Skip to content

Move workout scoring and snapshot encoding off the main actor - #28

Closed
AlexSchmidt1999 wants to merge 2 commits into
codex/upstream-review-oct10from
codex/training-performance-oct10
Closed

AlexSchmidt1999 wants to merge 2 commits into
codex/upstream-review-oct10from
codex/training-performance-oct10

Conversation

@AlexSchmidt1999

@AlexSchmidt1999 AlexSchmidt1999 commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Every accepted pulse sample used to score and JSON-encode the growing manual workout on the main actor. Encoding took most of the time in the local Release benchmark. Capture now keeps every sample and updates mean and peak immediately. One detached job scores the window, including its fingerprint, and encodes the existing snapshot. While that job runs, only the latest pending window is queued, with all accepted samples retained.

A result is applied only if its session and revision still match. Pause, resume, end, and background checkpoints invalidate older work before it can overwrite the UI or stored state. Checkpoints save the full window and the last completed live Effort estimate. Final saving uses the existing scoring and storage path. The snapshot key and format, Effort formulas, widget comparisons, and ActivityKit throttling stay the same.

On the local M4 Max, main-actor function time at 7,200 starting samples fell from 4.2842 to 0.7050 ms p95. The new timing adds capture and a valid result merge. It excludes scheduling and rendering. The benchmark report gives calculation, encoding, and main-actor measurements for all four sample counts.

Verification:

  • 35 focused macOS tests passed in Release with the existing DEBUG test accessors enabled. They cover numeric and snapshot equivalence, unchanged pulse values, duplicate seconds, gaps, stale lifecycle results, and a failed database save followed by a complete retry.
  • All 338 Python tool tests passed with canonical temporary paths on macOS. The normal macOS /var alias causes four pre-existing path-string comparison failures.
  • The regular iOS Release build passed, including widgets and Watch bundles. Build 451 is installed and launched on the owner's iPhone, with app sources matching this PR.
  • Source hygiene, translation coverage, source policy, and unsigned-binary policy passed. No capabilities, endpoints, dependencies, or BLE commands were added.

This is Apple-only, with unchanged numerical and stored-data contracts. Raw device recordings remain local. The build-450 recording showed a 518 ms callback interval, but does not identify every cause. An iPhone comparison after installation is still needed to check how much this helps scrolling.

The PR targets the combined fork test branch so its diff contains just this work. Measurement and optimization are separate commits. The existing upstream PRs are unchanged.

@AlexSchmidt1999

Copy link
Copy Markdown
Owner Author

Replaced by #31, which retains this draft's commits and includes the tested build-454 UI update fix. The current device comparison will be recorded there.

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