Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(mobile): yield to UI during shell cache encoding #12117

Mergedjuliusmarmingemerged 1 commit intoperf/mobile-thread-list-renders fromrefs/pull/12117/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

Encoding the mobile shell cache blocks the JavaScript thread for hundreds of milliseconds on large environments. Throttling reduces how often this happens, but each remaining encode still stalls input and JS-driven rendering.

Keep the existing schema validation and transforms, and yield through a cancellable native timer after every 32 encoded thread rows. The encoder is compiled once; the cache format, decoder, and final SQLite write are unchanged. Only mobile shell saves use this scheduling. Web, desktop, thread-detail caches, and server-config caches are unchanged.

A direct replay through the production encoder on Hermes used the same captured 761-thread shell and three warm trials per version. Maximum timer gaps fell from 355–367 ms to 26–35 ms, with identical JSON in every trial. Total background encoding took longer, 500–525 ms versus 355–367 ms. Incoming network events were buffered, allowed pending cache work to drain, then replayed after the experiment. A prototype trial had a 72 ms gap; the batch size does not guarantee a fixed frame budget. Project encoding and final JSON.stringify remain synchronous.

Before and after timer gaps and total encoding time

Nine focused cache-store tests pass, covering exact original output with dates/nulls/normalization/unknown-field stripping, validation failure after a yield, and cancellation of the pending host timer. Mobile typecheck and targeted lint/format pass. Source review found no blockers. Measurements used an iOS Simulator Debug development client with production JavaScript; they are not physical-device frame-rate results.

Final-bundle thread-scrolling smoke test, not a matched latency comparison:

Final simulator thread scrolling

Profiling methods, results, and limitations.

Model: GPT-6 Astra. Harness: Codex.

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. Thread transfer impact

      ⚠️ The latest CI run did not produce a thread transfer result for 00587f6.

      This comment will update automatically after the next completed run.

    3. Approvability

      Verdict: Approved at 00587f6

      Macroscope's review found this PR approvable — This is a bounded mobile performance change that yields during large shell-cache encodes without changing serialized data, validation, decoding, or persistence behavior. The new scheduling and cancellation logic is isolated and covered by focused tests.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. juliusmarminge merged this729c6ff

    5. juliusmarminge closed this

Sign in to join this conversation.