Skip to content

perf(common): avoid redundant V1 archived timeline loads in incremental queries - #19553

Open
fhan688 wants to merge 1 commit into
apache:masterfrom
fhan688:avoid-redundant-V1-archived-timeline-loads-in-incremental-queries
Open

perf(common): avoid redundant V1 archived timeline loads in incremental queries#19553
fhan688 wants to merge 1 commit into
apache:masterfrom
fhan688:avoid-redundant-V1-archived-timeline-loads-in-incremental-queries

Conversation

@fhan688

@fhan688 fhan688 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Describe the issue this Pull Request addresses

This is a follow-up to #19338 and addresses the archived-timeline optimization suggested in #19338 (comment).

For timeline layout V1, CompletionTimeQueryViewV1 loaded archived instants to identify candidate requested times, after which IncrementalQueryAnalyzer discarded that timeline and loaded the archive again to construct QueryContext. Since V1 completion time is equivalent to requested time, the second scan is redundant.

Summary and Changelog

  • Add a dedicated V1 analysis path in IncrementalQueryAnalyzer.
  • Load the filtered archived timeline at most once when the requested range overlaps archived instants.
  • Apply InstantRange directly to HoodieInstant.requestedTime() and reuse the same archived timeline in QueryContext.
  • Avoid archive loading for active-only and snapshot ranges; for end-only ranges, check the filtered active timeline before loading the archive.
  • Keep the V2 completion-time query path unchanged.
  • Add tests covering single archive loading, timeline reuse, range boundaries, active-only and snapshot paths, limits, and V2 behavior.

Impact

Improves incremental-query performance for timeline layout V1 (table versions 5–7) by eliminating a redundant archived-timeline scan. There are no public API, configuration, storage-format, or V2 semantic changes. Query results and existing range semantics remain unchanged.

Risk Level

low

The change touches V1 incremental range selection but keeps V2 on the existing path. It is covered by TestIncrementalQueryAnalyzer and TestCompletionTimeQueryViewV1: 16 tests passed with no failures or errors. Reactor compilation, Checkstyle, RAT, and git diff --check also passed.

Documentation Update

none. This is an internal performance optimization with no new user-facing behavior or configuration.

Contributor's checklist

  • Read through contributor's guide
  • Enough context is provided in the sections above
  • Adequate tests were added if applicable

@github-actions github-actions Bot added the size:L PR with lines of changes in (300, 1000] label Aug 7, 2026
@codecov-commenter

codecov-commenter commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.84%. Comparing base (65cf7e8) to head (b322979).
⚠️ Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
...di/common/table/read/IncrementalQueryAnalyzer.java 96.00% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master   #19553   +/-   ##
=========================================
  Coverage     76.84%   76.84%           
- Complexity    32379    32391   +12     
=========================================
  Files          2522     2522           
  Lines        139106   139154   +48     
  Branches      16713    16720    +7     
=========================================
+ Hits         106892   106930   +38     
- Misses        24621    24631   +10     
  Partials       7593     7593           
Components Coverage Δ
hudi-common 83.27% <96.00%> (+<0.01%) ⬆️
hudi-client 81.97% <ø> (-0.02%) ⬇️
hudi-flink 84.69% <ø> (-0.02%) ⬇️
hudi-spark-datasource 70.59% <ø> (-0.01%) ⬇️
hudi-utilities 73.67% <ø> (+0.04%) ⬆️
hudi-cli 15.32% <ø> (ø)
hudi-hadoop 63.49% <ø> (-0.02%) ⬇️
hudi-sync 75.11% <ø> (ø)
hudi-io 79.46% <ø> (ø)
hudi-timeline-service 83.44% <ø> (ø)
hudi-cloud 64.06% <ø> (ø)
hudi-kafka-connect 53.20% <ø> (ø)
Flag Coverage Δ
common-and-other-modules 50.16% <92.00%> (+0.01%) ⬆️
flink-integration-tests 48.92% <42.66%> (-0.03%) ⬇️
hadoop-mr-java-client 43.70% <0.00%> (-0.03%) ⬇️
integration-tests 13.56% <0.00%> (-0.01%) ⬇️
spark-client-hadoop-common 49.59% <0.00%> (-0.04%) ⬇️
spark-java-tests 51.59% <90.66%> (+0.02%) ⬆️
spark-scala-tests 45.98% <25.33%> (+<0.01%) ⬆️
utilities 36.57% <41.33%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...di/common/table/read/IncrementalQueryAnalyzer.java 96.34% <96.00%> (-1.08%) ⬇️

... and 18 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hudi-agent hudi-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ 🤖 This review was generated by an AI agent and may contain mistakes. Please verify any suggestions before applying.

Thanks for the contribution! This PR splits IncrementalQueryAnalyzer.analyze into dedicated V1 and V2 paths so that V1 resolves incremental ranges by applying InstantRange directly to requestedTime and loads the filtered archived timeline at most once, avoiding the redundant second archive scan. I traced the new V1 branches against the V2 reference semantics in CompletionTimeQueryViewV2.getInstantTimes and the shared createQueryContext, and the behavior appears preserved. No correctness issues found. A few style/readability suggestions in the inline comments. Please take a look, and this should be ready for a Hudi committer or PMC member to take it from here. - a Hudi committer or PMC member can take it from here for a final review.
. A few naming and structural suggestions below, but overall the code is clean and well-organized.

cc @yihua

}

@Test
void testV1ActiveOnlyAndSnapshotRangesDoNotLoadArchive() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 nit: this test covers two distinct cases (active-only range and earliest-snapshot range) in one method, which makes it harder to pinpoint which scenario caused a failure. Could you split it into testV1ActiveOnlyRangeDoesNotLoadArchive and testV1EarliestSnapshotDoesNotLoadArchive?

⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.

@hudi-bot

hudi-bot commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands @hudi-bot supports the following commands:
  • @hudi-bot run azure re-run the last Azure build

@fhan688

fhan688 commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

this is the potential improvement mentioned in #19338, please help review, thanks! @danny0405

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L PR with lines of changes in (300, 1000]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants