Repository navigation
Conversation
Add cooperative incremental decoding to ArrowDecoder and DecodeStream so multi-megabyte scrapes can yield between bounded steps on single-threaded !Send LocalSet runtimes without starving timers or peer tasks:
- Add DecodeBudget (defaulting to 128 entries, 64 KiB, and 1ms duration, checking Instant::elapsed every 16 entries) and DecodeStep::{Pending, Batch, Done}.
- Add DecodeStream::step(budget) and DecodeStream::pos() to pause and resume chunked decoding at Layer 0 Entry boundaries.
- Add lifetime-free DecodeCursor (ArrowDecoder::start_decode, start_decode_stream, step_decode, finish_decode) so owned PdataDecodeJob structs can hold an owned byte buffer and ArrowDecoder across suspension points under #![forbid(unsafe_code)].
- Add runtime-agnostic async helpers ArrowDecoder::decode_cooperative (with a single-pass synchronous fast path when input.len() <= budget.max_bytes) and DecodeStream::next_cooperative.
- Add LocalSet timer scheduling lateness and dhat bounded-memory tests in tests/otap-compat and criterion benchmarks in benches/decode.rs.
Closes #27
Signed-off-by: Bartek Plotka <bwplotka@gmail.com>
bwplotka
force-pushed
the
bwplotka/phase4-cooperative-decoding
branch
from
November 5, 2026 04:40
b8644c2 to
0ece0e0
Compare
bwplotka
marked this pull request as ready for review
November 5, 2026 05:10
Signed-off-by: Bartek Plotka <bwplotka@gmail.com>
…empotent Signed-off-by: Bartek Plotka <bwplotka@gmail.com>
Signed-off-by: Bartek Plotka <bwplotka@gmail.com>
Signed-off-by: Bartek Plotka <bwplotka@gmail.com>
…calls Signed-off-by: Bartek Plotka <bwplotka@gmail.com>
Signed-off-by: Bartek Plotka <bwplotka@gmail.com>
…, and cancellation Signed-off-by: Bartek Plotka <bwplotka@gmail.com>
Signed-off-by: Bartek Plotka <bwplotka@gmail.com>
Signed-off-by: Bartek Plotka <bwplotka@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on prometheus/scrape.rs#29 and prometheus/scrape.rs#19, part 2 of 2 for prometheus/scrape.rs#27.
Applies the
benchfmt.rsand rawbenchstatreporting rules from prometheus/scrape.rs#32.Closes prometheus/scrape.rs#27.
Adds cooperative incremental decoding to
ArrowDecoderandDecodeStreamso multi-megabyte scrapes can yield between bounded steps on single-threaded!SendLocalSetruntimes without starving timers or peer tasks:DecodeBudget, defaulting to 128 entries, 64 KiB, and 1ms duration while checkingInstant::elapsedevery 16 entries, along withDecodeStep::{Pending, Batch, Done}.DecodeStream::step(budget)andDecodeStream::pos()to pause and resume chunked decoding at Layer 0Entryboundaries.DecodeCursorviaArrowDecoder::start_decode,start_decode_stream,step_decode, andfinish_decodeso ownedPdataDecodeJobstructs can hold an owned byte buffer andArrowDecoderacross suspension points under#![forbid(unsafe_code)].asynchelpersArrowDecoder::decode_cooperative, with a single-pass synchronous fast path wheninput.len() <= budget.max_bytes, andDecodeStream::next_cooperative.LocalSettimer scheduling lateness anddhatbounded-memory tests intests/otap-compatandbenchfmt.rsbenchmarks inbenches/decode.rs.Commits in order:
0ece0e0arrow: add cooperative incremental decoding and DecodeBudgetbf4b638arrow: avoid private intra-doc links in public rustdoc commentsf134292arrow: make finish_decode and ActiveParserState::take_scratch_into idempotent8807b39arrow: implement Debug for DecodeCursore6b3b82arrow: reclaim parser scratch if decode_cooperative is dropped at yieldf53feddarrow: validate cursor scrape_id and input length across step_decode calls6cd52c3arrow: return DecodeStep::Done on empty scrapes in single-batch mode1a8beb0arrow: expand unit tests for cooperative error paths, duration budget, and cancellationbc4e9b2tests: exercise DecodeStream::next_cooperative in dhat_bounded_mem6aff3e6bench: migrate benches/decode.rs to benchfmt.rsbenches/decode.rsbenchstatcomparison betweenbefore.txtatef2ce5candafter.txtat6aff3e6:benches/decode.rsbenchstat -col /modecomparison on6aff3e6:Heap bytes and allocation counts on
decode,stream_16k, andstream_256are unchanged fromef2ce5c, anddecode_cooperativeandstream_256_cooperativematch their synchronousdecodeandstream_256counterparts in bothB/opandallocs/opwhile adding+1.73%to+2.91%wall-time overhead from budget checks andActiveParserStatestashing across yields.