perf(rest): lazy-decode snapshots in commitTableResponse when snapshot-loading-mode=refs - #1956
Draft
technicolorbeat wants to merge 1 commit into
Draft
Conversation
…t-loading-mode=refs Add lazy snapshot decoding to REST catalog's commit responses. When snapshot-loading-mode=refs is configured, store full snapshots as raw JSON and keep only the current snapshot in memory. Remaining snapshots are decoded on first access via sync.Once for thread-safety. This optimization reduces AddFiles latency by 50-100ms for tables with long snapshot histories by deferring snapshot unmarshaling until needed. Changes: - table/metadata.go: Add lazy snapshot fields and ensure/decode methods - catalog/rest/rest.go: Apply lazy decode after commit response unmarshal - table/lazy_snapshots_test.go: Comprehensive test coverage Fixes apache#1946 Signed-off-by: Roli Bhardwaj <specklegrey12@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.
Summary
Defer snapshot decoding in commit responses when
snapshot-loading-mode=refsis set. Reduces AddFiles latency by 50-100ms for tables with 1000+ snapshots by deferring decode until needed.Problem
REST commit responses eagerly decode all snapshots even though most callers only need the current snapshot. For tables with 1000+ snapshots, this costs ~100ms in JSON unmarshaling per commit.
Solution
Store full snapshots as raw JSON, keep only current snapshot in memory. Decode remaining snapshots on first access via
sync.Once(thread-safe).Opt-in via
snapshot-loading-mode=refs. Default behavior unchanged.How It Works
Changes
Testing
✓ All table tests pass
✓ All REST tests pass
✓ New lazy snapshot tests (4 tests)
✓ Lint checks pass
Performance
Related