Skip to content

perf(store-runtime): release publish-time memory when the build permit is released #830

Description

@ScriptedAlchemy

Problem

The #803 publication coordination slice serializes corpus-sized manifest builds per project publication shard (measured: peak overlapping builds = 1 at 1/2/4/8 scopes). Peak process RSS nevertheless grows linearly with the number of published worktree scopes, because memory acquired while a scope publishes is retained after that scope releases the build permit.

Measured with concurrent_worktree_scopes_publish_with_one_corpus_build_and_bounded_rss (600-file / 7,200-function corpus, one project, N distinct worktree generations, publish_verified_snapshot concurrently):

scopes RSS before publish sampled peak during publish growth growth / scope
1 0.27 GB 0.90 GB 0.64 GB 0.64 GB
2 0.39 GB 1.64 GB 1.25 GB 0.62 GB
4 0.59 GB 3.00 GB 2.41 GB 0.60 GB
8 1.03 GB 5.77 GB 4.74 GB 0.59 GB

Builds do not overlap (wall ≈ N × single publish), so this is retained published state per RetainedCodeGraphRuntimeV1/scope (staged relational projection, replay/materialization buffers, or the seated generation), not concurrent build memory. ~0.6 GB for a 7,200-function generation is also far above the sealed generation's on-disk size, so part of it is likely transient build memory that is never returned to the allocator or is held by an Arc that outlives publication.

Required design

  • Attribute the per-scope retention with Hotpath allocation tracking across publish_verified_snapshot (manifest projection, relational staging, sealed copy, replay pool) and identify what outlives the permit.
  • Release publish-time buffers when the permit is released; retain only what serving needs, and make retained-per-scope memory proportional to the served index, not to the build.
  • Keep the perf(store-runtime): coordinate graph publication per project #803 lock cell and lock order unchanged.

Acceptance evidence

  • Re-run the 1/2/4/8-scope harness: peak RSS growth after the first scope should be bounded by the served-state size per scope, with the measurement in the closing comment.
  • Existing publication, journal-resume, cancellation, and rollback suites unchanged.

Refs #803 (measurement), PR #707 (9de84bc8a harness).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions