Problem
The close_file method in src/interpreter/mod.rs currently holds the file_handles mutex while awaiting flush() and sync_all() operations, which serializes all I/O through this mutex and causes contention.
Current Code Location
- File:
src/interpreter/mod.rs
- Lines: Around 416-429
- Method:
IoClient::close_file
Issue Details
- The mutex guard is held while awaiting async file operations
- This prevents concurrent access to
file_handles by other tasks
flush() on tokio::fs::File is effectively a no-op
- Should prefer
sync_all() for durability and propagate errors properly
Proposed Solution
- Remove the file handle from the HashMap while holding the lock
- Drop the mutex guard immediately after removal
- Perform async sync operations outside the mutex scope
- Use
sync_all() with fallback to sync_data() for proper error handling
References
Priority
This affects I/O performance and concurrency under load, particularly when multiple file operations are happening simultaneously.
Problem
The
close_filemethod insrc/interpreter/mod.rscurrently holds thefile_handlesmutex while awaitingflush()andsync_all()operations, which serializes all I/O through this mutex and causes contention.Current Code Location
src/interpreter/mod.rsIoClient::close_fileIssue Details
file_handlesby other tasksflush()ontokio::fs::Fileis effectively a no-opsync_all()for durability and propagate errors properlyProposed Solution
sync_all()with fallback tosync_data()for proper error handlingReferences
Priority
This affects I/O performance and concurrency under load, particularly when multiple file operations are happening simultaneously.