[seekdb][memtable] Replace global Iterator pool with session-level cache#915
Open
hnwyllmm wants to merge 1 commit into
Open
[seekdb][memtable] Replace global Iterator pool with session-level cache#915hnwyllmm wants to merge 1 commit into
hnwyllmm wants to merge 1 commit into
Conversation
… cache The global ObFixedClassAllocator pool for memtable btree iterators was pinned to tenant 500 and never released memory. This change introduces a per-session free list (ObBtreeIterCache) so iterator memory is properly attributed to the business tenant and released when sessions disconnect achieving full memory reclaim at idle. Frontend SQL scans use the session cache via THIS_WORKER.get_session; backend merge and estimation paths use direct ob_malloc/ob_free with proper tenant attribution via MTL_ID. Co-Authored-By: Claude Opus 4.6 (1M context) <[REDACTED_EMAIL]>
Member
Author
|
The mapping Dima issue is about optimizing memory usage for Iterator/BtreeI labels. |
Member
Does px seekdb still mock sessions? |
Member
Author
Why is it called a mock session? Isn't it just serializing and deserializing the session information once? |
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.
Task Description
Replace the global object pool for memtable range scan iterators (
Iterator<BtreeIterator>, ~5KB each) with a session-level caching mechanism. The previous globalObFixedClassAllocatorpool had issues: memory was charged to the 500 tenant and was not observable, the global pool only grew and did not shrink under no load, and it was shared between foreground and background tasks without distinction.Solution Description
Introduced a two-path distribution mechanism to replace the global object pool:
THIS_WORKER.get_session()and uses a session-level free list (ObBtreeIterCache) to cache iterators. Iterators are reused across SQL statements within the same session (zero allocation after prewarm). All memory is released when the session disconnects.nullptr, iterators are directly allocated/freed viaob_malloc/ob_free. Memory is released immediately upon task completion.Passed Regressions
test_query_engine: PASSED (1/1)test_mvcc_callback: PASSED (19/19)oltp_read_only4 threads 30s: TPS=278, QPS=4444, zero errors.oltp_point_select4 threads 30s: TPS=3519, QPS=3519, zero errors.BtreeIterCachefully released after session disconnect,BtreeIterimmediately freed after merge completion, oldIterator<BtreeItag completely disappeared.Upgrade Compatibility
No impact on upgrades. This is a purely internal memory management change with no persistent format modifications.
Other Information
Under no load, all btree iterator-related memory returns to zero, resolving the issue of permanent occupancy by the global pool's peak watermark.
Performance regression: http://:9090/jenkins/job/lite_perf_guard/1003/
Release Note
Replaced the global memory pool for B-tree iterators used in memtable range scans with a session-level cache, improving memory observability and reclaiming memory immediately when sessions end or background tasks complete.