Skip to content

Reduce Apple UI and scoring work on the main thread - #31

Closed
AlexSchmidt1999 wants to merge 6 commits into
codex/upstream-review-oct10from
codex/ui-update-scope-oct11
Closed

AlexSchmidt1999 wants to merge 6 commits into
codex/upstream-review-oct10from
codex/ui-update-scope-oct11

Conversation

@AlexSchmidt1999

@AlexSchmidt1999 AlexSchmidt1999 commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner

Foreground rescores merge a full day of heart-rate samples, sort them and calculate Effort and calories on the main actor. This happens during ordinary use, with no training session running. The cache-miss read-and-score block now runs in a utility-priority detached task. Cache access and the result merge stay on the main actor. Owner precedence, query limits, formulas and stored values stay the same.

This fork test PR also retains the earlier performance changes:

  • Manual workout scoring and snapshot encoding run off the main actor, with session and revision checks before applying results.
  • Today publishes day results after the final read and cancellation check.
  • The app entries retain AppModel without observing every publication. Live screens keep observing the same object. The iPhone tab shell receives its repository as a plain reference, and the Shortcuts import alert subscribes to pending imports.
  • The existing opt-in local capture labels windows with workout and Lift Log state.

The earlier build-454 archive, retrieved before the day-cycle fix, contains 130 windows from 43 foreground captures, all starting without training. Today has 204.96 sampled seconds and a worst callback interval of 265.7 ms. Trends has 48.20 seconds and a worst of 220.6 ms. Most windows overlap the first ten seconds after returning to the app.

Applying the earlier comparison filters leaves only 34.93 seconds of Today data for build 454, compared with 483.81 seconds for build 453. Late callbacks are 1.232% and 0.418%, respectively. The captures cover different interactions and durations. The retained logs also place long windows near foreground rescores. One pass reports 4.176 seconds elapsed and 4.0 CPU seconds. Its phase timings include database waits.

Local verification:

  • Both Apple Release targets compile, including iPhone widgets and Watch bundles. The new iOS artifact is build 455.
  • 50 focused macOS tests pass. A new integration fixture uses 80,000 primary HR samples, conflicting timestamps from a second owner and out-of-range points. Effort and calorie bit patterns match values recorded before the change for both methods and both sex-specific calorie paths. The test also checks cache reuse and invalidation after a new sample.
  • The hosted import tests create their private store before the app model, fixing a startup-open race in the test fixture.
  • All 338 Python tool tests, source hygiene, translation coverage, source policy and the four-bundle binary policy pass.

The device traces also contain substantial SwiftUI graph and rendering work.

The capture report and workout benchmark document the measurements. Raw recordings and preferences stay local. Android is unchanged because this changes Apple execution scheduling without changing analytics or storage formats.

This replaces fork test drafts #28, #29 and #30. Their changes remain separate commits. The PR targets the combined fork review branch, and the existing upstream feature PRs remain separate.

iPhone follow-up, October 16

The owner reports smoother everyday use with the combined build. The Today measurements record 0.026% late callbacks over 64.71 seconds, compared with 0.536% over 860.79 seconds before the day-cycle scheduling change. The worst callback interval falls from 159.6 to 63.4 ms.

The October 16 merge with upstream testing is installed. Its first 6.29 sampled seconds contain 404 callbacks, four late callbacks and zero intervals over 33 ms. The longest interval is 29.2 ms. The linked report contains the source revisions, full counts and sampling method. Raw archives and personal data stay local.

@AlexSchmidt1999 AlexSchmidt1999 changed the title Reduce Apple UI update work and compare iPhone performance Reduce Apple UI and scoring work on the main thread Oct 14, 2026
@AlexSchmidt1999

AlexSchmidt1999 commented Oct 16, 2026 •

Copy link
Copy Markdown
Owner Author

iPhone measurements, October 16

The combined build is running on the owner's iPhone, and the owner reports smoother everyday use. These figures are display-link callback timings from Today.

The comparison uses windows entirely beyond the first ten foreground seconds, with sync and training inactive, nominal thermal state and Low Power Mode off:

Source revision Windows / captures Approx. sampled seconds Late callbacks / total Late callbacks Worst interval Intervals over 33 ms
Before day-cycle scheduling change, 55335982 176 / 10 860.79 275 / 51,283 0.536% 159.6 ms 221
With day-cycle work off the main actor, f1fc4840 13 / 1 64.71 1 / 3,873 0.026% 63.4 ms 1

The median window p95 is 16.7 ms in both selections. The retained archive for the fixed version contains 31 windows across 11 foreground captures, covering approximately 123.24 seconds. Including foreground starts, it records 0.733% late callbacks, 30 intervals over 33 ms and a longest interval of 79.1 ms.

The merged October 16 installation, f88a1e12, includes the performance fixes and upstream testing revision 8e4b0c16. Its first two Today windows cover 6.29 seconds in one foreground capture: 404 callbacks, four late callbacks (0.990%), zero intervals over 33 ms and a longest interval of 29.2 ms. Installation receipts and archive process boundaries distinguish this version from the older installation that also used build number 454.

The merged iPhone Release and macOS Debug builds pass. The macOS run completes 2,351 app tests with three skipped and zero failures. The five language-setting tests pass separately in the system language.

The shared data consists of aggregate timings and counts. Raw archives, device identifiers, precise session times, preferences and health records stay local.

@AlexSchmidt1999

Copy link
Copy Markdown
Owner Author

The follow-up changes are now submitted for upstream review:

  • #2757: final day-scoped Today publication.
  • #2758: workout and Lift state in performance capture, using the pause contracts from #2759.
  • #2760: workout scoring and snapshot encoding off the main actor, with lifecycle checkpoints, retry fixtures and the Release benchmark.
  • #2803: app and tab-shell update scope, including the observed Shortcuts confirmation.
  • #2804: day-cycle HR processing off the main actor with bit-pattern and cache coverage.

The shared call sites in #2761 and #2764, and the lazy-dashboard scope in #2638, also follow the installed build.

The combined review tree reproduces installed iPhone commit f88a1e12: 1,182 of 1,183 Apple product files are byte-identical. The remaining file uses NoopMetrics.space3 for the same 12-point spacing. Both Apple builds pass locally, including iPhone widgets and Watch components. The macOS run completes 2,352 app tests with three skipped and zero failures.

This fork-only collection is superseded by those upstream PRs. The anonymized measurement report remains available in this PR conversation.

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