Skip to content

Large-repo render hang: architectural perf pass (profile-first) #75

Description

@thalida

Spun out of PR #72. For a Linux-scale repo (~80k files and 100k+ commits) the world rendering hangs. PR #72 shipped the safe/bounded wins; this tracks the architectural work that needs a measured approach.

Already done in #72

  • Media image fetches batchedPOST /api/files (one round trip per ~32 images instead of one GET per billboard).
  • Firefly orb cap (MAX_FIREFLY_ORBS = 200k) — orbs = trees × authors-per-commit, previously uncapped.

Already optimized (verified, no action needed)

  • Icon atlas is memoized by tree_signature (city/state/index.ts:233).
  • Trees capped at TREE_MAX_CELLS = 100k (city/components/trees/treePlacement.ts:97).
  • Layout runs off-thread; buildings are instanced (one InstancedMesh per cell); decoration defers past paint.

Remaining bottlenecks to profile + fix (ranked)

  1. Worker payload clone — the full manifest structured-clones into the layout worker and ~80k building objects clone back out (city/layout/index.ts). The treeDecorationProfile bench already simulates full-vs-slim clone. Explore a geometry-only return payload (the main thread re-associates file/dir by path).
  2. Picker pickables — rebuilt as a flat list of all ~80k buildings + trees on every cityRevision/decorationRevision bump (city/interaction/picker.ts). No spatial index / distance LOD; raycasts test everything.
  3. Street-label textures — one canvas + measureText + GPU upload per street, no LOD (skip tiny/short streets; cache by label text).
  4. bbox computed — O(buildings+streets) with per-point Vector3 allocations (city/state/index.ts); reuse scratch vectors, early-exit on reuse applies.

Approach

Profile first. Build a headless large-repo bench (80k files / 100k commits) that times each apply phase (layout return, buildings assembly, picker refresh, bbox, decoration), so we fix the phase that actually dominates with a before/after number — rather than guessing. The golden bench only covers the decoration pass, so any change to the buildings/picker paths needs its own guard.

Context: the full audit lives in the PR #72 thread.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestnice-to-haveDeferred-but-real work; not urgent

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions