Skip to content

⚡ Optimize event log export to use async I/O#148

Open
ScottMorris wants to merge 1 commit intomainfrom
perf/async-event-logs-6279845040915257839
Open

⚡ Optimize event log export to use async I/O#148
ScottMorris wants to merge 1 commit intomainfrom
perf/async-event-logs-6279845040915257839

Conversation

@ScottMorris
Copy link
Copy Markdown
Contributor

💡 What:

  • Refactored collect_event_logs in apps/threshold/src-tauri/src/event_logs.rs to be an async fn and use tauri::async_runtime::spawn_blocking for file reading and formatting.
  • Extracted core log processing logic into a synchronous read_and_format_logs function to facilitate testing and isolation.
  • Updated export_event_logs to be async, await collect_event_logs, and use spawn_blocking for directory creation and file writing.
  • Updated get_event_logs to be async and await collect_event_logs.
  • Added a unit test read_and_format_logs_works to verify the logic.

🎯 Why:

  • The previous implementation performed synchronous file I/O on the main thread, which could cause UI freezes, especially with large log files.
  • Offloading these operations to a worker thread via spawn_blocking ensures the application remains responsive during log export.

📊 Measured Improvement:

  • Verified that the new implementation correctly passes tests and compiles.
  • While exact UI responsiveness metrics were not collected (requires UI interaction), offloading I/O from the main thread is a standard and proven performance optimization in Tauri applications.

PR created automatically by Jules for task 6279845040915257839 started by @ScottMorris

- Extract `read_and_format_logs` for testability
- Use `spawn_blocking` for file I/O in `collect_event_logs` and `export_event_logs`
- Make `get_event_logs` async
- Add unit test for log formatting logic

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
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