Skip to content

Batch 4: history/popup timing accuracy#109

Merged
rezdm merged 1 commit into
mainfrom
fix/batch4-history-popup
Jul 22, 2026
Merged

Batch 4: history/popup timing accuracy#109
rezdm merged 1 commit into
mainfrom
fix/batch4-history-popup

Conversation

@rezdm

@rezdm rezdm commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Batch 4 of the feedback fixes — the "recorded-over-time data doesn't line up with real elapsed time" cluster.

Closes #85
Closes #86

#85 — popup CPU chart alternated spikes and zeros

The popup sampled on a fixed 500 ms wall clock, but current_data_ only changes once per refresh interval — so it sampled the same snapshot twice (a 0% reading) or split one tick's counter delta over half the elapsed time (a ~2x spike). Now it appends one sample per new snapshot (gated on current_data_->timestamp) and consumes the already-correct per-process percentages (cpu_user_percent/cpu_kernel_percent/memory_percent, computed once per tick by DataStore with the right elapsed time) instead of re-deriving deltas. Drops the now-unused prev_utime/prev_stime/last_update fields.

#86 — history windows + hotspots

  • a "Last 1/5 min" are now real wall-clock windows via a new HistoryStore::count_since() — the tick count was derived from the current refresh interval, so changing the interval mid-session made the window wrong for older samples.
  • b get_series(): O(1) unordered_set membership instead of a linear std::find per process per sample.
  • c export_csv(): snapshot samples_/process_names_ under the lock, then write the files without holding it, so a slow export doesn't block the collector.

Testing

Built GUI+TUI+tests on Linux; unit tests pass (62 checks, incl. new count_since checks). Popup/history chart behavior to be confirmed in runtime testing.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xodto1bRjCSGEzLuz3JFbV

- #85 Process popup CPU chart: append one sample per *new* snapshot (gated on
  current_data_->timestamp) and consume the already-computed per-process
  percentages (cpu_user_percent/cpu_kernel_percent/memory_percent), instead of
  re-deriving counter deltas on a fixed 500ms wall-clock poll. The old scheme
  sampled the same snapshot twice (a 0% reading) and divided one tick's delta
  by half the elapsed time (a ~2x spike). Drops the now-unused prev_utime/
  prev_stime/last_update fields.
- #86a History "last 1/5 min" windows are now real wall-clock windows via a new
  HistoryStore::count_since(): the tick count came from the *current* refresh
  interval, so changing the interval mid-session made the window wrong for
  older samples. count_since returns how many recent samples fall in the
  window; the view feeds that to the existing count-based queries.
- #86b get_series(): O(1) unordered_set membership instead of a linear
  std::find over the pid list per process per sample.
- #86c export_csv(): snapshot samples_/process_names_ under the lock, then
  write the files without holding it, so a slow export doesn't block the
  collector's next record().

Built GUI+TUI+tests on Linux; 62 checks pass (incl. new count_since checks).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xodto1bRjCSGEzLuz3JFbV
@rezdm
rezdm merged commit 1dc11c6 into main Jul 22, 2026
12 checks passed
@rezdm
rezdm deleted the fix/batch4-history-popup branch July 22, 2026 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant