Closed Bug 1626837 Opened 5 years ago Closed 5 years ago

Implement ProfileChunkedBuffer

Categories

(Core :: Gecko Profiler, task, P2)

task

Tracking

()

RESOLVED FIXED
mozilla77
Tracking Status
firefox77 --- fixed

People

(Reporter: mozbugz, Assigned: mozbugz)

References

(Blocks 2 open bugs)

Details

Attachments

(8 files)

47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review

ProfileChunkedBuffer simulates a near-infinite buffer over ProfileBufferChunks.
It uses a ProfileBufferChunkManager to get chunks and later release them.
Its use is similar to BlocksRingBuffer:

  • It reserves blocks in chunks, adds some structure (just the size of the entry that follows), and lets a user-provided writer write the entry.
  • It allows reading past entries.
  • It can be in an "out-of-session" state where APIs are still available but do nothing.

It is intended to be a replacement for BlocksRingBuffer.

ProfileBuffer used to check if a BlocksRingBuffer was in session by looking
at its buffer size.
Now IsInSession() should be used, it is clearer in intent, and will make the
transition to ProfileChunkedBuffer slightly easier.

ProfileChunkedBuffer simulates a near-infinite buffer over ProfileBufferChunks.
It uses a ProfileBufferChunkManager to get chunks and later release them.
Its use is similar to BlocksRingBuffer:

  • It reserves blocks in chunks, adds some structure (just the size of the entry
    that follows), and lets a user-provided writer write the entry.
  • It allows reading past entries.
  • It can be in an "out-of-session" state where APIs are still available but do
    nothing.

It is intended to eventually replace BlocksRingBuffer.

This patch starts with the basic structure, following patches will add all
planned features.

Depends on D69492

ProfileChunkedBuffer can handle zero of one ProfileBufferChunkManager at a
time, and can optionally take ownership of the manager.

Depends on D69493

To ensure that a spare chunk is ready to handle data that will eventually
overflow the current chunk, ProfileChunkedBuffer uses
ProfileBufferChunk::RequestChunk() to queue a request for a new chunk.

This request should be handled off-thread by the buffer user -- but a response
is not guaranteed, so the buffer does not rely on it and can get a new chunk
on the spot if really needed.

Because the request is asynchronous, and because either the buffer or the user
could be destroyed while a request is in flight, a shared
RequestedChunkRefCountedHolder object is used:

  • When the request is handled, the new chunk (or nullptr) is given to the
    holder.
  • When the buffer needs a new chunk, it can retrieve the new chunk if the
    request was successfully fulfilled.
    If the requestee is destroyed first, the request won't be fulfilled and the
    buffer will carry on without relying on requests.
    If the requester is destroyed first, the holder (with a potential requested
    chunk) will just get destroyed after the request is fulfilled or the requestee
    is destroyed as well.

Depends on D69494

InChunkPointer is an internal accessor pointing at a position inside a chunk.
It can handle up to two groups of chunks (typically the extant chunks stored in
the chunk manager, and the current chunk.

Depends on D69496

This is needed to embed a small buffer (e.g., containing one backtrace attached
to a marker) into a bigger buffer (e.g., the main profiler buffer).

Depends on D69498

Pushed by gsquelart@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/e207f1d1f211 Add BlocksRingBuffer::IsInSession() - r=canaltinova https://hg.mozilla.org/integration/autoland/rev/e4f1e52ecd5b ProfileChunkedBuffer basic data and functions - r=canaltinova https://hg.mozilla.org/integration/autoland/rev/3df5df7105cd ProfileChunkedBuffer ChunkManager handling - r=canaltinova https://hg.mozilla.org/integration/autoland/rev/c8e55e1a9e86 ProfileChunkedBuffer chunk request mechanism - r=canaltinova https://hg.mozilla.org/integration/autoland/rev/a1edf5289acd ProfileChunkedBuffer write functions - r=canaltinova https://hg.mozilla.org/integration/autoland/rev/7ab49e4c1621 ProfileChunkedBuffer detail::InChunkPointer - r=canaltinova https://hg.mozilla.org/integration/autoland/rev/f6a19e0ba1a9 ProfileChunkedBuffer read functions - r=canaltinova https://hg.mozilla.org/integration/autoland/rev/8243d7c3eeaf ProfileChunkedBuffer (de)serialization - r=canaltinova
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: