Skip to content

perf(server): reduce retained observation allocation size (from upstream #2149) - #3

Open
A13xB0 wants to merge 2 commits into
masterfrom
upstream/pr-2149
Open

A13xB0 wants to merge 2 commits into
masterfrom
upstream/pr-2149

Conversation

@A13xB0

@A13xB0 A13xB0 commented Oct 9, 2026

Copy link
Copy Markdown
Owner

From upstream

This PR brings in upstream Kpa-clawbot/CoreScope#2149 by @n30nex, unchanged. It is open upstream at the time of writing and addresses upstream issue Kpa-clawbot#2148. Both commits are cherry-picked with -x, so each commit message names its upstream commit:

  • 532436e6 test: respect native permissions and fixture release context (upstream 2403d28f)
  • c663f6a7 perf(server): reduce retained observation allocation size (upstream 1b66d388)

They applied to our master (3e21b17) with no conflicts. Nothing in this PR was written for the fork; if upstream changes Kpa-clawbot#2149 before merging, this PR should be refreshed from it.

What it changes

StoreObs (one per retained observation) had tsParseOnce sync.Once between two fields, and the padding put the struct at 200 bytes, so each observation landed in Go's 208-byte allocation class. Moving tsParsed time.Time ahead of the sync.Once packs it to 192 bytes, the 192-byte class. The second commit makes three tests portable (Windows symlink privilege, POSIX file modes, release-notes fixture context).

Performance

Upstream's own BenchmarkStoreObsRetainedMemory (100k observations), 10 runs each on master and on this branch:

                          │   master    │            this PR             │
                          │   sec/op    │   sec/op     vs base           │
StoreObsRetainedMemory-12   15.71m ± 1%   15.69m ± 2%  ~ (p=0.579 n=10)

                          │ retained-B/obs │ retained-B/obs  vs base           │
StoreObsRetainedMemory-12        208.0 ± 0%       192.0 ± 0%  -7.69% (p=0.000 n=10)

Scale on our deployment: production holds about 167k observations in memory, so this saves about 2.7 MB of heap there. It is a small, free win; the larger memory items are tracked separately (subpath index, analytics recompute allocations).

Tests

  • TestStoreObsMemoryFootprint (from upstream) fails if StoreObs grows past 192 bytes on 64-bit targets.
  • make test: 16 of 16 modules pass.
  • Frontend suites: 194 of 194 pass. On our master, tests/unit/test-issue-1956-release-routing.js failed locally because it expected CI's GITHUB_REF_NAME; the second commit fixes that, so this branch is the first where every local suite passes.

Review notes

  • Pure field reorder; no behaviour change. sync.Once must not be copied after first use, and nothing copies StoreObs by value (it is always held by pointer).
  • Test changes come from upstream as-is.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KaR4xu8gVykQBkH8yG8m6H

@A13xB0 A13xB0 added live: pre-prod In the image running on CoreScope pre-production upstream: someone else's PR Tracks another author's upstream PR, brought in for testing upstream: in review Open as a PR on Kpa-clawbot/CoreScope, waiting on review labels Oct 10, 2026
@A13xB0 A13xB0 added upstream: superseded Upstream solved this another way (another PR merged); not needed and removed live: pre-prod In the image running on CoreScope pre-production upstream: in review Open as a PR on Kpa-clawbot/CoreScope, waiting on review labels Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

upstream: someone else's PR Tracks another author's upstream PR, brought in for testing upstream: superseded Upstream solved this another way (another PR merged); not needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants