Skip to content

[to dev/1.3] Optimize memtable scan#16643

Merged
JackieTien97 merged 4 commits intodev/1.3from
skipNotSatisfiedTimeRange-1.3
Oct 28, 2025
Merged

[to dev/1.3] Optimize memtable scan#16643
JackieTien97 merged 4 commits intodev/1.3from
skipNotSatisfiedTimeRange-1.3

Conversation

@shuwenwei
Copy link
Member

Description

Optimize memtable scan #16576

  1. unpackOneFakeMemChunkMetaData exits early after exceeding filter timeranges
  2. Non-aligned series push offset and limit down to the nextBatch method during the construction of TsBlock
  3. Aligned series handles pushDownFilter, offset, and limit when the rebuildTsBlock method needs to be called
  4. Skip unnecessary timestamps by binary search TVList
  5. Added a LazyBitmap to avoid constructing a too large Bitmap when calling nextBatch of AlignedTVListIterator

@codecov
Copy link

codecov bot commented Oct 24, 2025

Codecov Report

❌ Patch coverage is 63.57827% with 114 lines in your changes missing coverage. Please review.
✅ Project coverage is 40.99%. Comparing base (f547b38) to head (9c8d16d).
⚠️ Report is 9 commits behind head on dev/1.3.

Files with missing lines Patch % Lines
...rg/apache/iotdb/db/utils/datastructure/TVList.java 60.74% 42 Missing ⚠️
...gine/execution/operator/source/SeriesScanUtil.java 34.09% 29 Missing ⚠️
...he/iotdb/db/utils/datastructure/AlignedTVList.java 52.38% 20 Missing ⚠️
...ne/execution/fragment/FragmentInstanceContext.java 18.18% 9 Missing ⚠️
...taregion/read/reader/common/NoDataPointReader.java 0.00% 7 Missing ⚠️
...pache/iotdb/db/utils/datastructure/LazyBitMap.java 84.21% 6 Missing ⚠️
...iotdb/db/utils/datastructure/MemPointIterator.java 50.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             dev/1.3   #16643    +/-   ##
===========================================
  Coverage      40.98%   40.99%            
  Complexity       198      198            
===========================================
  Files           3581     3585     +4     
  Lines         234341   234715   +374     
  Branches       28211    28300    +89     
===========================================
+ Hits           96050    96225   +175     
- Misses        138291   138490   +199     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sonarqubecloud
Copy link

@JackieTien97 JackieTien97 requested a review from Copilot October 28, 2025 02:42
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR optimizes memtable scan performance by implementing several efficiency improvements: early exits based on time range filters, push-down of offset/limit operations, binary search for timestamp navigation, and lazy bitmap construction to reduce memory overhead.

Key changes:

  • Implements binary search methods in TVList to efficiently skip timestamps outside query ranges
  • Pushes down offset and limit operations to the nextBatch method for non-aligned series
  • Introduces LazyBitMap to avoid constructing large bitmaps unnecessarily for aligned series
  • Adds early exit logic in unpackOneFakeMemChunkMetaData when timestamps exceed filter ranges

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pom.xml Updates tsfile dependency version to include optimization changes
NonAlignedTVListIteratorTest.java Adds test coverage for time range skipping functionality
AlignedTVListIteratorTest.java Adds test coverage for time range skipping in aligned series
TVList.java Implements binary search methods and offset/limit push-down in nextBatch
OrderedMultiTVListIterator.java Adds skipToCurrentTimeRangeStartPosition method for multi-iterator handling
OrderedMultiAlignedTVListIterator.java Adds skipToCurrentTimeRangeStartPosition for aligned multi-iterators
MergeSortMultiTVListIterator.java Implements time range skipping for merge-sort iterators
MergeSortMultiAlignedTVListIterator.java Implements time range skipping for aligned merge-sort iterators
MemPointIterator.java Adds abstract method for time range start position skipping
LazyBitMap.java New class implementing lazy bitmap construction to reduce memory usage
AlignedTVList.java Replaces BitMap with LazyBitMap and refactors rebuild logic with filter/pagination
NoDataPointReader.java New singleton class for representing empty point readers
SeriesScanUtil.java Adds early exit optimization and satisfied time range tracking
FragmentInstanceContext.java Adds cached global time filter time ranges accessor

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@JackieTien97 JackieTien97 merged commit dbc0133 into dev/1.3 Oct 28, 2025
26 of 27 checks passed
@JackieTien97 JackieTien97 deleted the skipNotSatisfiedTimeRange-1.3 branch October 28, 2025 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments