Skip to content

Comments

⚡ Replace blocking Path::exists in web interface with async counterparts#190

Open
Cylae wants to merge 1 commit intomainfrom
fix-blocking-io-web-interface-3973199796531529381
Open

⚡ Replace blocking Path::exists in web interface with async counterparts#190
Cylae wants to merge 1 commit intomainfrom
fix-blocking-io-web-interface-3973199796531529381

Conversation

@Cylae
Copy link
Owner

@Cylae Cylae commented Feb 14, 2026

This optimization replaces blocking synchronous file system calls with their asynchronous counterparts from the tokio crate in the server_manager/src/interface/web.rs file.

In async Rust, blocking the executor thread with synchronous I/O can lead to reactor starvation, where other tasks (like incoming HTTP requests) cannot be processed while a thread is waiting for the OS to return from a stat syscall.

Key changes:

  • Replaced path.exists() with tokio::fs::try_exists(path).await.unwrap_or(false).
  • Replaced std::fs::metadata(path) with tokio::fs::metadata(path).await.
  • Updated get_users, start_server, add_user_handler, and delete_user_handler.

Performance impact:
While a micro-benchmark of a single exists() call shows minimal difference due to the speed of modern filesystems, these changes follow async best practices and ensure the application scales correctly under high load by never blocking the reactor.


PR created automatically by Jules for task 3973199796531529381 started by @Cylae

… equivalents

Replaced synchronous `std::path::Path::exists` and `std::fs::metadata` with
`tokio::fs::try_exists` and `tokio::fs::metadata` respectively in `web.rs`.
This ensures that the async reactor's worker threads are not blocked by
filesystem I/O in high-concurrency scenarios, improving responsiveness.

Locations updated:
- `AppState::get_users`
- `start_server`
- `add_user_handler`
- `delete_user_handler`
@google-labs-jules
Copy link
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant