Skip to content

Address monitors by I2C bus and serialize writes per display to cut brightness latency - #5

Open
knowlen wants to merge 1 commit into
mainfrom
fast-ddc-bus-addressing
Open

knowlen wants to merge 1 commit into
mainfrom
fast-ddc-bus-addressing

Conversation

@knowlen

@knowlen knowlen commented Oct 1, 2026

Copy link
Copy Markdown
Owner

Problem

Changing brightness took 1-2 s to reach the monitors, and startup took about 5 s.

  • Every ddcutil call addressed the monitor with -d N, which makes ddcutil re-detect all displays first. On a machine with 11 I2C buses that costs 0.9-1.2 s per call.
  • The async worker only sent updates every 0.5 s and launched writes fire-and-forget, so writes to both displays contended for the bus (1.7 s for two) and an older write could finish after a newer one, leaving the monitor at a stale value.
  • Startup waited 1.0 s between reads and slept 1 s before the UI.

Changes

  • detect_displays() records each display's I2C bus; get_vcp_value, set_vcp_value and set_vcp_value_async use --bus N (falling back to -d N if unknown). Writes add --noverify --skip-ddc-checks, reads --skip-ddc-checks.
  • AsyncDDCWorker keeps at most one write in flight per display and sends the newest pending value when it finishes; intermediate values are skipped, displays are independent, and writes cannot land out of order. update_interval now defaults to 0.
  • _command_interval defaults to 0 (ddcutil already enforces DDC/CI timing); the startup sleep(1) / sleep(0.5) are removed.

Measurements (2 x LG 4K over HDMI, ddcutil 2.2.7)

Before After
setvcp per call 0.98-1.21 s (-d 1) 0.10 s (--bus 2 --noverify --skip-ddc-checks)
Both displays in parallel 1.74 s 0.12 s
Slider change -> both monitors updated 1.2-1.7 s + up to 0.5 s batching 0.11 s
Startup (detect + reads) ~5 s ~1.0 s

Tests

  • Updated expected ddcutil arguments; added tests for bus addressing after detection, newest-value-wins while a write is in flight, and independent displays.
  • 70 passed; black, ruff and mypy clean.

@claude

claude Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

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