Skip to content

Add Stopwatch.Reporter utility and refactor Rate_Group to use it - #190

Merged
dinkelk merged 2 commits into
lasp:mainfrom
dinkelk:feature/stopwatch-reporter
Jul 31, 2026
Merged

Add Stopwatch.Reporter utility and refactor Rate_Group to use it#190
dinkelk merged 2 commits into
lasp:mainfrom
dinkelk:feature/stopwatch-reporter

Conversation

@dinkelk

@dinkelk dinkelk commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds Stopwatch.Reporter, a child package of Stopwatch that pairs a wall-clock and CPU-execution stopwatch for timing a section of code, accumulates recent-maximum and all-time-maximum values for both, and reports them as a Task_Timing_Report.T (the same type Rate_Group publishes, so measurements from any component can share a downlink packet).

The Rate_Group component previously hand-rolled exactly this logic in its tick handler; the second commit refactors it to use the new package (net -38 lines) with identical behavior.

Design notes

  • External wall times: Start/Stop overloads accept an externally supplied wall clock time, supporting backdating a measurement to an incoming tick's timestamp so queue latency is included (the Rate_Group pattern), or supplying both endpoints from converted Sys_Time stamps.
  • Max-updated indication: Accumulate optionally reports whether either all-time maximum was updated, supporting Rate_Group's time-exceeded events.
  • Per-operation reporting: Report_Last carries the most recent measurement alongside the all-time maximums, for components that publish a report per operation rather than periodically.
  • Instance is a public record, matching the parent Stopwatch style.

Validation

  • New unit test suite (src/util/stopwatch/test, 4 tests) exercising start/stop with injected times, accumulation and max-updated indications, both report variants, and both resets: 4/4 pass.
  • All 5 existing Rate_Group unit tests pass unmodified against the refactor.
  • redo style passes on both directories.

@dinkelk
dinkelk requested review from Jbsco and cbrisebois-lasp July 29, 2026 21:40
@dinkelk
dinkelk force-pushed the feature/stopwatch-reporter branch 3 times, most recently from add9853 to 835b1ce Compare July 30, 2026 17:23

@Jbsco Jbsco left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Some callouts, also wondering if timing_report.record.yaml should move to src/types/task/, alongside task_timing_report.record.yaml.
And should the Max_Cycle_Time_Exceeded value assertion in the Rate_Group suite be restored as part of this?

Comment thread src/components/rate_group/component-rate_group-implementation.ads Outdated
Comment thread src/util/stopwatch/stopwatch-reporter.adb Outdated
Comment thread src/util/stopwatch/stopwatch-reporter.ads
Comment thread src/components/rate_group/component-rate_group-implementation.adb Outdated
@dinkelk
dinkelk force-pushed the feature/stopwatch-reporter branch from 83f827c to 33c33bc Compare July 30, 2026 18:53
@dinkelk

dinkelk commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks for the review. All addressed and squashed back to 2 commits:

  • Named associations in the To_Report calls: done.
  • Timer field moved under its comment: done.
  • Sys_Time fetch in the CPU measurement: good catch, fixed with split Stop_Cpu_Timer/Stop_Wall_Timer primitives (see inline reply).
  • timing_report.record.yaml moved to src/types/task next to task_timing_report.record.yaml.
  • Max_Cycle_Time_Exceeded value assertion restored -- the wall side is deterministic in test, so it works again. Only the execution time values remain count-only (real CPU clock).
  • Instance stays public per the inline thread.

Comment thread src/util/stopwatch/stopwatch-reporter.adb Outdated
@dinkelk
dinkelk force-pushed the feature/stopwatch-reporter branch from 33c33bc to bb80d7f Compare July 30, 2026 19:13
@Jbsco
Jbsco self-requested a review July 30, 2026 19:26
@dinkelk
dinkelk force-pushed the feature/stopwatch-reporter branch from bb80d7f to ad63daf Compare July 31, 2026 15:05

@Jbsco Jbsco left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

src/components/rate_group/types/ is now an empty directory, except for .all_path, could be removed in this PR, but not blocking. Otherwise looks good!

@dinkelk
dinkelk force-pushed the feature/stopwatch-reporter branch from ad63daf to ea814a6 Compare July 31, 2026 17:01
@dinkelk

dinkelk commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator Author

src/components/rate_group/types/ is now an empty directory, except for .all_path, could be removed in this PR, but not blocking. Otherwise looks good!

addressed.

dinkelk added 2 commits July 31, 2026 11:31
Combines a wall-clock and CPU-execution stopwatch pair for timing a
section of code. Accumulates recent-maximum and all-time-maximum values
for both timers and reports them as a Task_Timing_Report.T, the same
type the Rate_Group component publishes, so measurements from any
component can be collected into a common downlink packet.

The wall clock start and stop times may be supplied externally, which
supports backdating a measurement to an incoming tick's timestamp so
that queue latency is included. Stop is also available in split
Stop_Cpu_Timer and Stop_Wall_Timer halves so that an expensive wall
stop time acquisition can be excluded from the CPU measurement.
Accumulate optionally reports whether either all-time maximum was
updated, supporting time-exceeded events. Report_Last provides
per-operation reporting, carrying the most recent measurement
alongside the all-time maximums.

Includes a unit test suite exercising the timer pair, accumulation,
report contents, and reset behavior with deterministic injected times.
Replace the hand-rolled maximum tracking, timing report conversion,
and recent-maximum reset logic in the Rate_Group tick handler with the
new Stopwatch.Reporter utility. Behavior is unchanged: the wall
measurement still starts at the incoming tick's timestamp, the system
time fetch for the wall stop remains excluded from the CPU measurement
(via the split stop), the time-exceeded events still fire when either
all-time maximum updates, and the data product contents are identical.

Also move timing_report.record.yaml next to task_timing_report.record.yaml
in src/types/task, and restore the max cycle time value assertion in
the unit test suite; the wall measurement is deterministic in test
since it spans the tick timestamp to the tester-provided system time.
@dinkelk
dinkelk force-pushed the feature/stopwatch-reporter branch from ea814a6 to 334857e Compare July 31, 2026 17:40
@dinkelk
dinkelk merged commit 096cb30 into lasp:main Jul 31, 2026
4 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