Support allocating string characters in the nursery
Categories
(Core :: JavaScript: GC, task, P2)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox122 | --- | fixed |
People
(Reporter: jandem, Assigned: sfink)
References
(Blocks 3 open bugs)
Details
(Whiteboard: [sp3])
Attachments
(1 file, 6 external files, 3 obsolete files)
|
2.93 KB,
text/plain
|
Details |
I added some logging here for nursery-allocated strings with malloc-allocated characters.
Starting Firefox and running Speedometer 3, we allocated about 900,000 strings. Of these, more than 99.1% of strings have <= 256 bytes of characters allocated using malloc.
It would be nice if we could allocate those in the nursery instead, similar to what we do for slots and elements. It'd potentially get rid of the malloc, but also the registerMallocedBuffer call which also shows up in profiles.
Updated•3 years ago
|
Updated•3 years ago
|
| Assignee | ||
Comment 1•3 years ago
|
||
Updated•3 years ago
|
| Assignee | ||
Comment 2•3 years ago
|
||
| Assignee | ||
Comment 3•3 years ago
|
||
| Assignee | ||
Comment 4•3 years ago
|
||
| Assignee | ||
Comment 5•3 years ago
|
||
| Assignee | ||
Comment 6•3 years ago
|
||
Updated•3 years ago
|
| Assignee | ||
Comment 8•3 years ago
|
||
There was a lando hiccup in landing this. It gave me an error message and the option to try again, I did, but then it showed that it had already successfully landed and the 2nd landing failed. So at least for now, it's all good.
Comment 9•3 years ago
|
||
Backed out for causing spidermonkey bustages.
- backout: https://hg.mozilla.org/integration/autoland/rev/384a2e0a03b3f201fdb65ba416d4a58cbdfdf4ab
- push: https://treeherder.mozilla.org/jobs?repo=autoland&revision=7067e9e6ee6cd0bf12b36862ff2a062b6b8a9b89
- failure log:
- /builds/worker/checkouts/gecko/js/src/vm/StringType.h:507:17: error: inline function 'JSString::allocSize' is not defined [-Werror,-Wundefined-inline]
- TEST-UNEXPECTED-FAIL | testDeduplication_ASSC | /builds/worker/checkouts/gecko/js/src/jsapi-tests/testDeduplication.cpp:105:CHECK failed: !SameChars(cx, depdep, original, 20)
| Assignee | ||
Comment 10•3 years ago
|
||
A simple benchmark of allocating lots of 89-93 byte strings and immediately throwing away 99% of them gives
without patches:
$JS stringbench.js 13.74s user 1.02s system 177% cpu 8.337 total
$JS stringbench.js 12.69s user 1.04s system 175% cpu 7.820 total
$JS stringbench.js 12.69s user 0.86s system 176% cpu 7.674 total
$JS stringbench.js 13.46s user 1.07s system 176% cpu 8.218 total
$JS stringbench.js 13.53s user 1.04s system 178% cpu 8.184 total
with patches:
$JS stringbench.js 13.16s user 1.06s system 176% cpu 8.041 total
$JS stringbench.js 13.20s user 1.00s system 176% cpu 8.051 total
$JS stringbench.js 12.83s user 1.01s system 176% cpu 7.821 total
$JS stringbench.js 13.31s user 0.99s system 176% cpu 8.110 total
$JS stringbench.js 13.32s user 1.03s system 177% cpu 8.096 total
So the median goes from 8.184sec -> 8.051sec (1.6% faster), the mean 8.047 -> 8.024 (2.9% faster). Which is basically nothing, given that all this program is doing is allocating and freeing. In the browser, I suppose it might reduce jemalloc lock contention, but that's pure speculation.
Using much longer strings (1561-1565 bytes):
without patches:
$JS stringbench.js 25.83s user 1.14s system 195% cpu 13.798 total
$JS stringbench.js 25.35s user 1.13s system 195% cpu 13.523 total
$JS stringbench.js 25.46s user 1.06s system 195% cpu 13.598 total
$JS stringbench.js 26.65s user 1.15s system 195% cpu 14.222 total
$JS stringbench.js 24.83s user 1.11s system 195% cpu 13.287 total
with patches:
$JS stringbench.js 26.15s user 1.18s system 195% cpu 13.977 total
$JS stringbench.js 24.05s user 1.00s system 195% cpu 12.822 total
$JS stringbench.js 25.52s user 1.10s system 195% cpu 13.609 total
$JS stringbench.js 26.39s user 1.20s system 195% cpu 14.121 total
$JS stringbench.js 26.61s user 1.11s system 195% cpu 14.170 total
the median does 13.598 -> 13.977 so this is a net slowdown. Oh! But 1561 bytes is long enough that it won't be allocated in the nursery (there's a 1024 byte limit). Shortening those to about 975 bytes gives:
without patches:
$JS stringbench.js 18.78s user 1.26s system 178% cpu 11.257 total
$JS stringbench.js 18.37s user 1.17s system 178% cpu 10.977 total
$JS stringbench.js 17.09s user 1.21s system 175% cpu 10.407 total
$JS stringbench.js 17.36s user 1.20s system 177% cpu 10.465 total
$JS stringbench.js 18.54s user 1.29s system 176% cpu 11.216 total
with patches:
$JS stringbench.js 16.53s user 1.15s system 174% cpu 10.148 total
$JS stringbench.js 17.51s user 1.31s system 176% cpu 10.640 total
$JS stringbench.js 17.71s user 1.26s system 175% cpu 10.795 total
$JS stringbench.js 16.99s user 1.18s system 175% cpu 10.364 total
$JS stringbench.js 16.82s user 1.19s system 174% cpu 10.294 total
So that's 10.977 -> 10.364, a 5.6% speedup. That's finally showing some improvement. I'll attach the benchmark script.
| Assignee | ||
Comment 11•3 years ago
|
||
Comment 12•3 years ago
|
||
Comment 13•3 years ago
|
||
Backed out for causing spider-monkey failures
Backout link: https://hg.mozilla.org/integration/autoland/rev/8f617a8e582152cf2871ae0c2ef9a6a382672feb
| Assignee | ||
Comment 14•3 years ago
|
||
| Assignee | ||
Comment 15•3 years ago
|
||
Comment 16•3 years ago
|
||
Comment on attachment 9362940 [details]
Bug 1853907 - Add MarkInfo::UNKNOWN to the (debug-only) output possibilities (instead of falling back to NURSERY most of the time)
Revision D193260 was moved to bug 1864090. Setting attachment 9362940 [details] to obsolete.
Comment 17•3 years ago
|
||
Comment on attachment 9362941 [details]
Bug 1853907 - Fix tests whose behavior depends on nursery strings and string buffers
Revision D193261 was moved to bug 1864750. Setting attachment 9362941 [details] to obsolete.
| Assignee | ||
Comment 18•3 years ago
|
||
Comment 19•2 years ago
|
||
Comment 20•2 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/99b1db19b1ee
https://hg.mozilla.org/mozilla-central/rev/3f10ccc211d6
https://hg.mozilla.org/mozilla-central/rev/bd6ad1a1a257
https://hg.mozilla.org/mozilla-central/rev/6e5d85fa4c3d
https://hg.mozilla.org/mozilla-central/rev/9047fbab5114
https://hg.mozilla.org/mozilla-central/rev/cb3c756775b2
https://hg.mozilla.org/mozilla-central/rev/dbd1a6aef0a7
| Assignee | ||
Updated•2 years ago
|
Comment 21•2 years ago
|
||
3.6% improvement on AWFY-Speedometer2.1-Flight-TodoMVC*
And maybe some smaller improvements on react-redux
Comment 22•2 years ago
|
||
This had a noticeable improvement to TodoMVC-JavaScript-ES6-Webpack on Linux: https://treeherder.mozilla.org/perfherder/graphs?highlightAlerts=1&highlightChangelogData=1&highlightCommonAlerts=0&series=mozilla-central,4687545,1,13&series=mozilla-central,4687881,1,13&series=mozilla-central,4725722,1,13&series=autoland,4686894,1,13&timerange=7776000&zoom=1700744865324,1700861140365,85.64141598706868,139.62161379152042
Description
•