Span's size takes 4 bytes for each delazification, even if it's empty
Categories
(Core :: JavaScript Engine, task, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox86 | --- | fixed |
People
(Reporter: arai, Assigned: arai)
References
Details
Attachments
(1 external file, 1 obsolete file)
raptor yahoo-mail's largest JS file's XDR contains ~4700 delazifications, and
each one takes 4 bytes to encode BigIntData.size() = 0
we should add single byte for each BaseCompilationStencil that describes which span isn't empty.
in most case regExpData.size() is also 0, and in some case objLiteralData.size() is also 0,
so we can compress up to 12 bytes into 1 byte.
other possibility is to use varint, even if the span isn't empty.
so that we can compress size data into 1 byte for each span, in most case.
| Assignee | ||
Comment 1•5 years ago
|
||
because of alignment (align32) before span content, 1 byte before the alignment can become 4 bytes, (depending on the alignment before that)
so we should compress at least 5 bytes into 1 byte to get actual size reduction, consistently.
gathering flags and all sizes with varint before all spans' contents could help.
| Assignee | ||
Updated•5 years ago
|
| Assignee | ||
Updated•5 years ago
|
| Assignee | ||
Comment 2•5 years ago
|
||
with the patch that adds flag, and then use varint for span/vector size, the size taken by XDR of raptor tp6 yahoo-mail mail_app_es6_09* JS file:
| unpatched | patched | diff | |
|---|---|---|---|
| Version | 22 | 22 | 0 |
| AtomTable | 1,977,500 | 1,977,500 | 0 |
| ImmutableScriptData | 1,984,138 | 1,984,138 | 0 |
| Scope | 164,428 | 150,359 | -14,069 |
| ScopeName | 212,848 | 194,040 | -18,808 |
| BigInt | 18,808 | 0 | -18,808 |
| Object | 180,382 | 163,231 | -17,151 |
| RegExp | 19,320 | 544 | -18,776 |
| GCThingData | 479,194 | 465,138 | -14,056 |
| ScriptData | 765,064 | 750,966 | -14,098 |
| ScriptExtra | 490,212 | 490,212 | 0 |
| SharedData | 4,702 | 4,702 | 0 |
| Module | 0 | 0 | 0 |
| Source | 3,071,613 | 3,071,613 | 0 |
| Chunk | 37,621 | 42,315 | +4,694 |
| Total | 9,405,852 | 9,294,780 | -111,072 |
| Assignee | ||
Comment 3•5 years ago
|
||
To reduce the size taken by empty span's size, compress possibly-empty span's
info into single byte flag.
| Assignee | ||
Comment 4•5 years ago
|
||
Because of alignment before span content, 1 byte flag could inflate to 4 bytes.
Use varint for all span/vector length and encode them before span, so that
the size reduction works more efficiently.
Depends on D102119
Comment 5•5 years ago
|
||
I'm wondering if instead of optimizing for optimal size in all cases, I wonder if we can instead focus on a few simple patterns and simplify the code.
// Leaf delazification. Implicitly, nscript = 1.
| 00000000 | nscope | ngcthing | nobjlit |
// All lists are 8-bit. I expect this is very common.
| 00000001 | nscope | ngcthing | nobjlit |
| | nscript | nbigint | regexp |
// Use flags for u32 lengths.
| XXXXXXX1 | nscope | ngcthing | nobjlit |
| | nscript | nbigint | regexp |
...
| <32-bit value for each flagged value> |
What do you think? I expect it to be very effective since any Stencil that exceeds 256 in one dimension will have data much larger than any header. It should also be fast to decode and maintain u32 alignment.
u23 nscript = 1;
u32 nscope = ...;
u32 ngcthing = ...;
u32 nobjlit = ...;
u32 nbigint = 0;
u32 nregexp = 0;
if (flags) {
nbigint = ...
nregexp = ...
if (flags > 0x1) {
if (flags & 0x2) nscript = ...;
...
}
}
Comment 6•5 years ago
|
||
Also, optimizing FunctionKey does seem worthwhile if delazify always uses it. Instead I'd rather we just try to shrink FunctionKey to u32 (Bug 1687400)
Comment 7•5 years ago
|
||
In the future I'd like to remove Xdr.{cpp,h} entirely and stop doing these byte-by-byte operations.
| Assignee | ||
Comment 8•5 years ago
|
||
checked yahoo-mail:
script,gcThing,scope <= 0xff, regExp,bigInt,objLit == 0 : 5312
script,gcThing,scope,regExp,bigInt,objLit <= 0xff : 2429
script,gcThing,scope <= 0xffff, regExp,bigInt,objLit == 0 : 6
script,gcThing,scope,regExp,bigInt,objLit <= 0xffff : 27
other : 0
also on google-mail:
script,gcThing,scope <= 0xff, regExp,bigInt,objLit == 0 : 9584
script,gcThing,scope,regExp,bigInt,objLit <= 0xff : 598
script,gcThing,scope <= 0xffff, regExp,bigInt,objLit == 0 : 7
script,gcThing,scope,regExp,bigInt,objLit <= 0xffff : 14
other : 0
and on twitch:
script,gcThing,scope <= 0xff, regExp,bigInt,objLit == 0 : 6935
script,gcThing,scope,regExp,bigInt,objLit <= 0xff : 2523
script,gcThing,scope <= 0xffff, regExp,bigInt,objLit == 0 : 5
script,gcThing,scope,regExp,bigInt,objLit <= 0xffff : 21
other : 0
So, I think having the following options should be sufficient:
- script,gcThing,scope fits 1 byte, other are 0
- all fits 1 byte
- all fits 2 bytes
- other (all fits 4 bytes)
Comment 9•5 years ago
|
||
Based on your numbers, we might be fine to combine case 3/4. They are less than 1% of stencils.
Updated•5 years ago
|
Updated•5 years ago
|
Comment 10•5 years ago
|
||
Comment 11•5 years ago
|
||
| bugherder | ||
Description
•