Skip to content

perf(store): reduce scoped-list allocations and skip unused artifact clones - #2338

Merged
DeliciousBuding merged 2 commits into
masterfrom
perf/scoped-store-lists
Sep 6, 2026
Merged

perf(store): reduce scoped-list allocations and skip unused artifact clones#2338
DeliciousBuding merged 2 commits into
masterfrom
perf/scoped-store-lists

Conversation

@DeliciousBuding

@DeliciousBuding DeliciousBuding commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

Closes #2337.

  • Add a reproducible real Store.ListRuns / Store.ListArtifacts benchmark covering 100/1,000 resident rows and missing/sparse/dense/all scopes.
  • Stage small filtered results locally and allocate their exact result size; overflow still allocates once for the dense case. Preserve one predicate invocation per row and insertion order.
  • Clone artifact content-source metadata only after scope selection, while preserving detached returned values and non-nil empty results. Extend the existing query behavior/ownership tests.

Measured result and limits

At 1,000 resident rows, ten-run results allocate 1,792 B instead of about 172 KB. Ten-artifact results allocate 1,888 B / 11 allocations instead of 179,072 B / 1,001 allocations; missing artifact queries have zero allocations instead of 1,001. Dense/all result allocation is unchanged.

This is not a universal latency claim: after an initial +12.4% unfiltered-run timing, interleaved before/after controls showed overlapping ranges and +2.7%/+5.4% dense/all medians at 1,000 rows. The allocation improvement is retained with this explicit tradeoff; no production request distribution, RSS, retained heap or end-to-end throughput was measured.

Validation

Passed on delivery files:

  • Linux/WSL2 Go 1.26.5: CGO_ENABLED=1 go test -race -p 2 ./internal/store -count=1 -cpu=4 -timeout=10m.
  • Windows: CGO_ENABLED=0 go test -p 2 ./internal/store -count=1 -cpu=4 -timeout=10m, go vet -p 2 ./internal/store, staticcheck ./internal/store (2026.1).
  • Same real-facade fixture, five repetitions per case with allocation and ordered-ID assertions. Generic compiler escape diagnostics and git diff --check.
  • Behavioral assertions cover one predicate visit, interleaved results around the small/dense transition, insertion order, non-nil empty slices, empty scope, nil content sources and mutation isolation. No timing thresholds or fixed-capacity tests.

All seven required checks passed for 5ab5fca23881e77031d093ea9bff5a35cc1202ec: validate, go-edge, go-hub, windows-go, windows-frontend, backend-required, frontend-required (CI run). The backend integration and fixture E2E lanes passed; frontend/native/real-E2E lanes were path-filtered or dispatch-only and skipped as reported by CI. CodeRabbit explicitly skipped review and is not counted as code review. L3 real-login/model and L4 packaged/release validation are not claimed.

Scope / hygiene

No API/schema/SQL/pool/index/debounce/runtime configuration change, new CI gate or production data. Existing architecture docs remain correct. Temporary comparison implementations were archived on the issue and removed from the worktree; only the benchmark, production helper and meaningful regressions remain. No runtime synchronization, rebuild, restart or deployment is included.

DeliciousBuding and others added 2 commits September 6, 2026 15:41
Refs #2337. Add real Store facade controls before choosing allocation changes.

Co-authored-by: Codex <codex@vectorcontrol.tech>
Refs #2337. Preserve insertion order, single-pass predicates, non-nil empty results and detached artifact metadata. Measure dense/all controls alongside sparse wins.

Co-authored-by: Codex <codex@vectorcontrol.tech>
@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: e84a9694-8f4e-4cde-bc26-1d059e093659

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@DeliciousBuding
DeliciousBuding merged commit 6fe72fd into master Sep 6, 2026
41 checks passed
@DeliciousBuding
DeliciousBuding deleted the perf/scoped-store-lists branch September 6, 2026 08:54
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.

perf(store): measure scoped-list allocation and avoid unnecessary artifact cloning

1 participant