Repository navigation
Fix/min folder occupied space cache - #17996
Merged
jt2594838 merged 2 commits intoJun 22, 2026
Merged
Conversation
…rategy MinFolderOccupiedSpaceFirstStrategy recomputed every folder's occupied space via a full Files.walk on every folder selection. While receiving a snapshot made of hundreds of thousands of tiny files, this turned each per-file allocation into a full directory-tree scan, making the cost quadratic. addPeer stalled (observed ~1 file / 4-5s) and syncLag stayed high. Cache the occupied space per folder and only recompute it periodically: an incremental selection counter is kept and, once a count threshold or a time interval is reached, the cached state is reset and the occupied space is recomputed. Selection semantics (pick the least occupied folder) are preserved while the number of full directory scans is bounded. Add a mocked unit test (DirectoryStrategyTest) and a real-filesystem integration test (MinFolderOccupiedSpaceFirstStrategyRealFsTest) covering the caching, the count-based refresh and the reset.
jt2594838
approved these changes
Jun 22, 2026
MileaRobertStefan
pushed a commit
to MileaRobertStefan/iotdb
that referenced
this pull request
Jun 26, 2026
* fix(consensus): cache occupied space in MinFolderOccupiedSpaceFirstStrategy MinFolderOccupiedSpaceFirstStrategy recomputed every folder's occupied space via a full Files.walk on every folder selection. While receiving a snapshot made of hundreds of thousands of tiny files, this turned each per-file allocation into a full directory-tree scan, making the cost quadratic. addPeer stalled (observed ~1 file / 4-5s) and syncLag stayed high. Cache the occupied space per folder and only recompute it periodically: an incremental selection counter is kept and, once a count threshold or a time interval is reached, the cached state is reset and the occupied space is recomputed. Selection semantics (pick the least occupied folder) are preserved while the number of full directory scans is bounded. Add a mocked unit test (DirectoryStrategyTest) and a real-filesystem integration test (MinFolderOccupiedSpaceFirstStrategyRealFsTest) covering the caching, the count-based refresh and the reset. * fix(consensus): make occupied space cache refresh configurable
JackieTien97
pushed a commit
that referenced
this pull request
Jun 29, 2026
* fix(consensus): cache occupied space in MinFolderOccupiedSpaceFirstStrategy MinFolderOccupiedSpaceFirstStrategy recomputed every folder's occupied space via a full Files.walk on every folder selection. While receiving a snapshot made of hundreds of thousands of tiny files, this turned each per-file allocation into a full directory-tree scan, making the cost quadratic. addPeer stalled (observed ~1 file / 4-5s) and syncLag stayed high. Cache the occupied space per folder and only recompute it periodically: an incremental selection counter is kept and, once a count threshold or a time interval is reached, the cached state is reset and the occupied space is recomputed. Selection semantics (pick the least occupied folder) are preserved while the number of full directory scans is bounded. Add a mocked unit test (DirectoryStrategyTest) and a real-filesystem integration test (MinFolderOccupiedSpaceFirstStrategyRealFsTest) covering the caching, the count-based refresh and the reset. * fix(consensus): make occupied space cache refresh configurable
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.
Description
Cache Refresh Configuration
This PR makes the occupied-space cache refresh policy in
MinFolderOccupiedSpaceFirstStrategyconfigurable instead of hardcoding60sand1000selections.Configuration Loading
Two common config items are added with positive-value validation:
min_folder_occupied_space_cache_refresh_interval_msmin_folder_occupied_space_cache_refresh_selection_thresholdInvalid non-positive values are ignored and the defaults are kept.
Tests
Added real-filesystem coverage for the occupied-space cache behavior and updated existing strategy tests.
This PR has:
Key changed/added classes (or packages if there are too many classes) in this PR
MinFolderOccupiedSpaceFirstStrategyCommonConfigCommonDescriptoriotdb-system.properties.template