Spending most of the time computing original source URLs in the source-map worker
Categories
(DevTools :: Debugger, defect, P2)
Tracking
(Not tracked)
People
(Reporter: ochameau, Unassigned)
References
(Blocks 1 open bug)
Details
When debugging reddit, the sourcemap worker spends most of the time parsing the original source URLs. There is tons of original sources in reddit and so it can be really slow on slow hardware.
The following profile comes from a very fast laptop with 100% performance settings:
https://share.firefox.dev/3H8o9zR
408ms
The same record with the same laptop in 100% battery saving settings:
https://share.firefox.dev/3mZQPnO
550ms
The same again, from a VM:
https://share.firefox.dev/3N5fSAz
6100ms!!
I've witness this being an issue while debugging reddit over zoom with Tom.
Updated•2 years ago
|
Reporter | ||
Comment 1•2 years ago
|
||
This relates to bug 1374505. The source-map library could be using native URL contructor if bug 1374505 was fixed.
When running from node, the source-map library is already using URL constuctor.
Otherwise, the usage of URL from the library is complex.
It is used from the following module:
https://searchfox.org/mozilla-central/rev/8329a650e3b4f866176ae54016702eb35fb8b0d6/devtools/client/shared/vendor/source-map/lib/util.js
We are using it to easily resolve original module path or URL to a absolute URL.
In this util.js module we are spawning lots of URL objects in non-trivial ways.
There is probably lots of edgecases in the resolution of these paths,
but it sounds like we could be doing something simplier, where we might avoid using URL constructor
and at least use it only once in the resolution.
From a unique usage, we might more easily be able to workaround the current limitation of native URL objects.
Last but not least, the usage of whatwg-url is a long term issue.
It is significantly larger than the source-map library itself and was reported to be an issue by the people importing source-map library in their website/node application.
So performance isn't the only issue related to this library.
Also note that the debugger frontend used to be using whatwg-url for similar reason.
But as we were using from a unique place, we were able to introduce a temporary workaround to handle URL with schema that native URL object don't support correctly:
https://searchfox.org/mozilla-central/rev/8329a650e3b4f866176ae54016702eb35fb8b0d6/devtools/client/debugger/src/utils/url.js#62-65
(see bug 1770959)
This workaround isn't perfect, it introduced some regression that I wasn't able to find.
Description
•