Replace LayoutStrategy buffered_bytes with a buffered bytes tracker - #8961
Conversation
9e130fe to
df39dc2
Compare
df39dc2 to
45a4306
Compare
Signed-off-by: Robert Kruszewski <github@robertk.io>
Signed-off-by: Robert Kruszewski <github@robertk.io>
Onur noted that constructing the writer's ArrayContext in `write_options` froze the allowed encodings earlier than before, so an encoding registered between `write_options()` and `write()` would be rejected. Split the buffered-bytes counter out of `LayoutWriterContext` into a shareable `BufferedBytesTracker`: the tracker is created with the options (so callers can observe it before the write starts), while the `ArrayContext` is built back in `write_internal`, restoring the previous snapshot point. Also make buffered-bytes reporting a public API so out-of-tree layouts can participate: `BufferedBytesTracker::reserve` hands out an RAII `BufferedBytesReservation` that releases on drop, reachable from a strategy via `LayoutWriterContext::reserve_buffered_bytes`. Signed-off-by: "Robert Kruszewski" <robert@spiraldb.com>
Signed-off-by: Robert Kruszewski <github@robertk.io>
I, Robert Kruszewski <github@robertk.io>, hereby add my Signed-off-by to this commit: 45a4306 Signed-off-by: Robert Kruszewski <github@robertk.io>
67fe739 to
431ff9f
Compare
I, Robert Kruszewski <github@robertk.io>, hereby add my Signed-off-by to this commit: 8311a80 Signed-off-by: Robert Kruszewski <github@robertk.io>
Merging this PR will degrade performance by 10.99%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | fsl_large |
88 µs | 98.8 µs | -10.99% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing rk/notodobytes (aa8fd1c) with develop (81c36da)
Footnotes
-
12 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
For file writing it's very useful to know how much data is already piped through
the writer. We have a CountingWriter but that can only measure flushed bytes. We
want to measure the bytes that the writer holds buferred.
Instead of recursive buffered_bytes which has numerous problems with stateless
strategies and double counting we add a bufferedbytestracker to the
layoutwritercontext and let writers report buffered bytes there