Closed Bug 1829610 Opened 2 years ago Closed 8 months ago

Spending most of the time computing original source URLs in the source-map worker

Categories

(DevTools :: Debugger, defect, P2)

defect

Tracking

(firefox143 fixed)

RESOLVED FIXED
143 Branch
Tracking Status
firefox143 --- fixed

People

(Reporter: ochameau, Assigned: nchevobbe)

References

(Blocks 1 open bug)

Details

(Keywords: perf-alert)

Attachments

(3 files)

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.

Severity: -- → S3
Priority: -- → P2

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.

See Also: → 1374505

Since Bug 1374505 was fixed, and URL constructor seems to handle custom protocols in last versions of all major browsers, we're removing the whatwg-url module in https://github.com/mozilla/source-map/pull/517
Once that's done and a new version of the sourcemap library is published, we can update it in mozilla central and remove the vendored whatwg-url.js we have in devtools

Bug 1653779 comment 41 highlights the current slowness of whatwg-url.
It would be interesting to re-profile bug 1653779 comment 17 test page after having migrated to native URL. To see if there is any useful followup to prevent doing so many URL lookups.

Assignee: nobody → nchevobbe
Status: NEW → ASSIGNED

Previous patch in the stack removed the only usage of the file.

Pushed by nchevobbe@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/609c1eaa5302 https://hg.mozilla.org/integration/autoland/rev/75979491ad07 [devtools] Update source-map moz.yaml to remove actions on now removed file. r=devtools-reviewers,ochameau. https://github.com/mozilla-firefox/firefox/commit/21654cc2598d https://hg.mozilla.org/integration/autoland/rev/75cc970beac0 [devtools] Update source-map package. r=devtools-reviewers,ochameau https://github.com/mozilla-firefox/firefox/commit/2e93880ec853 https://hg.mozilla.org/integration/autoland/rev/b99d46ab183a [devtools] Remove unused devtools/client/shared/vendor/whatwg-url.js. r=devtools-reviewers,bomsy.
Blocks: 1979058
Status: ASSIGNED → RESOLVED
Closed: 8 months ago
Resolution: --- → FIXED
Target Milestone: --- → 143 Branch

Improved the installer (non shippable) size on windows by 122KB (0.1%).

Regressions: 1979891

(In reply to Pulsebot from comment #7)

Pushed by nchevobbe@mozilla.com:
https://github.com/mozilla-firefox/firefox/commit/609c1eaa5302
https://hg.mozilla.org/integration/autoland/rev/75979491ad07
[devtools] Update source-map moz.yaml to remove actions on now removed file.
r=devtools-reviewers,ochameau.
https://github.com/mozilla-firefox/firefox/commit/21654cc2598d
https://hg.mozilla.org/integration/autoland/rev/75cc970beac0
[devtools] Update source-map package. r=devtools-reviewers,ochameau
https://github.com/mozilla-firefox/firefox/commit/2e93880ec853
https://hg.mozilla.org/integration/autoland/rev/b99d46ab183a
[devtools] Remove unused devtools/client/shared/vendor/whatwg-url.js.
r=devtools-reviewers,bomsy.

Perfherder has detected a build_metrics performance change from push b99d46ab183a0d8a42e57f3d58733882bf32a282.

If you have any questions, please reach out to a performance sheriff. Alternatively, you can find help on Slack by joining #perf-help, and on Matrix you can find help by joining #perftest.

Improvements:

Ratio Test Platform Options Absolute values (old vs new)
0.12% installer size osx-aarch64-shippable aarch64 nightly 103,743,682.42 -> 103,619,565.83

Details of the alert can be found in the alert summary, including links to graphs and comparisons for each of the affected tests.

If you need the profiling jobs you can trigger them yourself from treeherder job view or ask a performance sheriff to do that for you.

You can run all of these tests on try with ./mach try perf --alert 46052

The following documentation link provides more information about this command.

Keywords: perf-alert
QA Whiteboard: [qa-triage-done-c144/b143]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: