Conversation
* Implemented a `PendingWrites` map with disabled CaseSense. * Initialized a 1000ms `SetTimer` to run `ProcessPendingWrites`. * Modified `SaveCurrentWindowPosition` to defer IniWrite calls to memory instead of writing directly to disk, dramatically reducing I/O usage during drag/resize events. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
|
👋 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. |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
There was a problem hiding this comment.
Pull request overview
This PR reduces disk I/O in the Window Manager GUI script by deferring IniWrite calls while a window is actively moving/resizing, then writing the final position after inactivity.
Changes:
- Introduces
LastSaved/PendingWritesmaps (case-insensitive) to track last position and pending debounced writes. - Adds a
ProcessPendingWritestimer to flush queued INI updates after an inactivity threshold. - Updates
SaveCurrentWindowPosition()to queue writes instead of writing immediately.
| IniWrite(currentValue, A_ScriptDir . "\WindowSizePosLog.ini", "Process Names", processName) | ||
| } | ||
| keysToDelete.Push(processName) |
There was a problem hiding this comment.
ProcessPendingWrites() calls IniWrite() without any error handling. If the INI write fails (file locked, permission issues, etc.), the timer thread can throw and potentially stop processing future pending writes. Consider wrapping the write in a try and only removing the entry from PendingWrites after a successful write (or keeping it queued to retry).
| IniWrite(currentValue, A_ScriptDir . "\WindowSizePosLog.ini", "Process Names", processName) | |
| } | |
| keysToDelete.Push(processName) | |
| try { | |
| IniWrite(currentValue, A_ScriptDir . "\WindowSizePosLog.ini", "Process Names", processName) | |
| keysToDelete.Push(processName) | |
| } catch e { | |
| OutputDebug("WM.ahk: Failed to write INI for process '" . processName . "': " . e.Message) | |
| } | |
| } |
|
|
||
| ; Main loop - monitor windows and save/restore positions | ||
| SetTimer(MonitorWindows, 350) | ||
| SetTimer(ProcessPendingWrites, 1000) |
There was a problem hiding this comment.
The debounce behavior here can exceed the stated 1000ms: the timer runs every 1000ms and you also require >= 1000 elapsed, so the actual write can happen ~1000–2000ms after the last change depending on timer alignment. If the intent is “write 1000ms after inactivity”, consider using a shorter polling interval (e.g., 250ms) or switching to a one-shot timer that gets reset on each change (e.g., schedule ProcessPendingWrites with a negative period on updates).
💡 What:
The optimization changes the
IniWriteoperation that previously occurred on every window drag/resize loop execution into a deferred, debounced disk write operation.🎯 Why:
The performance problem is excessive disk I/O when tracking window positions. The
MonitorWindowsloop runs every 350ms. When dragging a window, a singleIniWritewas called on each loop iteration, leading to hundreds of unnecessary synchronous writes. The final resting position is all that needs to be logged.📊 Measured Improvement:
Dynamic execution of AHK benchmark was not performed since the environment lacks Wine (
autohotkeycommand is missing). However, mathematically, a 10-second continuous window drag operation that previously caused ~28 individual disk I/O write operations (1 per 350ms) now performs exactly 0 disk writes during dragging and 1 disk write after 1000ms of inactivity, resulting in near 100% reduction of blocking operations over that timespan.PR created automatically by Jules for task 1848832163621820363 started by @Ven0m0