perf(scan): reuse index planning resources across queries - #267
Open
wangyong9999 wants to merge 4 commits into
Open
perf(scan): reuse index planning resources across queries#267wangyong9999 wants to merge 4 commits into
wangyong9999 wants to merge 4 commits into
Conversation
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.
Purpose
Linked issue: N/A
Repeated scans in the same process rebuilt several immutable planning resources:
DataEvolutionBatchScanloaded the schema and rebuiltCoreOptionsafterTableScanhad already initialized them. This also dropped the cache supplied throughScanContext.CacheManager; closing a reader invalidated its pages, and the next reader opened the index file before checking the cache.This change reuses the
TableSchema,CoreOptions, filesystem, executor, memory pool, and cache already owned by the scan when planning a DataEvolution global-index query.It adds a whole-table snapshot live manifest cache entry, separate from bucket-specific entries. The cache stores live entries before query filtering and applies the current predicate after a cache hit.
It shares a bounded BTree
CacheManagerbetween indexers with the same cache configuration, retains immutable pages after reader destruction, and opens the input stream only on a cache miss. Retained pages use the process default memory pool so they do not outlive a caller-owned pool.The manifest cache remains disabled for row-range scans. Cache read, deserialization, serialization, or write failures fall back to rebuilding the manifest entries. Cache-manager creation is serialized; the existing LRU remains thread-safe and bounded by
btree-index.cache-sizefor each distinct cache configuration. The existing eagerBlockCacheconstructor andClose()behavior are unchanged.On an HDFS primary-key table with 606K rows, 51 active data files, and 6.5 GB of data, a
logidlookup returning two rows was executed twice in one process. The cold plan/read/total time was 851/163/1015 ms. The second plan/read/total time was 115/99/214 ms. BTree evaluation decreased from 621 ms to 0.55 ms. Both runs selected one indexed split, one data file, and a two-row range, and matched the result of an index-disabled scan.Tests
core_test,common_test, andsst_format_testAppendOnlyFileStoreScanTest.TestSnapshotLiveManifestCache*(4 cases)LruCacheTest.TestForSnapshotLiveManifestEntriesBlockCacheTest.*(7 cases)LazyFilteredBTreeReaderTest.*(33 cases)*BTree*(144 passed; 7 existing compatibility-data cases skipped by their fixture guard)*GlobalIndexTest.TestDataEvolutionBatchScan*(32 cases covering partition/index combinations, external paths, bitmap, and range bitmap)validation status=PASS,path_proof status=PASS path=pk-file-local-btreegit diff --checkThe local environment does not provide CMake or pre-commit executables, so the CMake and pre-commit checks are left to CI.
API and Format
Adds an overload of
CacheKey::ForSnapshotLiveManifestEntriesfor a whole-table cache key. This is an additive API change. There is no object-layout, storage-format, or protocol change.Documentation
No new user-facing feature or option.
Generative AI tooling
Generated-by: Codex (GPT-5)