Optimize web interface performance and async safety#197
Conversation
…gement - Implemented `add_user_async` and `delete_user_async` in `UserManager` to offload blocking I/O and system calls to `tokio::task::spawn_blocking`. - Optimized `start_server` to initialize `sysinfo::System` in a blocking task, preventing async runtime stalls during startup. - Refactored `dashboard` handler to perform system resource refreshes (CPU, RAM, Disks) in a blocking task, ensuring responsiveness even under load. - Replaced potential panics (`unwrap`) on Mutex locks with safer `expect` calls. - Bumped version to 1.0.8 in `Cargo.toml` and `README.md`.
|
👋 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. |
This PR addresses performance bottlenecks and potential async runtime blocking issues in the Server Manager web interface.
Key changes:
add_user_asyncanddelete_user_asynctoUserManager. These methods handle file I/O (updatingusers.yaml) and system calls (creating/deleting Linux users) withintokio::task::spawn_blocking, preventing the async executor from stalling during these operations.dashboardhandler previously performed synchronous system hardware refreshes (refresh_cpu,refresh_memory,refresh_disks) while holding a Mutex on the main async thread. This has been moved tospawn_blocking.sysinfo::System::new_all()is a heavy operation. It is now offloaded to a blocking task during server startup.unwrap()calls onstd::sync::Mutexlocks withexpect()for better error reporting (though poisoning still panics, as is standard).Verified with
cargo check,cargo test, andcargo clippy.PR created automatically by Jules for task 16168826496189565349 started by @Cylae