Skip to content

feat: add disk activity history on the Performance page - #30

Merged
JamesLinYJ merged 2 commits into
mainfrom
cursor/disk-activity-history-f9aa
Oct 20, 2026
Merged

JamesLinYJ merged 2 commits into
mainfrom
cursor/disk-activity-history-f9aa

Conversation

@JamesLinYJ

@JamesLinYJ JamesLinYJ commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds disk activity history on the Performance page, in the same style as the CPU and memory graphs.

  • The existing system sampler worker reads IOCTL_DISK_PERFORMANCE on \\.\PhysicalDriveN and keeps those handles open. Refresh does not open processes. A failed read leaves the byte and timing baselines in place.
  • Each successful IOCTL_DISK_PERFORMANCE increments the driver's enable reference. The collector keeps one enable while the handle is open and issues IOCTL_DISK_PERFORMANCE_OFF for every other success. Dropping the drive — worker shutdown, or the drive disappearing — releases whatever remains before CloseHandle. A failed IOCTL does not add a reference. A disable that fails leaves that reference outstanding and is reported once.
  • The first sample, a counter reset, and a rate that does not fit in u64 replace the baseline and do not publish a point. A zero query interval publishes nothing and keeps the previous baseline.
  • Read and write bytes per second are u64. The graph is active time, 0–100, in the same ring buffer and grid used by the other performance graphs. The UI thread only lays out and paints.
  • The disk band sits under memory and above the detail area. No-title mode still fills the window with the CPU graph.
  • New strings are in TextKey and every locale. No new menu command. Options is unchanged.

Tests

  • First sample only stores a baseline.
  • A backwards counter replaces the baseline and the next interval does not spike.
  • A zero query interval keeps the baseline, and the bytes show up on the next real interval.
  • A rate that overflows u64, or a sum of drive rates that overflows u64, does not publish.
  • A failed read does not advance any baseline.
  • Totals add byte rates and the graph uses the busiest disk.
  • The performance page pushes a history point only for a real rate, and a failed sample leaves that point in place.
  • Successful samples keep one enable outstanding and shutdown releases that last reference once.
  • A failed IOCTL does not require a disable. A rejected payload after a successful IOCTL still counts as an enable.
  • A failed disable leaves the reference outstanding and does not keep issuing. Removing one drive balances only that drive.

Verification

This host is Linux. cargo fmt --all -- --check passed. cargo clippy --all-targets --locked -- -D warnings passed for x86_64-pc-windows-msvc, i686-pc-windows-msvc, and aarch64-pc-windows-msvc. cargo build --release --locked --target x86_64-pc-windows-msvc stops because link.exe is not on this machine, so the disk unit tests were type-checked and not executed here. These checks are not a Windows device test.

CI on this PR runs Quality (x86_64) and Architecture (i686, aarch64), including the Windows test and release builds. Hands-on disk graph behavior on a Windows device is still pending.

Open in Web Open in Cursor 

Sample physical-disk byte counters on the existing system worker and
draw active time with the same history graph as CPU and memory.

Co-authored-by: jameslincn <jameslincn@outlook.sg>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T02:56:05.459635Z 247cd9e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 247cd9e8ac

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/system/disk.rs
let ok = unsafe {
DeviceIoControl(
handle,
IOCTL_DISK_PERFORMANCE,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Balance each disk-performance enable request

On every successful periodic sample, this issues IOCTL_DISK_PERFORMANCE again without ever issuing IOCTL_DISK_PERFORMANCE_OFF. Microsoft documents that the former increments a reference counter and that the latter disables counters enabled by previous calls, so the worker continually accumulates enable references and releases none when a drive disappears or the collector stops, potentially leaving system-wide disk-statistics collection enabled after exit. Track and balance successful enables, including the worker shutdown path.

AGENTS.md reference: AGENTS.md:L48-L50

Useful? React with 👍 / 👎.

Each successful IOCTL_DISK_PERFORMANCE increments the driver's reference
count. Track those successes, keep one enable while the handle is open,
and issue IOCTL_DISK_PERFORMANCE_OFF for the rest, including worker
shutdown and a drive that disappears.

Co-authored-by: jameslincn <jameslincn@outlook.sg>
@JamesLinYJ
JamesLinYJ merged commit 51e6bf5 into main Oct 20, 2026
3 checks passed
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