New issue
Advanced search Search tips

Issue 740874 link

Starred by 3 users

Issue metadata

Status: Fixed
Owner:
Closed: Jul 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 1
Type: Bug



Sign in to add a comment

Module scripts have very slow performance on certain module trees

Reported by guybedf...@gmail.com, Jul 11 2017

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36

Steps to reproduce the problem:
I've extracted out a sample dependency tree of 170 modules from Babel code (with the code all removed, just leaving import relations), with some circular references, which practically brings the pipeline to a halt, taking almost 20 seconds to process. In Safari this same tree can load in under 200ms.

1. Clone https://github.com/guybedford/modules-slow-tree
2. Run a local server
3. Open /test.html

What is the expected behavior?
This module tree should be able to load a lot faster.

What went wrong?
It seems like an unnecessarily high order loop somewhere in the pipeline implementation or cache.

Did this work before? N/A 

Chrome version: 61.0.3154.0  Channel: canary
OS Version: OS X 10.12.5
Flash Version:
 

Comment 1 by rtoy@chromium.org, Jul 11 2017

Cc: rtoy@chromium.org
Labels: Needs-Feedback
How did you measure the time to load the module?  Using the developer tools and profiling the page load, I get 300 ms or so total with Chrome canary on OSX.  Perhaps I'm not measuring this correctly?
It's definitely demonstrating the slowdown for me. I've attached a gif here of the page load process. I'm running on a 2014 Macbook Air, if there's anything specific about my environment that might be affecting this that you can think of let me know?
chrome-modules-slow-tree.gif
1.7 MB View Download
Also note the Chrome version is 61.0.3155.0.
Project Member

Comment 4 by sheriffbot@chromium.org, Jul 12 2017

Labels: -Needs-Feedback
Thank you for providing more feedback. Adding requester "rtoy@chromium.org" to the cc list and removing "Needs-Feedback" label.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot

Comment 5 by junov@chromium.org, Jul 12 2017

Components: -Blink Blink>JavaScript
Status: Untriaged (was: Unconfirmed)
Able to repro in Chrome 61 on linux.  
Note that in addition there is a bug here too in this test case that an error message "Binding not found" is supposed to be thrown but isn't.
Actually, ignore my previous comment, I just ran the test case again and the missing binding error is no longer happening for me.
Cc: rmcilroy@chromium.org
Components: -Blink>JavaScript Blink>JavaScript>Parser
Status: Available (was: Untriaged)
Cc: neis@chromium.org adamk@chromium.org
Adding Georg and Adam due to this being module related.

Comment 10 by adamk@chromium.org, Jul 18 2017

Cc: module-dev@chromium.org
Components: -Blink>JavaScript>Parser Blink>HTML>Script

Comment 11 by adamk@chromium.org, Jul 19 2017

Labels: -Pri-2 -OS-Mac OS-All Pri-1
Owner: kouhei@chromium.org
Status: Assigned (was: Available)
I suspect this is a dup of  issue 722728 . At the least, https://codereview.chromium.org/2889783002/ should make this a lot faster by not queueing unnecessary tasks on the runloop.

Comment 12 by adamk@chromium.org, Jul 19 2017

Not sure that exact patch will help: I tried adapting it locally and still see tens of thousands of tasks.
Thanks Adam for looking into this. Could it be that there is unnecessary looping in the dependency algorithm, perhaps by calling a full top-level dependency trace on each individual module load instead of just the top-level module or something similar?

Comment 14 by adamk@chromium.org, Jul 19 2017

Trace attached, showing huge number of tasks.
trace_slow-modules.json.gz
4.2 MB Download

Comment 15 by adamk@chromium.org, Jul 19 2017

I've instrumented the code to get some more concrete numbers. There are a total of 478,748 tasks dispatched by the ModuleMap. over 460,000 of them are dispatched here:

https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/dom/ModuleMap.cpp?rcl=cd7e31fb911a98c7dc021d543e9dea8c553cdb1f&l=79

where we call ModuleMap::Entry::AddClient() for an entry that's already finished fetching.

The rest of the notifications come from NotifyNewSingleModuleFinished, which loops over the clients. We dispatch to a total of 18,638, so over 100 clients per module, on average.
Thanks. I'll try porting the patch which batches the Dispatch... tasks for a single MTL.
Status: Fixed (was: Assigned)
https://chromium-review.googlesource.com/c/578531/ has fixed this

Sign in to add a comment