Skip to content

HDDS-16281. Reduce per-key overhead in Recon reprocess tasks - #11123

Open
rich7420 wants to merge 8 commits into
apache:masterfrom
rich7420:HDDS-16281
Open

rich7420 wants to merge 8 commits into
apache:masterfrom
rich7420:HDDS-16281

Conversation

@rich7420

@rich7420 rich7420 commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

OBS namespace summary reprocess caches the last bucket's metadata per worker and reuses its object ID, avoiding repeated bucket-table reads for consecutive keys. The cache checks both volume and bucket names and retains at most one bucket per worker.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-16281

How was this patch tested?

With JDK 21:

  • Clean build: mvn -pl :ozone-recon -am clean install -DskipTests -DskipShade -DskipRecon -DskipDocs.
  • mvn -pl :ozone-recon test '-Dtest=TestNSSummaryTaskWithOBS*,TestNSSummaryTaskWithFSO*,TestNSSummaryTaskWithLegacy*,TestContainerKeyMapperTask,TestFileSizeCountTask' -DskipShade -DskipRecon -DskipDocs -Ddevelocity.cache.local.enabled=false -Ddevelocity.cache.remote.enabled=false: 82 tests run, 0 failures, 0 errors, 0 skipped.
  • The bucket lookup regression fails with upstream OBS code and passes with this change.
  • ./hadoop-ozone/dev-support/checks/checkstyle.sh: 0 violations.

CI:

Copilot AI lite review requested due to automatic review settings August 26, 2026 13:58

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chihsuan chihsuan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for working on this! @rich7420 the improvement looks promising. 👍

Would it make sense to add a multi-worker test with a low flush threshold to verify that repeated map replacements do not lose or duplicate data?

Optionally, I think it would be useful to benchmark a high number of buckets to measure peak memory usage, since each worker caches every bucket it encounters until reprocessing finishes.

getReconNamespaceSummaryManager().clearNSSummaryTable();

assertThat(task.reprocessWithOBS(omMetadataManager)).isTrue();
verify(bucketTable, times(2)).getSkipCache(anyString());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would it be possible to make the bucket/key setup local to this test? The hard-coded times(2) currently depends on the shared fixture containing exactly two buckets, so an unrelated fixture change could break this test.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Now captures the getSkipCache args and asserts doesNotHaveDuplicates() (each bucket fetched at most once), so it no longer depends on the bucket count. Also moved into a @Nested class.

@rich7420
rich7420 marked this pull request as draft September 4, 2026 06:23
…allback cleanup

- Add testReprocessLowThresholdConservesData: with a flush threshold of 1,
  reprocess still yields the exact per-bucket file counts and sizes, so the
  repeated per-worker map replacement, async flush and end-of-loop drain neither
  lose nor double-count keys.
- Replace the times(2) bucket-cache assertion, which depended on the fixture
  holding exactly two buckets, with an ArgumentCaptor + doesNotHaveDuplicates
  check that each bucket is looked up at most once, independent of bucket count.
- Group both in a @nested class so they are discovered and reported clearly
  under a class-level run.
- Document why the per-worker ThreadLocals are cleared in a finally: the
  small-table fallback in ParallelTableIteratorOperation runs the per-key
  operation on the reused Recon pool thread, so the finally is not dead code.

Claude-Session: https://claude.ai/code/session_01FUpCUnmy6JzHPGvwMhyGzq
@rich7420
rich7420 marked this pull request as ready for review September 4, 2026 08:36
@github-actions github-actions Bot added the recon label Sep 23, 2026
@rich7420
rich7420 marked this pull request as draft October 17, 2026 12:09
@rich7420
rich7420 marked this pull request as ready for review October 17, 2026 13:03
@adoroszlai

Copy link
Copy Markdown
Contributor

Thanks for the patch. I would like to defer this after #11754, which cuts the ozone-integration-test -> ozone-recon dependency, (hopefully) allowing CI runs for Recon-only changes like this to get Surefire test results for ozone-integration-test from the Develocity build cache.

@rich7420

Copy link
Copy Markdown
Contributor Author

@adoroszlai ok problem. thanks!

@chihsuan chihsuan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for addressing my earlier comments! @rich7420 The new tests look good.

Sorry, I should have checked this last time. I tested each change on its own. The bucket cache makes reprocess faster, from about 2100ms to 1800ms. The ThreadLocal change doesn't make it faster, and it adds a second map we need to keep in sync.

Since only the bucket cache makes it faster, could we remove the ThreadLocal change from this PR?

@adoroszlai
adoroszlai marked this pull request as draft October 27, 2026 11:50
@adoroszlai
adoroszlai requested a review from chihsuan October 27, 2026 15:09
@rich7420
rich7420 marked this pull request as ready for review October 27, 2026 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants