Fix duration metric accuracy: RDD timing, codegen try/finally, per-partition write timing#63
Merged
Fix duration metric accuracy: RDD timing, codegen try/finally, per-partition write timing#63
Conversation
…upport for duration Writing duration now really gives per partition duration and not just wall time
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
Custom RDD instead of mapPartitions for duration timing —
DataFlintRDDUtilsnow uses a custom RDD that capturesstartTimeinsidecompute()beforefirstParent.iterator(). Previously,mapPartitionssetstartTimeafter the parent RDD's compute, missing eager work in operators like SortExec (full partition sort) and HashAggregateExec (hash map build).Per-partition write duration —
TimedExec.executeCollectnow reconstructs DataWritingCommandExec with the data plan wrapped inRDDTimingWrapperinside WriteFilesExec (Spark 3.4+) or directly (older Spark). The write command consumes the timed RDD viasparkContext.runJob, so wall-clock-per-partition timing captures both data production and write I/O. Previously, write duration was measured as driver-side wall-clock time, inconsistent with other per-partition metrics.Codegen try/finally for blocking operators —
doProducenow wraps the child code withtry/finallyso the duration metric flushes even when blocking operators (SortExec, etc.) exit early viashouldStop()/return. Previously, duration was 0 for these operators in codegen because the timing code after the child code was never reached.Sanitize codegen variable prefix — Nodes with spaces in
nodeName(e.g. RDDScanExec's "Scan ExistingRDD", DataWritingCommandExec's "Execute InsertIntoHadoopFsRelationCommand") caused invalid Java identifiers in generated code.doProducenow sanitizesctx.freshNamePrefixto strip non-alphanumeric characters.Add RDDScanExec to instrumented nodes — "Scan ExistingRDD" nodes now get duration metrics in both Spark 3 and Spark 4.
Test plan