Skip to content

perf(battery): use GetSystemPowerStatus on Windows instead of SetupAPI/IOCTL - #7839

Merged
JanDeDobbeleer merged 1 commit into
claude/lazy-load-segment-perf-8wo3t7from
claude/windows-battery-perf-2pc76t
Aug 30, 2026
Merged

perf(battery): use GetSystemPowerStatus on Windows instead of SetupAPI/IOCTL#7839
JanDeDobbeleer merged 1 commit into
claude/lazy-load-segment-perf-8wo3t7from
claude/windows-battery-perf-2pc76t

Conversation

@JanDeDobbeleer

Copy link
Copy Markdown
Owner

The previous implementation enumerated battery devices via SetupAPI and
issued three sequential DeviceIoControl calls (IOCTL_BATTERY_QUERY_TAG,
_INFORMATION, _STATUS) per battery. The STATUS query round-trips to the
embedded controller, which is the dominant cost users reported (~80ms
per prompt render, see #1599).

GetSystemPowerStatus reads a value Windows already maintains for the
taskbar battery icon, so it returns percentage and charging state
without hitting the EC. The fields it can't provide (Voltage, Full/
Current capacity in mWh) aren't exposed by battery.Info today, so
there's no loss of currently displayed data.

@github-actions

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown

📦 Release binary size report

Compares this PR's release-equivalent build against the latest published release, per OS (amd64).

OS Baseline This PR Delta
darwin 13.82 MB 14.16 MB +342.4 KB (+2.42%) ⚠️
linux 13.49 MB 13.82 MB +336.0 KB (+2.43%) ⚠️
windows 14.05 MB 14.29 MB +244.7 KB (+1.7%)

⚠️ Binary size grew by more than the 2% / 256 KiB threshold on at least one platform. If this PR doesn't add a feature that justifies it, double-check for a new or heavier dependency.

@JanDeDobbeleer
JanDeDobbeleer changed the base branch from main to claude/lazy-load-segment-perf-8wo3t7 August 30, 2026 09:20
@JanDeDobbeleer
JanDeDobbeleer force-pushed the claude/windows-battery-perf-2pc76t branch from 3c61f7f to eb6a5e4 Compare August 30, 2026 09:22
…I/IOCTL

The previous implementation enumerated battery devices via SetupAPI and
issued three sequential DeviceIoControl calls (IOCTL_BATTERY_QUERY_TAG,
_INFORMATION, _STATUS) per battery. The STATUS query round-trips to the
embedded controller, which is the dominant cost users reported (~80ms
per prompt render, see #1599).

GetSystemPowerStatus reads a value Windows already maintains for the
taskbar battery icon, so it returns percentage and charging state
without hitting the EC. The fields it can't provide (Voltage, Full/
Current capacity in mWh) aren't exposed by battery.Info today, so
there's no loss of currently displayed data.
@JanDeDobbeleer
JanDeDobbeleer force-pushed the claude/windows-battery-perf-2pc76t branch from eb6a5e4 to 46a2569 Compare August 30, 2026 10:09
@JanDeDobbeleer
JanDeDobbeleer merged commit 5e94923 into main Aug 30, 2026
13 checks passed
@JanDeDobbeleer
JanDeDobbeleer deleted the claude/windows-battery-perf-2pc76t branch August 30, 2026 10:13
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.

2 participants