Repository navigation
Conversation
Mark hot Parser entry and scratch accessors #[inline] so cross-CGU callers in arrow inline them without requiring whole-program LTO. Derive Default and add in-place reset() and retained_memory_bytes() helpers on PromParserState and OpenMetricsParserState so ArrowDecoder can reuse parser scratch buffers in place across cooperative decode steps. Signed-off-by: Bartek Plotka <bwplotka@gmail.com>
Replace the per-entry ActiveParser enum wrapper with an internal ScrapeParser specialization trait so ingest_entries monomorphizes directly over PromParser and OpenMetricsParser without per-entry enum branching. Retain PromParserState and OpenMetricsParserState directly inside ArrowDecoder and store a 1-byte ParserKind tag in DecodeCursor, shrinking DecodeCursor from 344 bytes (with 5 owned Vecs) to 80 scalar bytes and avoiding dummy parser initialization and 272-byte enum moves on every cooperative step. Raise DECODE_BUDGET_DURATION_CHECK_INTERVAL from 16 to 64 entries, precompute the per-step byte limit, and skip Instant::now() when a step cannot reach the first periodic clock check. 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.
Follow-up to prometheus/scrape.rs#30 and prometheus/scrape.rs#27, motivated by cooperative decode profiling in open-telemetry/otel-arrow#4703.
Reduces per-entry and per-step overhead in
ArrowDecoderandDecodeStreamso cooperativeDecodeBudgetdecoding matches synchronous streaming throughput:ActiveParserenum wrapper with an internalScrapeParserspecialization trait and marks hot Layer 0 entry accessors#[inline]soingest_entriesmonomorphizes directly overPromParserandOpenMetricsParser.PromParserStateandOpenMetricsParserStateinsideArrowDecoderand stores a 1-byteParserKindtag inDecodeCursor, shrinkingDecodeCursorfrom 344 bytes to 80 scalar bytes and avoiding dummy parser initialization ininit_cursorand 272-byte enum moves on every step.DECODE_BUDGET_DURATION_CHECK_INTERVALfrom16to64entries, precomputes the per-step byte limit, and skipsInstant::now()when a step cannot reach the first periodic clock check.Commits in order:
0a5517aparse: inline entry accessors and add in-place parser state reset328e8f0arrow: monomorphize parser ingestion and shrink DecodeCursorBenchmarks (benchstat)
Measured with 6 interleaved rounds of
cargo bench --bench decode -- -bench '^BenchmarkDecode' -benchtime 1s -count 1 -cpu 2 -benchmem:before.txt:909063aafter.txt:328e8f0