Closed Bug 1586971 Opened 5 years ago Closed 5 years ago

[BinAST] Add single-entry variant for `HuffmanTable`

Categories

(Core :: JavaScript Engine, task, P3)

task

Tracking

()

RESOLVED FIXED
mozilla71
Tracking Status
firefox71 --- fixed

People

(Reporter: arai, Assigned: arai)

References

Details

Attachments

(1 file)

single-entry table can appear frequently, and allocating 1 entry Vector is inefficient in term of Mutex and also space-efficiency.
we can add another variant with fixed-size inline array.
(maybe this applies also to non-single entry, maybe up to 2 or 3)

locally, this improves the performance by 12% with parsing 200 small files.

Blocks: 1586972

running try with new SingleEntryHuffmanTable<T> type.
https://treeherder.mozilla.org/#/jobs?repo=try&revision=84b556e99f771c45daca57f51de30ef8a7b26080

then, here's the size of tables:

table size in bytes
GenericHuffmanTable<T> 88
SingleEntryHuffmanTable<T> 8 + sizeof(T)
SingleLookupHuffmanTable<T> 72
TwoLookupsHuffmanTable<T> 80
ThreeLookupsHuffmanTable<T> 80

the maximum of sizeof(T) is 8, so single HuffmanEntry can consume 16 bytes.
and we can use up to 5 entries (80 / 16) without consuming extra space in
GenericHuffmanTable<T>, if we add dedicated variant for each number of entries.
(I haven't checked if adding another variants improves the speed tho)

See Also: → 1586975

just noticed that we don't need HuffmanEntry<T> field but just T
will post fixed one.
this reduces the size by 8.
(might apply for 2 or more entires case)

(In reply to Tooru Fujisawa [:arai] from comment #0)

single-entry table can appear frequently, and allocating 1 entry Vector is inefficient in term of Mutex and also space-efficiency.

Based on this comment, I would have expected the patch to look like:

- using Table = Vector<Foo, 0, systemAllocPolicy>;
+ using Table = Vector<Foo, 1, systemAllocPolicy>;

(In reply to Nicolas B. Pierron [:nbp] from comment #4)

(In reply to Tooru Fujisawa [:arai] from comment #0)

single-entry table can appear frequently, and allocating 1 entry Vector is inefficient in term of Mutex and also space-efficiency.

Based on this comment, I would have expected the patch to look like:

- using Table = Vector<Foo, 0, systemAllocPolicy>;
+ using Table = Vector<Foo, 1, systemAllocPolicy>;

Yeah, that also works in term of reducing allocation in SingleLookupHuffmanTable.
but adding pre-allocated elements in Vector increases the size of SingleLookupHuffmanTable (because of bigger Vector.mTail),
and that results in increasing the size of GenericHuffmanTable (because SingleLookupHuffmanTable becomes the biggest type),
while adding another non-Vector variant doesn't,
so I chose this way for space-efficiency.

another solution would be making SingleLookupHuffmanTable's implementation a Variant internally, and use static array variant for smaller case.
this would also solve the case that SingleLookupHuffmanTable is used inside MultiLookupHuffmanTable and the SingleLookupHuffmanTable gets only 1 item.

Pushed by arai_a@mac.com:
https://hg.mozilla.org/integration/autoland/rev/0c243363fa85
Add SingleEntryHuffmanTable. r=Yoric
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla71
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: