Skip to content

Avoid event-loop reentry in window height checks - #539

Open
adkins17 wants to merge 1 commit into
potatomushclient:masterfrom
adkins17:fix/window-height-event-loop-latency
Open

adkins17 wants to merge 1 commit into
potatomushclient:masterfrom
adkins17:fix/window-height-event-loop-latency

Conversation

@adkins17

Copy link
Copy Markdown

Summary

  • remove the nested Tk update from ::potato::countWindowHeight
  • prevent window-height/NAWS measurement from re-entering queued UI, input, timer, or socket callbacks
  • add a stock Tcl/Tk regression test and PowerShell runner
  • include a 500-call latency measurement in the test output

Reproducer

The test queues an unrelated callback immediately before calling countWindowHeight.
On unmodified stock Potato, the callback runs inside the function because update
processes the complete Tk event queue. With this patch, it remains pending until the
normal event loop resumes.

Results

Tcl/Tk 8.6.18, Windows, upstream baseline 46d18387bd6b156b85176fa588a60991cbba6235:

Build Re-entry assertion p50 p95 max
Stock FAIL 0.011 ms 0.060 ms 0.600 ms
Patched fresh worktree PASS 0.005 ms 0.006 ms 0.237 ms

The primary correction is eliminating nested event-loop processing; the microbenchmark
also showed a roughly 90 percent p95 reduction.

Test

./tests/Test-WindowHeightLatency.ps1 -Runtime C:/path/to/tclkit-8.6.18-win64-intel-tk.exe

Fresh-worktree validation passed:

  • patch apply check
  • patch reverse check
  • PowerShell parser
  • all window-height regression assertions

This change is based directly on stock Potato and has no dependency on split-screen,
packet-debugger, telemetry, or other custom-client code.

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