⚡ Cache hardware detection and optimize disk loop - #412
Conversation
Cache HardwareInfo::detect result using std::sync::OnceLock to avoid repeated expensive system information detection calls. Optimize virtual filesystem filtering in disk summation loop using byte slice matching.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
💡 What:
static HARDWARE_CACHE: OnceLock<HardwareInfo>) forHardwareInfo::detect(), while moving uncached physical system hardware detection intoHardwareInfo::detect_uncached().b"overlay" | b"tmpfs" | ...) and functional iterator summation, eliminatingstd::str::from_utf8validation overhead.benchmark_hardware_detectiontoserver_manager/benches/service_benchmark.rs.test_hardware_info_cached_and_uncached_detectioninserver_manager/src/core/hardware.rs.🎯 Why:
HardwareInfo::detect()was repeatedly invoked when composing structures, generating configurations, and executing CLI/web operations. ExecutingSystem::new(), refreshing disk/CPU lists, searching PATH binaries viawhich, and parsing user contexts on every call created significant latency. Caching static hardware information and removing string conversions makes hardware detection near-instantaneous.📊 Measured Improvement:
HardwareInfo::detect()uncached):496.01 µs(microseconds)HardwareInfo::detect()cached):45.858 ns(nanoseconds)PR created automatically by Jules for task 17336695570065704145 started by @Cylae