Remove ObjectGroup
Categories
(Core :: JavaScript Engine, task, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox88 | --- | fixed |
People
(Reporter: jandem, Assigned: jandem)
References
(Blocks 2 open bugs)
Details
(Keywords: perf-alert)
Attachments
(18 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 |
edit: this comment refers to the original plan before the bug was morphed into removing ObjectGroup instead:
BaseShape
is just 4 words, it might make sense to merge into Shape:
flags_
could likely be merged into Shape flags word.- The
unowned_
pointer would go away. clasp
could then be removed from ObjectGroup (or Shape, but that's harder)Shape
obviously no longer needs a pointer to theBaseShape
- It would remove some pointer chasing.
I prototyped this a bit last week and it seems doable.
Assignee | ||
Comment 1•4 years ago
|
||
I should have time for this in a few weeks.
Assignee | ||
Comment 2•4 years ago
|
||
We'll have to see how this affects memory usage. It might be fine or even slightly better than now, but we just have to measure.
Assignee | ||
Comment 3•4 years ago
|
||
I prototyped removing BaseShape
yesterday. It adds a single word to Shape
so it's a memory regression, but it did allow removing the JSClass*
from ObjectGroup
. It removes a lot of code though, in particular owned vs unowned BaseShapes
are complicated.
After thinking/talking this through more, we now think it's worth keeping BaseShape
around for a bit and instead:
- Simplify
BaseShape
by moving the "cache pointer" and object flags toShape
. This adds a word toShape
but it lets us remove a bunch of complexity and overhead aroundBaseShapes
+ the indirection for the shape cache pointer. - Move the realm and proto from
ObjectGroup
toBaseShape
. - Remove
ObjectGroup
.
For TypedObjects
: move TypeDescr
from ObjectGroup
to the object. This could be stored as second word (instead of the current ObjectGroup
) so that we can still do a single branch for TypedObject
layout guards, relying on other objects never storing a bit-identical value there. The second (currently third) word will have to move into JSObject
to represent that invariant nicely.
Advantages here are:
- Removes a word from every JS object.
- Removes ObjectGroup overhead and complexity.
- Still simplifies BaseShape quite a bit.
The downsides:
- Adds an extra indirection for
{class, proto, realm}
pointers. __proto__
mutation would always require aBaseShape
+Shape
change, no moreUNCACHEABLE_PROTO
flag. This does simplify the system.
I don't expect it but if the UNCACHEABLE_PROTO
flag removal turns out to be an issue, we could bring it back by allowing the object to store the prototype in a fixed/dynamic slot: in this case the BaseShape
would store a slot index instead of the proto itself. This adds complexity and branches so isn't perfect, but we do have options there.
Assignee | ||
Comment 4•4 years ago
•
|
||
I have a WIP patch stack for this. Looking at Linux64 numbers on Try:
- Base Content JS is about 35K (~1.4%) less.
- For awsy-tp6 the improvement is a bit bigger, ~4% for JS memory.
- Speedometer and JetStream 2 aren't affected much, maybe a tiny bit faster but hard to say with only a few data points.
Memory reports are mostly as expected:
- Objects are smaller.
- ObjectGroups are gone.
- Shapes have an extra word so use more memory.
- BaseShapes are one word smaller; a ShapeTable/ShapeIC no longer requires a new BaseShape. Memory usage is similar to current ObjectGroup memory (expected because this basically turns BaseShape into ObjectGroup).
The number of GC-things drops a bit (no more groups, fewer BaseShapes) so I hope that will have a positive impact.
This also removes a lot of complexity (object groups, owned BaseShapes) so I'm pretty happy with it.
Updated•4 years ago
|
Assignee | ||
Comment 5•4 years ago
|
||
This adds a pointer to Shape, but it lets us remove owned BaseShapes in the next patch.
Accessing the ShapeTable/ShapeIC is now a bit more efficient because it removes a
level of indirection. Creating the ShapeTable/ShapeIC is also faster because we no
longer need to create a new (owned) BaseShape.
Because dictionary objects no longer have owned BaseShapes at this point, the patch
has to change BaseShape::adoptUnowned
calls to Shape::setBase
to prevent assertion
failures.
Updated•4 years ago
|
Assignee | ||
Comment 6•4 years ago
|
||
At this point all BaseShapes are unowned (= immutable, shared) so we can remove the
UnownedBaseShape type and the BaseShape::unowned_
field.
Simplify NextEnvironmentShape
by reusing the previous shape's BaseShape instead
of doing a slow lookup resulting in the same BaseShape.
Depends on D106971
Assignee | ||
Comment 7•4 years ago
|
||
The BaseShape::get
call is redundant. Reusing the BaseShape from the previous
last-property is equivalent and infallible, and lets us simplify the code a bit.
Depends on D106972
Assignee | ||
Comment 8•4 years ago
|
||
Depends on D106973
Assignee | ||
Comment 9•4 years ago
|
||
BaseShape stores the JSClass* too so this patch changes the code to get the JSClass*
from there instead of from the ObjectGroup.
Depends on D106974
Assignee | ||
Comment 10•4 years ago
|
||
Depends on D106975
Assignee | ||
Comment 11•4 years ago
|
||
Now that shapes have an associated realm/compartment, we could fail the tracingCompartment
assertion for same-zone but different-compartment shapes stored in IC stubs for
cross-compartment wrapper stubs.
This adds TraceSameZoneCrossCompartmentEdge to avoid that.
Also add an assertion to CacheIRWriter to ensure we don't embed cross-zone shapes.
Depends on D106976
Assignee | ||
Comment 12•4 years ago
|
||
Depends on D106977
Assignee | ||
Comment 13•4 years ago
|
||
The ObjectGroup still stores the proto as well but we don't really use it anymore.
This is simpler than removing the group's proto now because that would result in
"empty" groups and the group table then doesn't make sense anymore.
Depends on D106978
Assignee | ||
Comment 14•4 years ago
|
||
Depends on D106979
Assignee | ||
Comment 15•4 years ago
|
||
Shape implying proto lets us simplify CacheIR guards. The UncacheableProto flag
is now only used to invalidate and disable the shape teleporting optimization.
Depends on D106980
Assignee | ||
Comment 16•4 years ago
|
||
Depends on D106981
Assignee | ||
Comment 17•4 years ago
|
||
Depends on D106982
Assignee | ||
Comment 18•4 years ago
|
||
We were relying on this flag being set in ObjectGroup::defaultNewGroup, but that's
going away soon.
Depends on D106983
Assignee | ||
Comment 19•4 years ago
|
||
This effectively removes groups from objects, but the actual object shrinking happens
in the next patch.
Depends on D106984
Assignee | ||
Comment 20•4 years ago
|
||
Note that on 32-bit platforms, JSObject is still 8 bytes. This means we don't have
to worry about misaligned DoubleValue stores to fixed slots on ARM32/MIPS32.
Depends on D106985
Assignee | ||
Comment 21•4 years ago
|
||
Depends on D106986
Assignee | ||
Comment 22•4 years ago
|
||
Depends on D106987
Comment 23•4 years ago
|
||
Comment 24•4 years ago
|
||
Backed out for wpt failures on Event-subclasses-constructors.html
Backout link: https://hg.mozilla.org/integration/autoland/rev/be83e8dbc365e0c03dd57e2dca49dfde1be07843
Log link: https://treeherder.mozilla.org/logviewer?job_id=332237591&repo=autoland&lineNumber=6501
Assignee | ||
Comment 25•4 years ago
|
||
(In reply to Narcis Beleuzu [:NarcisB] from comment #24)
Backed out for wpt failures on Event-subclasses-constructors.html
It's annoying that mach try auto
didn't run that test, but it's a good find. This is an issue with InitializePropertiesFromCompatibleNativeObject
, an API that's only used in the browser.
Comment 26•4 years ago
|
||
Comment 27•4 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/1ae4c30bb931
https://hg.mozilla.org/mozilla-central/rev/e9c2f256240a
https://hg.mozilla.org/mozilla-central/rev/d5d3cb487914
https://hg.mozilla.org/mozilla-central/rev/2186bd51bebd
https://hg.mozilla.org/mozilla-central/rev/9bfa6023a553
https://hg.mozilla.org/mozilla-central/rev/11fc8f557a2a
https://hg.mozilla.org/mozilla-central/rev/1eb43e6ab1f8
https://hg.mozilla.org/mozilla-central/rev/cad616508f73
https://hg.mozilla.org/mozilla-central/rev/ec72f104edbf
https://hg.mozilla.org/mozilla-central/rev/40d2e0691861
https://hg.mozilla.org/mozilla-central/rev/8199e30ca52f
https://hg.mozilla.org/mozilla-central/rev/b91b9804031d
https://hg.mozilla.org/mozilla-central/rev/5986697cbefa
https://hg.mozilla.org/mozilla-central/rev/503f3d7f7162
https://hg.mozilla.org/mozilla-central/rev/483a1682c2fa
https://hg.mozilla.org/mozilla-central/rev/95cc69c76f0e
https://hg.mozilla.org/mozilla-central/rev/88d76a5c5958
https://hg.mozilla.org/mozilla-central/rev/4197952997ba
Assignee | ||
Updated•4 years ago
|
Comment 28•4 years ago
|
||
== Change summary for alert #29147 (as of Tue, 09 Mar 2021 13:35:56 GMT) ==
Improvements:
Ratio | Suite | Test | Platform | Options | Absolute values (old vs new) |
---|---|---|---|---|---|
3% | JS | linux1804-64-shippable-qr | tp6 | 171,553,938.45 -> 165,988,948.55 | |
3% | JS | macosx1015-64-shippable-qr | tp6 | 173,287,247.03 -> 168,843,936.09 | |
2% | JS | linux1804-64-shippable | tp6 | 169,816,956.09 -> 165,937,167.86 | |
2% | JS | windows10-64-shippable-qr | tp6 | 172,547,939.34 -> 168,766,500.09 | |
2% | JS | windows10-64-shippable | 89,135,713.16 -> 87,319,923.96 | ||
2% | JS | windows10-64-shippable | 89,073,843.86 -> 87,372,224.82 | ||
1% | Base Content JS | macosx1015-64-shippable-qr | 2,517,759.33 -> 2,480,250.67 | ||
1% | Base Content JS | linux1804-64-shippable-qr | 2,510,974.67 -> 2,474,522.67 | ||
1% | Base Content JS | linux1804-64-shippable | 2,509,538.00 -> 2,474,546.67 | ||
1% | Base Content JS | windows10-64-shippable | 2,513,248.00 -> 2,478,816.00 | ||
1% | Base Content JS | windows10-64-shippable-qr | 2,513,248.00 -> 2,478,816.00 |
For up to date results, see: https://treeherder.mozilla.org/perfherder/alerts?id=29147
Updated•4 years ago
|
Comment 29•4 years ago
|
||
== Change summary for alert #29132 (as of Mon, 08 Mar 2021 21:16:36 GMT) ==
Improvements:
Ratio | Suite | Test | Platform | Options | Absolute values (old vs new) |
---|---|---|---|---|---|
2% | netflix | loadtime | linux64-shippable-qr | cold nocondprof webrender | 765.21 -> 749.58 |
For up to date results, see: https://treeherder.mozilla.org/perfherder/alerts?id=29132
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Description
•