Allow ModuloBuffer and BlockRingBuffer to be used over an existing byte buffer
Categories
(Core :: Gecko Profiler, task, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox70 | --- | fixed |
People
(Reporter: mozbugz, Assigned: mozbugz)
References
Details
Attachments
(1 file)
In some cases it would be useful for BlocksRingBuffer (and its underlying ModuloBuffer) to work over an existing byte buffer.
So we could use an array of bytes on the stack, e.g.:
constexpr auto size = MakePowerOfTwo32<8192>;
uint8_t buffer[size.Value()];
BlocksRingBuffer brb(buffer, size);
This saves having to do a heap allocation.
Sometimes a small ProfileBuffer (where BlocksRingBuffer will eventually be used) is created to sample a stack, so this will help remove another allocation there. And it could be useful during the transition of markers to use BlocksRingBuffer (TBC).
Finally, this will help with testing, by creating a pre-filled buffer, testing a ModuloBuffer or BlocksRingBuffer in the middle, and verifying that nothing around it was unexpectedly modified.
Assignee | ||
Comment 1•5 years ago
|
||
By default ModuloBuffer
allocates its own buffer on the heap.
Now ModuloBuffer
adds two alternatives:
- Take ownership of a pre-allocated
UniquePtr<uint8_t>
buffer. - Work over an unowned
uint8_t*
array. The caller is responsible for
ownership, and ensuring that the array lives at least as long as the
ModuloBuffer
/BlocksRingBuffer
.
BlocksRingBuffer
can pass along these new options to its underlying
ModuloBuffer
.
The main use will be for small on-stack BlocksRingBuffer
that can store a
stack trace, or to more easily collect data (without allocating anything on the
heap) that can then go into the upcoming ProfileBuffer
's BlocksRingBuffer
.
Pushed by gsquelart@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/0dac048b774a ModuloBuffer and BlocksRingBuffer can be given a external underlying buffer - r=gregtatum
Comment 3•5 years ago
|
||
These changes seem to have increased bug 1546797 occurrences:
https://treeherder.mozilla.org/#/jobs?repo=autoland&fromchange=6fa38c5ad525da1cd85cd3190ee05ac060a53102&searchStr=linux%2Cx64%2Casan%2Cmochitests%2Ctest-linux64-asan%2Fopt-mochitest-browser-chrome-e10s-10%2Cm%28bc10%29&tochange=2edf1cdeb9939a621a9128116e7d7f00efdbc0cc&selectedJob=257338460
:gerald could you, please, take a look?
Assignee | ||
Comment 4•5 years ago
|
||
I'd say that's not possible, as ModuloBuffer and BlocksRingBuffer are not used yet in Firefox!
(They're only used in the cppunittest TestBaseProfiler.cpp, which I would hope should not influence mochitests.)
Comment 5•5 years ago
|
||
bugherder |
Description
•