Skip to content

perf: reduce Activity memory and repeated team and store work - #1925

Merged
santoshkumarradha merged 4 commits into
devfrom
fix/skills-guided-efficiency
Oct 24, 2026
Merged

santoshkumarradha merged 4 commits into
devfrom
fix/skills-guided-efficiency

Conversation

@santoshkumarradha

@santoshkumarradha santoshkumarradha commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

What changed

Three existing paths did repeated work as histories and teams grew:

  • Activity layouts copied both full task and conversation records into every line. Compact lines now refer to stable immutable task slots, while conversation overlays retain independent copies.
  • Disbanding a team asked for a reporting home once per membership, repeatedly scanning the entire membership list. It now reuses the existing batched Homes reading before mutation.
  • Opening a settled store checked for a missing session once per message. It now probes distinct nonempty session IDs through the existing covering index, preserving discovery of legacy rows introduced after an earlier settled open.

No new dependency, persistent cache, schema, setting, command or user-facing behavior is introduced. Contributor guidance records the requested Matt Pocock diagnosis, TDD, module-design and two-axis review practices; delegates receive the same expectations.

How it was checked

Paired runs compare dev 127eb40fa with this change, using the same fixture and built application. Go 1.26.5, linux/arm64. Actual terminal timings include input delivery and observed screen output; fixture setup is separate. Latency scenarios reject model requests.

Actual terminal workload Before After
Activity, 5,120 tasks: median hover 67 ms 61 ms
Same Activity: p95 hover 93 ms 69 ms
Disband among 10,000 memberships: confirmation to saved notice 1,015 ms 353 ms
Disband among 40,000 memberships: confirmation to saved notice 27,871 ms 1,252 ms
Startup, settled 1m-message/1,000-session store: median first interactive surface 597 ms 202 ms

Hover uses 12 alternating visible row targets. Startup uses three launches with 5 ms observation polling; its clock includes launch preparation, while the 23-second mock-database construction is excluded. The isolated startup profile keeps memory extraction off and exercises the normal conversation-search store open; it does not measure every optional startup setting. Disband figures are single diagnostic observations at each size and include persistence and redraw work. Activity fixture setup took 32–36 ms; team fixture setup was approximately 0.6 seconds at 10,000 memberships and 2–3 seconds at 40,000. These are reproducible observations, not universal latency gates.

Code-interface workload Before After
Activity paint, 5,120 tasks: allocated bytes 12.48 MB 2.05 MB
Same body benchmark: diagnostic time 6.87 ms 3.66 ms
History rebuild plus layout: allocated bytes 49.09 MB 38.67 MB
Public store Open/Close, 100k messages 53.63 ms 13.10 ms
Public store Open/Close, 1m messages 504.64 ms 81.34 ms

Activity's 4 MiB real-body allocation regression fails on the unchanged baseline at 12,479,576 bytes and passes with this change. Independent overlay copies add 40 small allocations per paint; total allocated bytes fall 83.5%. Stripped binaries built with the same target/flags remain exactly 67,764,489 bytes; module dependencies are unchanged.

Public Disband benchmarks with managers present in their rosters measured 168 → 3.35 ms at 10,000 memberships and 2,200 → 11.88 ms at 40,000 (three iterations; fixture cloning excluded). Disbanding trades additional transient indexed storage (approximately 12 MB at 40,000 memberships) for eliminating repeated scans. This storage is discarded after the mutation. Store reopening still scans message IDs; this does not claim constant-time opening.

Functional checks preserve nested folds, filtering, phone/column geometry, live task ownership, recursive disbanding, unaffected shared memberships and history. Store tests exercise public Open → Sessions behavior, preserving titles/tags/surfaces/timestamps, unusual IDs and backfill after a later legacy writer. Focused race checks passed for the changed store, team and Activity paths.

The live 120-member workflow passed manager preview, pointer burst, physical scrolling, resize and opening the clicked member. All 5 completed model requests were verified as OpenRouter deepseek/deepseek-v4.1-flash, including auxiliary calls. Navigation/startup measurements made zero model calls.

make pr-ready passed: every selected test passed on its first run. All final-head GitHub gates passed, including build, vet, formatting, manual/law checks and the touched backend/TUI suites.

After make build, reproduce with:

go test ./internal/tui3 -run '^$' -bench '^(BenchmarkActivityScaleFrame|BenchmarkTasksConversationHistory)$' -benchtime=100x -benchmem -count=1
go test ./internal/store -run '^$' -bench '^BenchmarkOpenSettledSessions$' -benchtime=3x -benchmem -count=1
go test ./internal/teams -run '^$' -bench '^BenchmarkDisbandScale$' -benchtime=3x -benchmem -count=1
CODEAF_E2E_MODEL=deepseek/deepseek-v4.1-flash go test -tags e2e ./internal/e2e -run '^(TestActivityScaleTerminalLatency|TestTeamsDisbandScaleTerminalLatency|TestSettledStoreTerminalStartup)$' -count=1 -v -timeout 8m
CODEAF_E2E_MODEL=deepseek/deepseek-v4.1-flash CODEAF_BASE_URL=https://openrouter.ai/api/v1 go test -tags e2e ./internal/e2e -run '^TestTeamsLargeOverviewPointerAndLivePreview$' -count=1 -v -timeout 8m

Capacity tests use mock records and an endpoint that rejects chat calls. Only the live workflow requires a configured OpenRouter key. Use identical test/benchmark fixtures with each revision for comparisons. The capacity Activity scenario now quits normally before fixture removal.

Standards

Independent review: 0 findings. Stable task slots, independently copied conversation overlays and kind-gated payload access preserve layout ownership. Existing modules and indexes are reused; no speculative abstraction was added.

Spec

Independent review: 0 findings. The changes match the requested efficiency/modularity cleanup and retain existing user behavior and public interfaces. Actual-terminal and exact-model acceptance passed.

Checklist

  • Numbered change entry added after PR allocation.
  • Performance rules and allocation budget documented in PERF.md.
  • Only task-owned paths staged; no evidence directories committed.
  • Santosh reviewed the measurements and authorized merging.
  • Merged to dev as 29e3f74eb; the merged build and actual-terminal Activity check passed (median 52 ms, p95 62 ms; zero model calls).

@santoshkumarradha
santoshkumarradha marked this pull request as ready for review October 24, 2026 18:02
@santoshkumarradha
santoshkumarradha merged commit 29e3f74 into dev Oct 24, 2026
6 checks passed
@santoshkumarradha
santoshkumarradha deleted the fix/skills-guided-efficiency branch October 24, 2026 18:05
santoshkumarradha added a commit that referenced this pull request Oct 24, 2026
* Reduce repeated work in Activity layouts, team disbanding and store reopening

* Benchmark disbanding with managers present in real rosters

* Document efficiency measurements and Activity allocation budget

* Document efficiency fixes and coding workflow for PR 1925
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