Skip MultiScan cache lookup when block cache is disabled#14785
Closed
xingbowang wants to merge 1 commit into
Closed
Skip MultiScan cache lookup when block cache is disabled#14785xingbowang wants to merge 1 commit into
xingbowang wants to merge 1 commit into
Conversation
✅ clang-tidy: No findings on changed linesCompleted in 266.9s. |
Tables configured without a block cache cannot produce cache hits during MultiScan Prepare, so probing the cache for every candidate block only adds CPU overhead. Teach IODispatcher to detect the missing block cache once and send every requested block directly to the read path. Keep LookupAndPinBlocksInCache safe for no-cache configurations by returning OK when no block cache is installed. Existing cache-enabled behavior is unchanged: the dispatcher still looks up each block, pins hits, and reads only misses, including when ReadOptions::fill_cache is false. Tests: built io_dispatcher_test; ran timeout 60 ./io_dispatcher_test --gtest_filter=IODispatcherTest.LookupAndPinBlocksInCacheNoOpsWithoutBlockCache:IODispatcherTest.SubmitJobWithoutBlockCacheSkipsCacheLookup:IODispatcherTest.FillCacheFalseStillLooksUpExistingCacheEntries; ran git diff --check.
ed91273 to
5ab3614
Compare
🟡 Codex Code ReviewAuto-triggered after CI passed — reviewing commit 5ab3614 ❌ Codex review failed before producing findings. ℹ️ About this responseGenerated by Codex CLI. Limitations:
Commands:
|
✅ Claude Code ReviewAuto-triggered after CI passed — reviewing commit 5ab3614 SummaryClean, low-risk PR that fixes a real bug (assertion failure when IODispatcher is used with High-severity findings (0): No high-severity findings. Full review (click to expand)Findings🔴 HIGHNone. 🟡 MEDIUMM1.
|
| Context | Executes? | Assumptions hold? | Action needed? |
|---|---|---|---|
| WritePreparedTxnDB | YES (via iterator) | YES -- cache config is orthogonal to txn visibility | Safe |
| ReadOnly DB | YES | YES -- common no-cache scenario | Enabled by this PR |
| CompactionService | YES | YES -- remote workers often use no_block_cache | Enabled by this PR |
| User-defined timestamps | YES | YES -- orthogonal | Safe |
| FIFO / Universal compaction | YES | YES -- compaction style doesn't affect cache config | Safe |
| Prefix seek | YES | YES -- orthogonal | Safe |
| BlockCacheLookupForReadAheadSize | NO when no cache | N/A -- guarded by block_cache.get() check at iterator.cc:74 |
Safe |
Assumption stress test results:
- "Returning OK with null is safe for all callers" -- VERIFIED. Both callers (
SubmitJobandBlockCacheLookupForReadAheadSize) correctly handle OK-with-null as cache miss.BlockCacheLookupForReadAheadSizeis additionally never called when no cache. - "Checking block_cache once is sufficient" -- VERIFIED.
rep_->table_optionsis immutable after table construction. - "Dictionary skip is safe" -- VERIFIED. Dictionary is only needed for
block_cache.LookupFull()decompression context. No cache means no LookupFull. NormalRetrieveBlockhandles its own decompression.
Positive Observations
- Correct pattern usage: Follows the established
if (!block_cache)guard pattern used throughout RocksDB (MaybeReadBlockAndLoadToCache,EraseFromCache,TEST_BlockInCache). - Good test design: Three well-structured tests covering: (1) direct API behavior, (2) SubmitJob integration with sync point verification that cache is NOT consulted, (3) regression guard ensuring
fill_cache=falsestill does lookups when cache exists. - Sensible optimization: Eliminates N cache key generations + N dictionary lookups + N cache probes that would all return null anyway.
- Enables real use cases: CompactionService remote workers, embedded systems, and streaming workloads frequently use
no_block_cache=true. - Appropriate use of
TEST_SYNC_POINT: Allows precise verification that the function is entered (or not) without introducing flakiness.
ℹ️ 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
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
BlockBasedTable::LookupAndPinBlocksInCachewhen a table has no block cache installed.IODispatcherto detect the missing block cache once and send all requested blocks directly to the read path instead of probing for impossible cache hits.SubmitJobskips cache lookups.Test Plan
CI