Vector35 / Vector35/debugger

UI widgets: mark-dirty-on-change, repaint at most every 100ms

Open
#1,093 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement Impact: Medium UI
Dominant language
C++
Stars
331
Forks
33
PR merge metrics
No merged PRs in 30d

Description

Follow-up to the worker-queue / state-on-worker discussion (#1090, #1088, #1089).

Problem

Every debugger event currently drives an immediate UI update on the dispatcher thread. Each widget that subscribes (register view, stack view, thread frames, modules, locals, IP highlight, statusbar, …) reacts inline. That's fine at normal user pace, but it caps the maximum stepping rate at "how fast can Qt repaint all the widgets," which is far slower than the engine can step.

Concretely: holding F11 to step rapidly today, the user gets maybe a dozen steps per second because each step's TargetStoppedEvent triggers a synchronous fan-out to every widget, each of which repaints. Most of those repaints are pure waste — the user only cares about the final state once they stop holding F11.

Proposed change

Two pieces:

1. Mark-dirty in callbacks; render on a timer

Each widget that consumes "snapshot"-style events (target stopped, register changed, active thread changed — anything where only the latest matters) does the following in its event callback:

void RegisterWidget::onDebuggerEvent(const DebuggerEvent&) {
    m_dirty = true;
    // do not call update() or repaint or fetch state here
}

A QTimer running at ~10Hz (every 100ms) checks the dirty flag and, if set, fetches the current state and triggers update():

void RegisterWidget::onFrameTick() {
    if (!m_dirty) return;
    m_dirty = false;
    m_snapshot = m_controller->GetState()->GetRegisters();
    update();
}

1000 events arrive between two timer ticks → dirty flipped 1000 times → one repaint with the freshest state.

2. Per-widget audit for snapshot vs. transition semantics

Not every event is "snapshot" semantics. Things like BreakpointChangedEvent are transitions (each one mutates a list; coalescing would lose information). Audit each widget and apply the dirty-bit pattern only to the snapshot subscribers; leave transition handlers running inline.

Suggested classification (verify per-widget):

Widget Snapshot or transition? Treatment
Register view, stack view, IP highlight, locals, statusbar snapshot (cares about latest state) dirty-bit + 100ms timer
Module list mostly transition but rarely changes during run dirty-bit + timer fine (low rate)
Thread frames snapshot dirty-bit + timer
Breakpoint widget transition inline (low rate already)
TTD events / bookmarks append/transition inline
Stdout pane append inline + Qt's own buffering
Why 100ms

It's slow enough that 1000 events coalesce into ~10 repaints (back-of-envelope), fast enough that the user perceives the updates as live. A perfect setting may be 50–150ms depending on widget cost; configurable per-widget if needed.

What this enables

Combined with Step(count=N) batching at the controller level (separate proposal), users holding F11 would see the engine actually run at engine speed — limited by adapter step latency rather than UI repaint cost. The two are complementary:

  • Step(count=N) collapses N user steps into one engine session, reducing the number of events fired.
  • The dirty-bit pattern ensures that when events DO fire rapidly (for any reason, not just stepping — also during target activity bursts like rapid module loads), the UI doesn't lag indefinitely behind.

Out of scope

  • Changing the event model / dispatcher contract (covered in earlier discussions). This proposal is purely on the widget consumer side.
  • Coalescing inside the broadcast queue (would require classifying events at the controller level; nice but bigger).
  • Snapshot-pointer / "always-fresh" rendering for high-rate widgets (would bypass events entirely; only worth doing if 100ms still isn't responsive enough).

Estimated scope

Each widget that opts in is ~15 lines: a member dirty flag, a QTimer, a slot. There are ~10 candidate widgets in ui/. Could land as one widget per PR or all in one focused refactor — they're independent.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the widget implementations under ui/ and audit the listed consumers: register, stack, thread frames, modules, locals, IP highlight, statusbar, breakpoint, TTD/bookmark, and stdout views. Trace their debugger-event callbacks and classify snapshot versus transition handling before applying the proposed timer approach. Done means snapshot widgets coalesce updates while transition and append handlers retain every event.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
desktop, performance
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.