Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Perf/rearchitecture - #20

Merged
saksham2001 merged 6 commits into
mainfrom
perf/rearchitecture
Jun 26, 2026
Merged

saksham2001 merged 6 commits into
mainfrom
perf/rearchitecture

Conversation

@saksham2001

Copy link
Copy Markdown
Owner

Summary

The app had become painfully slow and laggy on the iPhone. I measured on a real device before changing anything. The root cause: the app was doing heavy database work while drawing the screen, over and over. Every time a screen refreshed, it re-ran an expensive ~230ms calculation that loaded the entire history of health data into memory and screens refresh hundreds of times during normal use and syncing.

This branch restructures how the app loads and shows data, following standard iOS practice:

  • Screens now just display already prepared data instead of building it on the fly. The expensive work runs once when data actually changes, not on every redraw.
  • The app asks the database for only what it needs (e.g. the last 24 hours) instead of loading everything and filtering in memory.
  • Ring sync was made calm: incoming data is now saved in batches and refreshes the UI once per batch, instead of jolting the whole app on every packet.
  • Removed a hidden bottleneck: the "Today so far" feed was quietly scanning ~12,000 rows of debug data on the main screen; it's been removed and that debug log is now capped so it can't grow forever.
  • Added a thin sync progress bar under the greeting so you can see when the ring is still sending data.

Results

  • The heavy per-screen calculation dropped from ~230ms to ~20ms, and now runs only when data changes rather than constantly.
  • A separate 284ms freeze (a leftover full-history scan in the coach feature) was eliminated.
    Screens that used to lock up are now responsive, including during sync.
  • No change to any data shown (steps, heart rate, sleep, calibration, charts, etc). The only visible change is the removed "Today so far" section and the new sync bar.

Related issues

Type of change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 📟 New / improved wearable support (BLE driver layer)
  • 🤖 Coach / LLM change (tools, prompts, orchestration)
  • 🎨 UI / DesignSystem change
  • 🧹 Refactor / chore (no behavior change)
  • 📝 Docs only
  • ⚠️ Breaking change (existing data, settings, or APIs change)

How was this tested?

This was tested on iPhone 16 Pro.

  • Added / updated unit tests (PulseLoopTests)
  • Ran the test suite locally (⌘U in Xcode)
  • Tested on a physical device with a real ring (model: Colmi R11)
  • Tested with demo data (-seedDemo YES, no hardware)
  • N/A (docs / non-code change)

Privacy & data

  • This change does not send health data off-device without explicit user action.
  • No secrets, API keys, or personal data are committed.
  • N/A

Screenshots / recordings

Checklist

  • My code follows the project's style (SwiftLint passes).
  • I ran the tests and they pass.
  • I updated docs / README where relevant.
  • I read the Contributing guide.

@saksham2001
saksham2001 merged commit 6fe428f into main Jun 26, 2026
2 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.

1 participant