Skip to content

perf(cache): read the immutable cache policy once per fingerprinter - #22

Merged
brianvarskonst merged 2 commits into
mainfrom
perf/memoize-immutable-policy
Oct 23, 2026
Merged

brianvarskonst merged 2 commits into
mainfrom
perf/memoize-immutable-policy

Conversation

@brianvarskonst

Copy link
Copy Markdown
Member

Finding

Review finding K-P2: mutable warm cache hits cost roughly six to eight filesystem calls per bundle (stat() per bundle composer.json and per consumed config file, scandir() per existing config directory). The documented answer is the immutable policy with a build ID, but ContainerResourceFingerprinter::immutable() re-read $_SERVER/$_ENV/getenv() and the build ID on every call: once per bundle inside fingerprint() and again in every freshness check. KernelPackageManifestCache additionally created a new fingerprinter per call.

Change

  • Memoize the policy per fingerprinter instance (only after it was determined; the missing-build-ID error still throws on every call).
  • Reuse one fingerprinter inside the discovery manifest cache.
  • README and docs/dependency-injection.md now state the per-request cost of mutable hits and recommend SYMPRESS_KERNEL_IMMUTABLE_CACHE=1 with a build ID for immutable release snapshots.

Verification

  • Existing immutable-policy tests (RuntimeCacheCompatibilityTest, CacheRequestCompatibilityTest, KernelPackageManifestCacheTest) pass; composer cs and composer static-analysis pass in a PHP 8.5.12 container.

brianvarskonst and others added 2 commits October 23, 2026 23:43
immutable() re-read the environment and the build ID for every bundle in
fingerprint() and for every freshness check, and the discovery manifest created a
new fingerprinter per call. Memoize the policy per instance and document that
immutable release snapshots should enable it to skip the per-request config and
discovery scans.
@brianvarskonst
brianvarskonst merged commit fe0107f into main Oct 23, 2026
3 checks passed
@brianvarskonst
brianvarskonst deleted the perf/memoize-immutable-policy branch October 23, 2026 22:29
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