)]}'
{
  "commit": "3a914a9ad18d8db13147595985dda70602b7328f",
  "tree": "45fa5f21be970281fd6598fb132b54701a619b8e",
  "parents": [
    "a995d36a1e4a208300fae7e1b4eba44465dd0e98"
  ],
  "author": {
    "name": "S Ashwin Balaji",
    "email": "sashwinbalaji@google.com",
    "time": "Tue Aug 18 02:36:25 2026 +0100"
  },
  "committer": {
    "name": "S Ashwin Balaji",
    "email": "sashwinbalaji@google.com",
    "time": "Tue Sep 01 16:49:56 2026 +0100"
  },
  "message": "tracing: add the v2 shared-ring chunk protocol\n\nAdd the producer-local shared ring used by tracing v2. This change contains\nthe shared-memory ABI, one writer per TraceWriter, the single reader, and the\nprotocol tests. SDK and service wiring follow in separate changes.\n\n- Define a 64-byte ring header:\n  - an always-lock-free atomic64 packs write_pos in the high half and read_pos\n    in the low half;\n  - num_writers_waiting avoids a wake syscall when no writer is asleep;\n  - a zero-filled mapping is a valid empty ring.\n\n- Define one atomic32 state word at the start of each chunk:\n  - Free(wrap) exposes the chunk to one ring traversal;\n  - BeingWritten identifies the writer and its published fragment prefix;\n  - Complete says the writer has finished touching the chunk, although it may\n    take the chunk back to append more fragments;\n  - RewriteRequested says the reader took the published prefix and the writer\n    must move any newer suffix;\n  - RewriteAcknowledged says the writer released the old chunk and the reader\n    may return it to Free.\n\n- Reserve uint32 positions in FIFO order and map them onto a power-of-two\n  number of physical chunks. Free carries a 16-bit wrap count so a delayed\n  writer cannot claim the same chunk during a later traversal.\n\n- Keep ownership rules local to the chunk word:\n  - one reservation permits one exact claim attempt;\n  - only the reader writes Free;\n  - the reader never waits for a writer;\n  - a lost reader CAS leaves read_pos unchanged and retries the position in a\n    later drain.\n\n- Store target BufferID after the state word. Payload fragments grow towards\n  higher addresses while their sizes grow down from the end of the chunk as\n  shortest-form protobuf varints. Fragment counts publish an append-only\n  prefix. If the reader reaches an active writer, it copies that prefix and\n  asks the writer to move only the unpublished suffix.\n\n- Keep the initial 256-byte minimum chunk size and require a four-byte-aligned\n  chunk stride. Check ring geometry and allocation arithmetic before mapping\n  memory. Require atomic32 and atomic64 to be always lock-free.\n\n- Honor BufferExhaustedPolicy in SharedRingBufferWriter. Linux and Android\n  writers can wait on the read_pos half of rw_positions with a futex. Other\n  platforms report that blocking is unavailable instead of spinning. The\n  waiter hint and its seq_cst fence pair prevent a missed wake across the two\n  atomic words.\n\n- Test ABI encoding, position and wrap rollover, malformed chunk input, every\n  state transition, failed claims, prefix copying, suffix relocation, futex\n  wake races, and concurrent multi-writer stress.\n\nBug: 536851377\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "f072867b3c57f18c42ab1faaf62cffdad52ddb57",
      "old_mode": 33188,
      "old_path": "Android.bp",
      "new_id": "56e203aae9892c9dc054f43da2ddaf66ebd9bd92",
      "new_mode": 33188,
      "new_path": "Android.bp"
    },
    {
      "type": "modify",
      "old_id": "e349a85e663b0be40af7167f8e6611b468439950",
      "old_mode": 33188,
      "old_path": "gn/perfetto_unittests.gni",
      "new_id": "de56e67a87e3523578830f8edf954961225ad71d",
      "new_mode": 33188,
      "new_path": "gn/perfetto_unittests.gni"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "de2894d6541fdbb81d4c8bdc2ca3cc42819ecf29",
      "new_mode": 33188,
      "new_path": "src/tracing/v2/BUILD.gn"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "535962b0358a2f6b529be3f5592ba2cfb8ca8792",
      "new_mode": 33188,
      "new_path": "src/tracing/v2/shared_ring_buffer.cc"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "875e73052582fc2228ee39d970aa6a7cf9990c4a",
      "new_mode": 33188,
      "new_path": "src/tracing/v2/shared_ring_buffer.h"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "8fe6616ed4d081b3bad787ecc60f193f907e4d1f",
      "new_mode": 33188,
      "new_path": "src/tracing/v2/shared_ring_buffer_concurrency_unittest.cc"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "947a5e767fdf567ea64b4583ed0de17a9f9aba16",
      "new_mode": 33188,
      "new_path": "src/tracing/v2/shared_ring_buffer_reader.cc"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "a3d92ba7485965af7e3e26caeb68bc9590265086",
      "new_mode": 33188,
      "new_path": "src/tracing/v2/shared_ring_buffer_reader.h"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "2d059ca69e5cc58054a4c57b141706b4406bf2ce",
      "new_mode": 33188,
      "new_path": "src/tracing/v2/shared_ring_buffer_reader_unittest.cc"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "6c07be9c26c529684db012c8e709ec9970b80b07",
      "new_mode": 33188,
      "new_path": "src/tracing/v2/shared_ring_buffer_unittest.cc"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "7c29d455604f11836bd2c70404f14ee2c197c364",
      "new_mode": 33188,
      "new_path": "src/tracing/v2/shared_ring_buffer_writer.cc"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "6fe47421fabf45bb84fa0a15d27ce911eb03fd2a",
      "new_mode": 33188,
      "new_path": "src/tracing/v2/shared_ring_buffer_writer.h"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "9032ce2e295fe25b9327f98d9ef84e01237e7835",
      "new_mode": 33188,
      "new_path": "src/tracing/v2/shared_ring_buffer_writer_unittest.cc"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "48a6a5bec7454ae05d3764179b93dae4145cfd51",
      "new_mode": 33188,
      "new_path": "src/tracing/v2/tracing_v2_abi.h"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "e82feb82e480c631fee67828bbaef223cab825f5",
      "new_mode": 33188,
      "new_path": "src/tracing/v2/tracing_v2_abi_unittest.cc"
    }
  ]
}
