Remove well-known and static string atom instance
Categories
(Core :: JavaScript Engine, task, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox87 | --- | fixed |
People
(Reporter: arai, Assigned: arai)
References
(Blocks 1 open bug)
Details
Attachments
(21 files)
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review |
If all operations on well-known/static ParserAtomEntry
pointer outside of ParserAtomsTable
can be moved inside ParserAtomTable (bug 1689892), we can remove well-known/static ParserAtomEntry
instances and instead use only TaggedParserAtomIndex
as reference to them.
so that:
- reduce rodata size
- reduce startup cost for initializing the well-known table
- enable adding more well-known/static
- bug 1689434 (length-3 or more static strings)
- make all atoms in self-hosted.js well-known
Assignee | ||
Comment 1•4 years ago
|
||
for static strings, the content can be encoded directly in the TaggedParserAtomIndex
, so we don't need extra space.
for well-known, we'll need string constant in addition to atom index, to retrieve the content,
but that can be shared between VM well-known atoms or other static string constant.
Assignee | ||
Comment 2•4 years ago
|
||
Thinking a bit more about the merit:
ParserAtomEntry
consists of:
HashNumber hash_
uint32_t length_
uint32_t flags_
- trailing chars
even if we remove the entry instance, we need hash and the equivalent of trailing chars.
So, 8 bytes (length and flags) can be definitely reduced for each atom.
then, for well-known atoms, we already have const char js_FOO_str[];
, so that can be shared.
https://searchfox.org/mozilla-central/rev/927e525f481a93a8f63d27a78ae6201e42b1b1fb/js/src/vm/JSAtom.cpp#220-222
Assignee | ||
Comment 3•4 years ago
|
||
bug 1689434 experiment proved that we can have TaggedParserAtomIndex
without ParserAtomEntry
instance.
the problem there were:
- cannot statically calculate/allocate hash
- atomization in toExistingJSAtom call
for well-known and length-1/2 case, we already calculate/allocate hash, and toExistingJSatom
doesn't touch ParserAtomEntry
instance but just returns from VM side's table,
so this should work.
Assignee | ||
Updated•4 years ago
|
Assignee | ||
Comment 4•4 years ago
|
||
https://treeherder.mozilla.org/jobs?repo=try&revision=8934f21512c29261e32a08e0490a4049f89ad881
the patch doesn't yet dedup well-known atoms' string in frontend and js_FOO_str
.
I hoped compiler can do that automatically, but maybe I should explicitly point the same string.
Assignee | ||
Comment 5•4 years ago
|
||
maybe we can move the WellKnownStringInfo
in the patch out of frontend, and use that also from JSAtom.cpp
WellKnownStringInfo
also contains hash, so JSRuntime::initializeAtoms
can use that info to skip hash calculation on runtime
Assignee | ||
Comment 6•4 years ago
|
||
Here's the plan:
- Rewrite length-1/2 cases not to retrieve
ParserAtom
, but construct necessary info (content, length) in place - Add
WellKnownAtomInfo
that holds (content, length, hash) for each well-known atoms - Use
WellKnownAtomInfo
array to populateWellKnownParserAtoms::wellKnownMap_
- Rewrite well-known atom case not to retrieve
ParserAtom
, but useWellKnownAtomInfo
- Remove
WellKnownParserAtoms_ROM
andWellKnownParserAtoms
's pointer fields - Dedup
js_*_str
andWellKnownAtomInfo
content - Rewrite
JSAtom
common names initialization to useWellKnownAtomInfo
array, with pre-calculated hash
Assignee | ||
Comment 7•4 years ago
|
||
Assignee | ||
Comment 8•4 years ago
|
||
Assignee | ||
Comment 9•4 years ago
|
||
Depends on D104593
Assignee | ||
Comment 10•4 years ago
|
||
Depends on D104594
Assignee | ||
Comment 11•4 years ago
|
||
Depends on D104595
Assignee | ||
Comment 12•4 years ago
|
||
Depends on D104596
Assignee | ||
Comment 13•4 years ago
|
||
Depends on D104597
Assignee | ||
Comment 14•4 years ago
|
||
Depends on D104598
Assignee | ||
Comment 15•4 years ago
|
||
Depends on D104599
Assignee | ||
Comment 16•4 years ago
|
||
Depends on D104600
Assignee | ||
Comment 17•4 years ago
|
||
Depends on D104601
Assignee | ||
Comment 18•4 years ago
|
||
Depends on D104602
Assignee | ||
Comment 19•4 years ago
|
||
Depends on D104603
Assignee | ||
Comment 20•4 years ago
|
||
Depends on D104604
Assignee | ||
Comment 21•4 years ago
|
||
Depends on D104605
Assignee | ||
Comment 22•4 years ago
|
||
Depends on D104606
Assignee | ||
Comment 23•4 years ago
|
||
WellKnownAtomInfo can be used also from JSAtom initialization later, so the
definition is placed in vm/WellKnownAtom.h, and also WellKnownAtomId is moved
there.
Depends on D104607
Assignee | ||
Comment 24•4 years ago
|
||
Depends on D104608
Assignee | ||
Comment 25•4 years ago
|
||
Depends on D104609
Assignee | ||
Comment 26•4 years ago
|
||
Depends on D104610
Assignee | ||
Comment 27•4 years ago
|
||
Depends on D104611
Assignee | ||
Comment 28•4 years ago
|
||
Depends on D104612
Assignee | ||
Comment 29•4 years ago
|
||
The result of size reduction
file | before | after | diff |
---|---|---|---|
js shell | 40,429,520 | 40,365,856 | -63,664 |
x86_64 dmg | 77,814,414 | 77,743,517 | -70,897 |
XUL | 161,242,216 | 161,193,856 | -48,360 |
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Comment 30•4 years ago
|
||
Comment 31•4 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/218bb88bba9d
https://hg.mozilla.org/mozilla-central/rev/1c3cdfd28aff
https://hg.mozilla.org/mozilla-central/rev/0449ae9ec529
https://hg.mozilla.org/mozilla-central/rev/a8abd8e27509
https://hg.mozilla.org/mozilla-central/rev/8118bd961f9c
https://hg.mozilla.org/mozilla-central/rev/6e986649b078
https://hg.mozilla.org/mozilla-central/rev/8bf00cffdeba
https://hg.mozilla.org/mozilla-central/rev/218133df75d4
https://hg.mozilla.org/mozilla-central/rev/e3c635019f2a
https://hg.mozilla.org/mozilla-central/rev/d85cd571f708
https://hg.mozilla.org/mozilla-central/rev/c73eb9133e56
https://hg.mozilla.org/mozilla-central/rev/833782d13263
https://hg.mozilla.org/mozilla-central/rev/74cbe3f3c730
https://hg.mozilla.org/mozilla-central/rev/b2ba7e3b9245
https://hg.mozilla.org/mozilla-central/rev/52dd05ae7c18
https://hg.mozilla.org/mozilla-central/rev/d80f85078a7f
https://hg.mozilla.org/mozilla-central/rev/a97f35aa5813
https://hg.mozilla.org/mozilla-central/rev/6550f2638e10
https://hg.mozilla.org/mozilla-central/rev/11be0b92d7fa
https://hg.mozilla.org/mozilla-central/rev/8b5f8b69af1f
https://hg.mozilla.org/mozilla-central/rev/b23da4ca0327
Description
•