Repository navigation
feat(storage): AdaptiveCompactionScheduler — EMA-driven I/O monitoring, impact prediction, and dynamic trigger adjustment (v1.7.0, #209) - #4234
Merged
Conversation
) - Add include/storage/adaptive_compaction.h: AdaptiveCompactionScheduler class with EMA-based I/O pattern monitoring, compaction impact prediction, low-load period detection, and dynamic trigger adjustment - Add src/storage/adaptive_compaction.cpp: full production implementation - Add CompactionManager::setConfig()/getConfig() to allow live config updates - Add tests/test_adaptive_compaction.cpp: 30 focused tests covering all 4 ACs - Add .github/workflows/adaptive-compaction-ci.yml: CI workflow - Update cmake/CMakeLists.txt and cmake/ModularBuild.cmake to include new sources - Update tests/CMakeLists.txt to register AdaptiveCompactionFocusedTests Co-authored-by: makr-code <[email protected]>
- Remove spurious trigger_adjustments_ increment from collectSample() (should only count actual threshold adjustments in applyAdaptedConfig) - Use chrono::seconds::rep instead of long for portable duration cast - Hold bg_mutex_ during config_ assignment in setConfig() to prevent race condition with concurrent getConfig() reads - Rename unused loop variables i -> n in integration test Co-authored-by: makr-code <[email protected]>
Copilot
AI
changed the title
[WIP] Implement adaptive compaction for storage domain
feat(storage): AdaptiveCompactionScheduler — EMA-driven scheduling with dynamic trigger adjustment (v1.7.0)
Mar 14, 2026
makr-code
marked this pull request as ready for review
March 14, 2026 17:58
Contributor
There was a problem hiding this comment.
Pull request overview
Implements the new AdaptiveCompactionScheduler to monitor I/O patterns, predict compaction impact, schedule compactions during low-load periods, and dynamically adapt compaction/GC triggers; extends CompactionManager to support live config updates.
Changes:
- Added
AdaptiveCompactionScheduler(EMA-based sampling, impact prediction, trigger adaptation + application toCompactionManager) - Extended
CompactionManagerwithsetConfig()/getConfig()for dynamic updates (incl. BG GC restart on interval change) - Added focused unit tests + CMake/CI wiring for the new scheduler and manager config updates
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| include/storage/adaptive_compaction.h | Declares scheduler API, config, stats, and adapted config contract |
| src/storage/adaptive_compaction.cpp | Implements sampling thread, EMA logic, prediction, triggering, and config adaptation |
| include/storage/compaction_manager.h | Adds dynamic config update/snapshot API |
| src/storage/compaction_manager.cpp | Implements setConfig() / getConfig() with BG GC restart behavior |
| tests/test_adaptive_compaction.cpp | Adds focused unit + integration-style tests for scheduler and manager config updates |
| tests/CMakeLists.txt | Adds new focused test target and ctest entry (but currently breaks CMake scoping) |
| cmake/CMakeLists.txt | Adds adaptive compaction source to core build |
| cmake/ModularBuild.cmake | Adds adaptive compaction source to modular storage sources |
| .github/workflows/adaptive-compaction-ci.yml | Adds dedicated workflow to build/run the focused test target on relevant changes |
You can also share your feedback on Copilot code review. Take the survey.
| test_adaptive_compaction.cpp | ||
| ) | ||
|
|
||
| target_include_directories(test_adaptive_compaction_focused PRIVATE |
Comment on lines
+147
to
+150
| double wa_factor = (current_write_amp > 1.0) | ||
| ? std::log(current_write_amp) / std::log(config_.urgent_write_amp_threshold) | ||
| : 0.0; | ||
|
|
Comment on lines
+121
to
+124
| /** Minimum tombstone GC threshold (used during high-write periods). */ | ||
| uint64_t min_tombstone_threshold = 1'000; | ||
|
|
||
| /** Maximum tombstone GC threshold (used during low-write periods). */ |
| pred.is_urgent = | ||
| (current_write_amp >= config_.urgent_write_amp_threshold); | ||
|
|
||
| // Low impact = low estimated CPU overhead AND low current load. |
Comment on lines
+44
to
+46
| void AdaptiveCompactionScheduler::updateEMA(double new_value, double& ema) noexcept { | ||
| ema = config_.ema_alpha * new_value + (1.0 - config_.ema_alpha) * ema; | ||
| } |
| collectSample(); | ||
| } | ||
| } | ||
|
|
… conventions - tests/CMakeLists.txt: fix post-merge corruption where test_adaptive_compaction_focused block was interleaved with test_device_manager_focused block; restore both blocks with correct target_include_directories, target_link_libraries and if/else/endif nesting - .github/workflows/adaptive-compaction-ci.yml: replace inline cmake configure+build steps with configure-themis composite action; add librocksdb-dev to setup-cpp-build packages Co-authored-by: makr-code <[email protected]>
Copilot
AI
changed the title
feat(storage): AdaptiveCompactionScheduler — EMA-driven scheduling with dynamic trigger adjustment (v1.7.0)
feat(storage): AdaptiveCompactionScheduler — EMA-driven I/O monitoring, impact prediction, and dynamic trigger adjustment (v1.7.0, #209)
Mar 15, 2026
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.
Implements roadmap item #209: machine-learning-inspired (EMA-based) adaptive compaction scheduling for the storage engine, targeting 20–30% reduction in compaction CPU overhead.
New:
AdaptiveCompactionSchedulerinclude/storage/adaptive_compaction.h·src/storage/adaptive_compaction.cpprecordRead()/recordWrite()+ background sampling thread → per-second rates → EMA smoothing (αconfigurable)predictCompactionImpact(write_amp)→CompactionImpactPrediction(CPU overhead ∈ [0,1], duration estimate,is_urgent,is_low_impact)isLowLoadPeriod()(EMA rates vs thresholds) +shouldTriggerCompaction(write_amp)combining WA urgency with low-load gategetAdaptedConfig()/applyAdaptedConfig(mgr)linearly interpolate tombstone threshold and GC interval from measured load pressureExtended:
CompactionManagerAdded
setConfig(const Config&)andgetConfig()for live config updates.setConfigholdsbg_mutex_during the assignment to prevent a race with concurrentgetConfig()reads, and restarts the background GC thread so the new interval takes effect immediately.Tests · CI · Build
tests/test_adaptive_compaction.cpp— 30 focused tests inAdaptiveCompactionFocusedTestscovering all 4 ACs including an integration testtests/CMakeLists.txt— fixed post-merge corruption where the adaptive compaction andtest_device_manager_focusedblocks were interleaved (missingtarget_include_directoriesbody, wrongif/else/endifnesting); both blocks restored to correct standalone structure.github/workflows/adaptive-compaction-ci.yml— replaced inlinecmakesteps withconfigure-themiscomposite action; addedlibrocksdb-devtosetup-cpp-buildpackages per CI conventionscmake/CMakeLists.txt+cmake/ModularBuild.cmake—adaptive_compaction.cppadded to storage source listsType of Change
Testing
📚 Research & Knowledge (wenn applicable)
/docs/research/angelegt?/docs/research/implementation_influence/eingetragen?Relevante Quellen:
Checklist
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.