|
| 1 | +# Startup Node Update Acceleration Plan (Cross-Platform + Windows Pilot) |
| 2 | + |
| 3 | +## Context |
| 4 | + |
| 5 | +This document solidifies the optimization strategy for improving node initialization/update speed after app launch. |
| 6 | + |
| 7 | +Scope: |
| 8 | +- Frontend graph startup path (`src/frontend/app.js`) |
| 9 | +- Simulation worker tick/update path (`src/frontend/simulationWorker.js`) |
| 10 | +- Runtime profiles across desktop and mobile runtimes |
| 11 | + |
| 12 | +## 1) Problem Definition |
| 13 | + |
| 14 | +Users experience slow perceived startup because the first interactive graph frame and first stable layout arrive too late. |
| 15 | + |
| 16 | +System-level startup latency model: |
| 17 | + |
| 18 | +`T_start = T_data_prepare + T_worker_init + T_tick_transfer + T_first_interactive_render + T_settle` |
| 19 | + |
| 20 | +Primary user-facing KPIs: |
| 21 | +- `TTI` (Time to Interactive graph) |
| 22 | +- `TFS` (Time to First Stable readable layout) |
| 23 | +- Startup frame-drop rate in first 3 seconds |
| 24 | + |
| 25 | +## 2) Hypotheses |
| 26 | + |
| 27 | +1. Full-payload tick transfer (`all nodes every tick`) is a major startup bottleneck. |
| 28 | +2. Full edge rendering in the first 0.3–1.2s adds heavy cost with limited user value. |
| 29 | +3. Missing persisted layout snapshots forces repeated cold-start relaxation. |
| 30 | +4. Platform runtimes (Windows/macOS/Android WebView) need different startup limits. |
| 31 | + |
| 32 | +## 3) Constraints and Unknowns |
| 33 | + |
| 34 | +### Constraints |
| 35 | +- Must keep behavior consistent across Tauri desktop and APK runtime. |
| 36 | +- Must not break existing focus/highlight/path mode interactions. |
| 37 | +- Must remain rollback-safe with feature flags. |
| 38 | + |
| 39 | +### Unknowns |
| 40 | +- Current P50/P95 startup metrics are not centrally collected. |
| 41 | +- Device capability distribution per platform is not yet quantified. |
| 42 | + |
| 43 | +## 4) Subproblem Decomposition |
| 44 | + |
| 45 | +1. Data preparation cost on main thread. |
| 46 | +2. Worker initialization + simulation settle speed. |
| 47 | +3. Worker→UI transfer volume and frequency. |
| 48 | +4. Startup render strategy (nodes-first vs edges-first). |
| 49 | +5. Warm-start memory (layout snapshot persistence). |
| 50 | + |
| 51 | +## 5) Three Candidate Options |
| 52 | + |
| 53 | +### Option A: Quick Throttle + Staged Rendering |
| 54 | +- Add startup edge delay. |
| 55 | +- Cap tick frequency. |
| 56 | +- Keep protocol unchanged. |
| 57 | + |
| 58 | +Expected gain: medium (fast to deliver, low risk). |
| 59 | + |
| 60 | +### Option B: Balanced Target (Recommended) |
| 61 | +- Option A + |
| 62 | +- Add persisted layout snapshots (warm start). |
| 63 | +- Add delta tick transfer strategy (or reduced-frequency transfer). |
| 64 | +- Add platform runtime profiles. |
| 65 | + |
| 66 | +Expected gain: high with manageable risk. |
| 67 | + |
| 68 | +### Option C: Deep Architecture Refactor |
| 69 | +- Shared memory + binary graph pipeline + renderer overhaul. |
| 70 | + |
| 71 | +Expected gain: highest, but high risk and long timeline. |
| 72 | + |
| 73 | +## 6) Comparison |
| 74 | + |
| 75 | +| Dimension | Option A | Option B (Recommended) | Option C | |
| 76 | +|---|---|---|---| |
| 77 | +| Delivery speed | Fast | Medium | Slow | |
| 78 | +| Risk | Low | Medium | High | |
| 79 | +| Cold-start improvement | Medium | High | Very high | |
| 80 | +| Warm-start improvement | Low | Very high | Very high | |
| 81 | +| Multi-platform feasibility (v1) | High | High | Medium | |
| 82 | + |
| 83 | +## 7) Chosen Direction |
| 84 | + |
| 85 | +Choose **Option B**, delivered in phases with rollback switches. |
| 86 | + |
| 87 | +Reason: |
| 88 | +- Strong performance upside without architectural disruption. |
| 89 | +- Explicitly supports runtime profile tuning per platform. |
| 90 | +- Suitable for a Windows-first pilot before broader rollout. |
| 91 | + |
| 92 | +## 8) Execution Plan |
| 93 | + |
| 94 | +### Phase 0: Instrumentation Baseline |
| 95 | +- Add startup timeline logs: |
| 96 | + - `T0 app_boot` |
| 97 | + - `T1 graph_preprocessed` |
| 98 | + - `T2 worker_init_sent` |
| 99 | + - `T3 first_tick_received` |
| 100 | + - `T4 first_interactive_render` |
| 101 | + - `T5 stable_layout` |
| 102 | + |
| 103 | +### Phase 1: Windows Pilot v1 (low-risk) |
| 104 | +- Add runtime startup profile selection. |
| 105 | +- Add worker tick rate cap. |
| 106 | +- Add startup edge render delay. |
| 107 | +- Add startup link render cap (optional guard). |
| 108 | + |
| 109 | +### Phase 2: Warm Start |
| 110 | +- Persist per-graph layout snapshot keyed by graph fingerprint. |
| 111 | +- Restore snapshot on startup and run low-alpha stabilization. |
| 112 | + |
| 113 | +### Phase 3: Delta Transfer |
| 114 | +- Reduce transfer volume via delta-only tick payload or lower-frequency full payload. |
| 115 | + |
| 116 | +## 9) Risk Points and Mitigation |
| 117 | + |
| 118 | +1. Stale snapshot mismatch: |
| 119 | + - Mitigation: strict graph fingerprint validation + fallback to cold start. |
| 120 | +2. Over-throttling in low-end devices: |
| 121 | + - Mitigation: per-platform profile overrides and fast rollback. |
| 122 | +3. Rendering incompleteness perception when edges are delayed: |
| 123 | + - Mitigation: short delay window + status hint + progressive edge restore. |
| 124 | + |
| 125 | +## 10) v1 Optimization Spec (Windows Pilot) |
| 126 | + |
| 127 | +### Runtime Profile (pilot default) |
| 128 | +- Profile ID: `desktop_windows_pilot` |
| 129 | +- Worker tick cap: `24–30 FPS` |
| 130 | +- Edge render delay: `~400ms` |
| 131 | +- Startup partial edge cap window: `first 1500ms` |
| 132 | + |
| 133 | +### Success Criteria |
| 134 | +- `TTI` improvement >= 30% vs baseline median. |
| 135 | +- `TFS` improvement >= 20% vs baseline median. |
| 136 | +- Startup 3s frame-drop reduction >= 30%. |
| 137 | + |
| 138 | +### Rollback Gates |
| 139 | +- Any startup regression > 10% on P95. |
| 140 | +- Any reproducible interaction regression (focus/path mode/reader). |
| 141 | + |
0 commit comments