Merge delazification stencil into initial stencil before encoding
Categories
(Core :: JavaScript Engine, task, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox88 | --- | fixed |
People
(Reporter: arai, Assigned: arai)
References
Details
Crash Data
Attachments
(7 files, 6 obsolete 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 |
In incremental stencil XDR, we encode initial stencil first, and then encode each delazification after that.
it means that, if a script is delazified, we have both lazy script data and delazified script data inside XDR.
ultimately, the lazy script data isn't necessary in the instantiated GC objects.
if we can somehow dedup the info, or drop unnecessary info, we can reduce the XDR size.
| Assignee | ||
Updated•4 years ago
|
| Assignee | ||
Comment 1•4 years ago
•
|
||
the lazy script data is necessary for the current instantiation steps, because we first instantiate initial stencil,
and then apply delazification stencils' instantiation, just like normal delazification.
if we somehow drop the first lazy data, the steps needs to be modified.
we had an idea about merging stencils on decode, before instantiation.
https://phabricator.services.mozilla.com/D90574
https://phabricator.services.mozilla.com/D90585
we might be able to revisit it.
| Assignee | ||
Comment 2•4 years ago
•
|
||
With current structure, we cannot remove a certain lazy script data from XDR data with simple move/copy operation, because data is stored into multiple spans,
and removing an item breaks the remaining part's indices (or, if we don't shift the items, it doesn't affect the space).
So, to remove the space taken by lazy script, we need to decode XDR data, and then remove the data taken by the lazy script (while keeping the lazy script's index itself as placeholder), and renumber remaining things, and then re-encode it at linearlize step. This needs to be operated recursively for all delazifications.
And when decoding, we need to merge all stencils into one, while ignoring the removed data.
The cost would almost be same as just decoding, merging, and re-encoding all stencils at linearlize step.
Either way, it's not good because it's performed on main thread, and taking long there results in long interruption.
So, if we want to reduce XDR size with such way, we should think about offloading the linearlize or the post-process work to helper thread.
| Assignee | ||
Comment 3•4 years ago
|
||
If we can bring initial CompilationStencil (or gc-free subset) around with ScriptSorce or somewhere while incremental encoding,
we can merge delazification into the initial stencil there, and encode the entire stencil at once when finalizing.
so that there's no duplication around script data, and also bug 1687094 will also be solved at the same time.
| Assignee | ||
Comment 4•4 years ago
|
||
Initial CompilationStencil's fields that is necessary for merging and encoding:
- all
BaseCompilationStencilfields- delazifications are merged into them
CompilationStencil.alloc- all delazification should use this allocator, given the result will be merged and held by initial stencil
CompilationStencil.input.options.instrumentationKinds- just to check if the stencil is encodable. this can be done earlier
CompilationStencil.moduleMetadataCompilationStencil.scriptExtra
In addition to that, it would be nice to reuse initial compilation's CompilationState.parserAtoms in delazification compilation,
so that atom indices created in delazifications doesn't require remapping when merging.
| Assignee | ||
Comment 5•4 years ago
|
||
the difference between the previous merge patch and the current situation is:
CompilationStencilwas usingVector, but now it usesSpan, and it's not extensibleCompilationStencilwas usingParserAtomsTablebut now it usesParserAtomSpan, and cannot intern/addParserAtom- most data was using
SystemAllocPolicy, but now all data is stored inLifoAlloc
so, if we keep using Span + LifoAlloc, merging (appending/concatenating) on each delazification isn't efficient.
it's better not to append/concatenate the span content on each delazification, but keep those Spans in "vector of Span",
and when finishing, concatenate all spans into single Vector, with mapping indices.
another solutions would be:
- add non-Span variant of
CompilationStencil(Vector+ParserAtomsTable), and use the previous way for encoding - make
CompilationStateportable, and store it inScriptSource, and reuse it across initial and delazification, and callCompilationState::finishwhen finishing encoding
| Assignee | ||
Comment 6•4 years ago
|
||
The reason why we chose Span was:
- a) to avoid alloc/ctor/dtor cost of Vector
- b) to directly use XDR buffer
for (a), if we don't store delazifications in XDR, the cost of Vector alloc/ctor/dtor on decode would be negligible,
but (b) still holds and we need Span, or at least variant.
| Assignee | ||
Comment 7•4 years ago
|
||
about reusing ParserAtomsTable:
if we reuse ParserAtomsTable across initial and delazification, we can get consistent TaggedParserAtomIndex, but
instantiation has problem, that delazification has to instantiate more atoms than current way, given
we don't have info that which atom is used by current compilation (delazification),
and also we don't keep atomCache across initial/delazification.
| Assignee | ||
Comment 8•4 years ago
|
||
the simplest way would be, just collect all CompilationStencil/BaseCompilationStencil references in the encoder,
and merge them while encoding.
we can use StencilDelazificationSet (or RefPtr/UniquePtr variant) for collecting them
| Assignee | ||
Comment 9•4 years ago
|
||
With WIP patch that merges stencils before encoding, the size of raptor yahoo-mail, mail_app_es6_09* XDR is reduced by 14%.
there, AtomTable is reduced by 51%, and ScriptData is also reduced by 51%.
| Assignee | ||
Updated•4 years ago
|
| Assignee | ||
Updated•4 years ago
|
| Assignee | ||
Comment 10•4 years ago
|
||
To return Vector-variant of CompilationStencil as the result of compilation,
it needs to be allocated separately from other CompilationState.
| Assignee | ||
Comment 11•4 years ago
|
||
| Assignee | ||
Comment 12•4 years ago
|
||
| Assignee | ||
Comment 13•4 years ago
|
||
| Assignee | ||
Comment 14•4 years ago
|
||
| Assignee | ||
Comment 15•4 years ago
|
||
Also add XDRStencilEncoder for non-incremental case, and
cleanup XDRStencilDecoder.
StencilDelazificationSet and gcOutputForDelazification become unused,
and will be removed by later patches.
| Assignee | ||
Comment 16•4 years ago
|
||
Now all stencils don't have associated delazification.
| Assignee | ||
Comment 17•4 years ago
|
||
| Assignee | ||
Comment 18•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
|
Updated•4 years ago
|
Updated•4 years ago
|
| Assignee | ||
Comment 19•4 years ago
|
||
Depends on D105157
| Assignee | ||
Comment 20•4 years ago
|
||
After removing BaseCompilationStencil, we could make the instantiation related methods non-static again.
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
| Assignee | ||
Comment 21•4 years ago
|
||
BorrowingCompilationStencil provides a CompilationStencil instance that
borrows all ExtensibleCompilationStencil data,
Not-borrow-able fields need to be moved to the temporary CompilationStencil,
and BorrowingCompilationStencil destructor returns them.
Depends on D105153
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
|
Updated•4 years ago
|
Updated•4 years ago
|
| Assignee | ||
Comment 22•4 years ago
|
||
To make it possible to convert them each other.
Depends on D105908
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 23•4 years ago
|
||
Since merging stencils is a read-only operation for the source delazification
stencil and we already have a borrowed stencil at caller, it is more
consistent with our conventions to pass a CompilationStencil& instead of an
ExtensibleCompilationStencil&.
Comment 24•4 years ago
|
||
Comment 25•4 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/07d2db86c609
https://hg.mozilla.org/mozilla-central/rev/6ab4cbb8f4a2
https://hg.mozilla.org/mozilla-central/rev/8e59cd75371f
https://hg.mozilla.org/mozilla-central/rev/d1fc4ee5aa50
https://hg.mozilla.org/mozilla-central/rev/1ad324a72551
https://hg.mozilla.org/mozilla-central/rev/13b97543f899
https://hg.mozilla.org/mozilla-central/rev/efff9a5c7a1f
Comment 26•4 years ago
|
||
Backed out for frequent crashes in Nightly:
https://hg.mozilla.org/mozilla-central/rev/432c586951243c132694fa9988a691fbf5198cca
Example of crashes: bp-6d1d6c1a-c45e-4277-9d9b-12c3d0210303
0 xul.dll static js::frontend::CompilationStencil::instantiateStencilAfterPreparation(JSContext*, js::frontend::CompilationInput&, js::frontend::CompilationStencil const&, js::frontend::CompilationGCOutput&) js/src/frontend/Stencil.cpp:1341
1 xul.dll js::frontend::InstantiateStencils(JSContext*, js::frontend::CompilationInput&, js::frontend::CompilationStencil const&, js::frontend::CompilationGCOutput&) js/src/frontend/BytecodeCompiler.cpp:386
2 xul.dll js::ParseTask::instantiateStencils(JSContext*) js/src/vm/HelperThreads.cpp:722
3 xul.dll js::ScriptDecodeTask::parse(JSContext*) js/src/vm/HelperThreads.cpp:836
4 xul.dll js::ParseTask::runHelperThreadTask(js::AutoLockHelperThreadState&) js/src/vm/HelperThreads.cpp:619
5 xul.dll static js::HelperThread::ThreadMain(void*) js/src/vm/HelperThreads.cpp:2366
6 xul.dll static js::detail::ThreadTrampoline<void (&)(void*), js::HelperThread*>::Start(void*) js/src/threading/Thread.h:205
7 ucrtbase.dll thread_start<unsigned int (__cdecl*)(void*), 1>
8 kernel32.dll BaseThreadInitThunk
9 ntdll.dll RtlUserThreadStart
10 kernelbase.dll TerminateProcessOnMemoryExhaustion
Nightly updates have been halted and will resume once the new nightly builds with the backout are available.
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
|
Updated•4 years ago
|
Comment 27•4 years ago
|
||
| Assignee | ||
Updated•4 years ago
|
Comment 28•4 years ago
|
||
Backed out for causing Spidermonkey failures.
Backout link: https://hg.mozilla.org/integration/autoland/rev/f953699c07a294ea44ed655ca0cee3b547509c56
Failure log: https://treeherder.mozilla.org/logviewer?job_id=331962401&repo=autoland
| Assignee | ||
Comment 29•4 years ago
|
||
it's bug 1696205 patch.
will fix there.
Comment 30•4 years ago
|
||
Comment 31•4 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/19f9592d23c1
https://hg.mozilla.org/mozilla-central/rev/cf67566b48ab
https://hg.mozilla.org/mozilla-central/rev/21e179ac5547
https://hg.mozilla.org/mozilla-central/rev/b2c2e8ec8016
https://hg.mozilla.org/mozilla-central/rev/de2a4e293b88
https://hg.mozilla.org/mozilla-central/rev/2ccfa2d73d3c
https://hg.mozilla.org/mozilla-central/rev/0e8c6b3bd1e2
Description
•