Skip to content

Reduce use of event-dispatch thread (EDT) from I/Q#207

Draft
hanno-becker wants to merge 2 commits intomainfrom
edt_fixes
Draft

Reduce use of event-dispatch thread (EDT) from I/Q#207
hanno-becker wants to merge 2 commits intomainfrom
edt_fixes

Conversation

@hanno-becker
Copy link
Copy Markdown
Contributor

  • [refactor] I/Q: Avoid EDT for read-only PIDE snapshots

    Several MCP tool handlers blocked the EDT to obtain snapshots they
    only read. Use PIDE.session.snapshot(node_name) directly from the
    worker thread instead.

    Name worker threads iq-worker-N, set daemon + MIN_PRIORITY so the
    OS scheduler prefers the EDT when CPU is contended.

  • I/Q: Replace polling loops with event-driven waiting

    Theory completion, command retrieval, and stable-snapshot waits all
    polled with Thread.sleep, stalling the calling thread and — in some
    paths — the EDT. jEdit would freeze for the duration of long-running
    proof checks.

    Subscribe to Session.Commands_Changed and count down a latch when
    the target condition is met. Re-check immediately after subscribing
    to close the TOCTOU window. Add PIDE.editor.flush() after
    write_to_theory so PIDE.session.snapshot() reflects the pending
    edit without an EDT round-trip.

Several MCP tool handlers blocked the EDT to obtain snapshots they
only read. Use PIDE.session.snapshot(node_name) directly from the
worker thread instead.

Name worker threads iq-worker-N, set daemon + MIN_PRIORITY so the
OS scheduler prefers the EDT when CPU is contended.

Signed-off-by: Hanno Becker <beckphan@amazon.co.uk>
Theory completion, command retrieval, and stable-snapshot waits all
polled with Thread.sleep, stalling the calling thread and — in some
paths — the EDT. jEdit would freeze for the duration of long-running
proof checks.

Subscribe to Session.Commands_Changed and count down a latch when
the target condition is met. Re-check immediately after subscribing
to close the TOCTOU window. Add PIDE.editor.flush() after
write_to_theory so PIDE.session.snapshot() reflects the pending
edit without an EDT round-trip.

Signed-off-by: Hanno Becker <beckphan@amazon.co.uk>
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