Replace use of EncodedSize with bitmap in buffer allocator
Categories
(Core :: JavaScript: GC, task, P1)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox143 | --- | fixed |
People
(Reporter: jonco, Assigned: jonco)
References
(Blocks 1 open bug)
Details
Attachments
(3 external files, 2 obsolete files)
EncodedSize was added to represent a buffer size in a more compact way so we didn't have to use more than one byte per possible allocation start in a chunk. However I saw memset showing up in some benchmarks from clearing the size array when allocating small buffers in chunks with the changes in bug 1973033.
I realized that, clever though EncodedSize was, it's more efficient to store a bitmap of the end position of allocations. This is slightly less efficient when looking up the size but that happens rarely outside of sweeping. This has another advantage too as it means we can support allocations that are any multiple of the granularity so it's less restrictive that using EncodedSize.
Replacing the encoding size with a bitmap reduces the size of BufferChunk header by 192 bytes, nearly halving its size.
This change also opens the door to future sweeping optimisations where we can find free regions by using bitmap operations instead of iterating through every allocation.
| Assignee | ||
Comment 1•1 year ago
|
||
Refactor AllocIter into a more general purpose BitSetIter which we can use for
our other bitmaps.
| Assignee | ||
Comment 2•1 year ago
|
||
We have a bunch of these bitmaps were each bit set corresponds to a location in
memory. This adds a template class to make an iterator over these locations out
of a bitmap iterator.
| Assignee | ||
Comment 3•1 year ago
|
||
The new bitmap has a bit set corresponding the the byte after the end of each
allocation, except if it abuts the end of the chunk.
| Assignee | ||
Comment 4•1 year ago
|
||
Reading the current allocation size is now a race for allocations in chunks
that are currently being swept, and this affects realloc operations which need
to know how much data to copy even if the chunk is being swept. One option is
to make allocEndBitmap atomic, but it's simpler to pass the current allocation
size in since it's always known.
| Assignee | ||
Comment 5•1 year ago
|
||
This can also now race with sweeping so don't allow it. We only use this for
debugging support so this doesn't have too much impact.
Updated•1 year ago
|
https://hg.mozilla.org/mozilla-central/rev/74c430ab20d9
https://hg.mozilla.org/mozilla-central/rev/1bd14903e3b1
https://hg.mozilla.org/mozilla-central/rev/8b2d0fbfb68b
https://hg.mozilla.org/mozilla-central/rev/cc1513d9c3aa
https://hg.mozilla.org/mozilla-central/rev/44ec9d7f58f3
Updated•1 year ago
|
Updated•1 year ago
|
Description
•