Repository navigation
[Performance] Stop pre-sizing memtable block containers - #19426
Closed
luoluoyuyu wants to merge 1 commit into
Closed
luoluoyuyu wants to merge 1 commit into
luoluoyuyu wants to merge 1 commit into
Conversation
TVList sized the block containers of a memtable list with the node-wide average series length (WritingMetrics#getGlobalAvgSeriesPointNum() / ARRAY_SIZE). That average describes a whole series lifetime rather than the number of blocks a memtable list holds, it had no upper bound, and it was applied to every container: - every measurement column of an aligned TVList pre-allocated one Object[average] (about 1.3 KB for 160 blocks) even when the column was never written, which dominated the memory of wide devices; - extendColumns materialized one null reference per open block and column; - the unaligned timestamps/indices/bitmap containers were pre-sized the same way. Aligned columns now use LazyValueColumn: a block slot stays an implicit null until the block receives a value array, so an unwritten column costs only its container and a null block costs nothing. Block pre-allocation is now an opt-in, hot-reloadable switch (enable_tvlist_block_preallocation, default false) with a small fixed bound, and the container accounting charges the slots that exist, so the memtable cost used by flush and mem-control matches the memory that is actually retained.
Member
Author
|
Superseded by #19310, which now contains the memtable block-container fix (lazy allocation, opt-in pre-allocation switch, exact container accounting) together with the aligned write-path optimizations. |
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
A memtable list sized its block containers with the node-wide average series length
(
WritingMetrics#getGlobalAvgSeriesPointNum() / ARRAY_SIZE), which has no upper bound and isunrelated to the number of blocks a list holds. It was applied to every container:
AlignedTVListpre-allocated oneObject[average]per column (even for columns never written),extendColumnsmaterialized anullper open block and column, and the unalignedtimestamps/indices/bitMapcontainers were pre-sized the same way. The capacity was alsoinvisible to
calculateContainerRamCost(charged bylist.size()).Changes
LazyValueColumn: aligned per-column block container. A slot stays an implicit null and isallocated on first write;
size()still equals the number of open blocks, so write, sort, clone,WAL and flush-encode paths are unchanged.
AlignedTVListconstructor andextendColumnsuse it instead of pre-filledArrayLists.enable_tvlist_block_preallocation(default
false; when enabled, a fixed 16 blocks). Removed the global accumulators inWritingMetricsthat only fed that average; the per-DataRegionAVG_SERIES_POINT_NUMmetric isunchanged.
LazyValueColumn#ramCost()).Example
A column never written, global average 160 blocks:
Object[160]≈ 1.3 KB (8-byte refs)size() = 0Config
effectiveMode: hot_reload; read on every list creation.Validation
mvn -pl iotdb-core/datanode test -Dtest='AlignedTVListTest,PropertiesTest,TsFileProcessorTest,AlignedWritableMemChunkTest,AlignedTVListIteratorTest,NonAlignedTVListIteratorTest,MemTableFlushTaskTest'plus the TVList tests: 189 + 63 cases, 0 failures.
New tests:
testUnwrittenColumnsRetainNoBlockStorage,testUnwrittenColumnKeepsBlockSlotsImplicit,testExtendColumnsDoesNotAllocatePerBlockSlots,testBlockPreallocationSwitch,testTVListBlockPreallocationConfiguration.Data, serialization format, WAL and query results are unchanged.