Add iterator key/value pinning APIs#14761
Conversation
Differential Revision: https://phabricator.intern.facebook.com/D102198463
|
| Check | Count |
|---|---|
performance-noexcept-move-constructor |
1 |
| Total | 1 |
Details
util/slice.cc (1 warning(s))
util/slice.cc:325:16: warning: move constructors should be marked noexcept [performance-noexcept-move-constructor]
🟡 Codex Code ReviewAuto-triggered after CI passed — reviewing commit f115033 ❌ Codex review failed before producing findings. ℹ️ About this responseGenerated by Codex CLI. Limitations:
Commands:
|
✅ Claude Code ReviewAuto-triggered after CI passed — reviewing commit f115033 SummaryWell-structured PR that adds iterator key/value pinning APIs with correct cache reference counting, proper fallback-to-copy semantics, and good test coverage for the supported use cases. The PinnableSlice move constructor fix is necessary and correct. The main gaps are in missing test coverage for some edge cases and a potential issue with High-severity findings (0): No high-severity findings. Full review (click to expand)Findings🟡 MEDIUMM1.
|
| Context | Executes? | Safe? | Notes |
|---|---|---|---|
| WritePreparedTxnDB | YES | YES | PinCurrent only reads already-validated position |
| ReadOnly DB | YES | YES | Same iterator stack |
| User-defined timestamps | Rejected | N/A | timestamp_size_ != 0 check |
| BlobDB | Rejected | N/A | ikey_.type != kTypeValue check |
| Wide-column entities | Rejected | N/A | Type check rejects |
| Merge results | Rejected | N/A | current_entry_is_merged_ check |
| Memory-mapped files | Fallback to copy | YES | No cache handle -> copies |
| Prefix seek | YES | YES | No prefix-specific behavior |
Cache::Ref() correctness: Cache::Ref() correctly bumps reference count independently of pinned_iters_mgr_. The cleanup callback calls Cache::Release(). This is the same pattern as PinnableSlice in Get(). No double-release risk.
Transaction visibility: PrepareForPinCurrent() only succeeds on already-visible keys (DBIter has applied read_callback_ checks). No bypass possible.
Positive Observations
- Clean layering of internal
PinnedIterKeyValuevs publicPinnableKeyValue - Correct fallback to copy when pinning unavailable
- Clever same-block deduplication via cache handle pointer identity
- Comprehensive test coverage across all rejection cases
- Necessary and correct PinnableSlice move constructor fix
ℹ️ About this response
Generated by Claude Code.
Review methodology: claude_md/code_review.md
Limitations:
- Claude may miss context from files not in the diff
- Large PRs may be truncated
- Always apply human judgment to AI suggestions
Commands:
/claude-review [context]— Request a code review/claude-query <question>— Ask about the PR or codebase
Summary
PinnableKeyValue,PinnableKeyValueBatch,Iterator::PinCurrent(), andIterator::AppendPinnedCurrent()so callers can keep the current key/value valid after iterator movement.PinCurrentKeyValue()hook through DB, forward, merging, level, and wrapper iterators to block-based table iterators.kTypeValuerows only; reverse iteration, merge results, timestamps, blobs, wide-column entities, timed puts, and other value types returnNotSupported.PinnableSlicemove construction so moved pinned slices can be reset and reused safely.Test Plan
git diff --check upstream/main...kv_pinningtimeout 60s ./db_test2 --gtest_filter='DBTest2.IteratorPinCurrentDeltaEncodedKeyAndPinnedValue:DBTest2.IteratorPinAPIsPinNonDeltaEncodedKeyAndValue:DBTest2.IteratorPinCurrentFallsBackToCopyWithoutBlockCache:DBTest2.IteratorAppendPinnedCurrentDedupesSameBlockLease:DBTest2.IteratorAppendPinnedCurrentTracksDistinctBlockUsage:DBTest2.IteratorAppendPinnedCurrentFallsBackToCopyWithoutBlockCache:DBTest2.IteratorPinCurrentClearsOutputOnReverseIterationNotSupported:DBTest2.IteratorPinAPIsHandleReverseIterationSafely:DBTest2.IteratorAppendPinnedCurrentResetReleasesAndReusesBatch:DBTest2.IteratorPinAPIsRejectNullOutputPointers:DBTest2.IteratorPinAPIsRejectBlobRowsAfterPrepareValue:DBTest2.IteratorPinAPIsRejectWideColumnEntityRows:DBTest2.IteratorPinAPIsRejectUserDefinedTimestampRows'timeout 60s ./db_iter_test --gtest_filter='DBIteratorTest.DBIteratorPinAPIsRejectTimedPutRows'timeout 60s ./slice_test --gtest_filter='PinnableSliceTest.Move'