perf: CPU optimization Phase 1 - reduce idle CPU from 61% to <5%#25
Merged
perf: CPU optimization Phase 1 - reduce idle CPU from 61% to <5%#25
Conversation
93c1a68 to
0775743
Compare
- Add once_cell dependency for static regex caching - Create regex_cache.rs with all compiled regex patterns - Update extractor.rs to use cached KOTLIN_SYNTHETIC_IMPORT and VIEWBINDING_VAR - Reduces CPU by avoiding regex recompilation on every file parse US-21.6: Cached regex patterns
The watcher loop was calling recv_event() followed by a 100ms sleep regardless of whether an event was received. Since recv_event() already blocks via the notify library (which uses OS-level file watching), the extra sleep was causing unnecessary CPU wake cycles. Removed tokio::time::sleep(Duration::from_millis(100)) from the loop. The notify library properly blocks recv_event() using inotify/FSEvents/kqueue.
0775743 to
47526ba
Compare
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
CPU optimization Phase 1 addressing high idle CPU usage issue. Includes multiple performance fixes:
Changes
Cached regex patterns (
src/indexer/regex_cache.rs)once_cell::Lazyextractor.rsand other modules to use cached patternsRemoved busy-loop sleep from AsyncFileWatcher (
src/watcher/notify_handler.rs)recv_event()blocks properly via OS-level file watching (inotify/FSEvents/kqueue)Documentation updates
Test Results
All commands verified working:
version,status,impact,serve,watch,mcp-stdio,benchmark,queryType of Change
Testing
cargo test)psRelated Issues
US-21.6: Cached regex patterns
US-21.8: Remove busy-loop sleep from AsyncFileWatcher