Repository navigation
Perf/simple dofn runner - #41539
Open
reuvenlax wants to merge 4 commits into
Open
Perf/simple dofn runner#41539reuvenlax wants to merge 4 commits into
reuvenlax wants to merge 4 commits into
Conversation
Contributor
|
Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment |
reuvenlax
force-pushed
the
perf/simple-dofn-runner
branch
from
November 24, 2026 06:04
4322d71 to
e904cdf
Compare
…ivers / FnApiDoFnRunner - WindowedValues: add ofWithCurrentContext(...) and builder(template, value) helpers, omit redundant OpenTelemetry Context.root() references, and add SingleWindowedValue fast paths in FullWindowedValueCoder encode/decode/registerByteSizeObserver. - OutputBuilderSupplier / OutputBuilderSuppliers / DoFnOutputReceivers: add direct build(value) and buildWithTimestamp(value, ts) methods avoiding intermediate Builder and lambda allocations on every emitted element. - FnApiDoFnRunner: use WindowedValues.ofWithCurrentContext(...) and builder(elem, val) in output receivers. - Add unit tests in WindowedValueTest and JMH benchmarks in OutputReceiverBenchmark.
reuvenlax
force-pushed
the
perf/simple-dofn-runner
branch
from
November 28, 2026 05:03
e904cdf to
1772c58
Compare
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.
Summary
Eliminates per-element allocations and redundant OpenTelemetry / builder / receiver overhead across
SimpleDoFnRunner,WindowedValues,DoFnOutputReceivers, andFnApiDoFnRunner.Key Changes
SimpleDoFnRunner(runners/core-java):DoFnProcessContextand cachedDirectOutputReceiver/CachedMultiOutputReceiverinstances across@ProcessElementinvocations (failing fast withIllegalStateExceptionon post-return access or invalid reentrant calls).Instanton every timestamp check via primitivelongfast-path arithmetic incheckTimestamp.cachedMainTag,cachedSingleExtraTag) plus a lazyHashMapinCachedMultiOutputReceiverso even deserializedTupleTaginstances (e.g. Dataflow) resolve in O(1) with zero allocation.ScopeOpenTelemetryContextStorage.get().current()fast path inprocessElement, and preserves empty-window elements (ValueInEmptyWindows) without extra validation overhead.WindowedValues/IterableLikeCoder/DoFnOutputReceivers/OutputBuilderSupplier(s)(sdks/java/core):WindowedValues.ofWithCurrentContext(...)andWindowedValues.builder(template, value)fast paths, omitting redundantContext.root()references.OutputBuilderSupplier.build(...)/buildWithTimestamp(...)/buildWindowedValue(...)methods to avoid intermediateWindowedValues.Builderand lambda allocations inDoFnOutputReceivers.FullWindowedValueCoder(encode,decode,registerByteSizeObserver) delegating wire-format header handling toIterableLikeCoder.readSizeHeader/decodeAfterSizeHeader/encodeSingleElement.FnApiDoFnRunner(sdks/java/harness):WindowedValues.ofWithCurrentContext(...)and direct output-receiver fast paths.SimpleDoFnRunnerTest,WindowedValueTest,DoFnOutputReceiversTest,OutputBuilderSuppliersTest,CollectionCoderTest, andFnApiDoFnRunnerTest, plusOutputReceiverBenchmark/OutputReceiverBenchmarkTest.Benchmark Results (JDK 21, 2 forks,
-prof gc, lower is better)SimpleDoFnRunner(processElementend-to-end)processElement_multiOutput2TagsDeserialized(2 outputs, distinct tag refs)processElement_outputReceiver(@Element,OutputReceiver)processElement_outputWithTimestampprocessElement_multiOutput4Tags(4 outputs)processElement_observesWindow(FixedWindows)processElement_processContextOutput(ProcessContext.output)OutputReceiverBenchmark(sdks/java/core:jmh)windowedReceiverOutputUntaggedwindowedReceiverOutputTaggedwindowedReceiverPerElementConstructionwindowedReceiverOutputViaBuilderrowReceiverOutputrowReceiverOutputWithTimestampwindowedReceiverOutputWindowedValuefullWindowedValueCoderDecodeShows strong results in localized benchmarks - e.g. Nexmark Q5 is 7.5% faster on DirectRunner. Combined with its sibling PRs, we see 25% savings on many real e2e Dataflow pipelines.
Note: if a user tries to hold onto a ProcessContext between elements (e.g. buffer in the DoFn), this will now break. This was always abroken/undefined usage however.