Skip to content

perf: compute the settings fingerprint once per settings version - #175

Merged
dnnsjsk merged 1 commit into
inline0:mainfrom
Contributolo:perf/fingerprint-memo
Oct 24, 2026
Merged

dnnsjsk merged 1 commit into
inline0:mainfrom
Contributolo:perf/fingerprint-memo

Conversation

@Contributolo

Copy link
Copy Markdown
Collaborator

Settings::fingerprint() JSON-encodes all resolved settings and hashes them on every call. Runtime_Context asks for it when it resolves output paths, so an uncached page view called it 69 times on a home page with 6 blocks (0.75 ms) and 21 times on a page with one block (0.25 ms).

The fingerprint is now kept together with the settings array it was computed from. While the settings are unchanged, === on the same array in memory returns immediately, so encoding and hashing run once per settings version. Any change still produces a new fingerprint: a reload builds a new array, a direct write (as some tests do through reflection) separates the array, and reset() clears the cached value.

Measured on WordPress 7.1.3, PHP 8.4 with OPcache, forked in-process requests, ABAB, n=20, medians:

Page Before After
Home (6 blocks) 50.9 ms 50.1 / 50.4 ms
One block 47.3 ms 46.7 / 46.9 ms

Independent of #173 (which removes some of the calls by reading asset outputs from the runtime cache) and #174.

Tests: SettingsTest covers the value (hash of get_all()), repeated calls, a direct write to the settings and a reload through a settings filter. The unit suite shows the same results with and without the change; phpcs on settings.php, PHPStan and npm run check pass.

Runtime_Context asks for Settings::fingerprint() for every resolved output
path, so a page with a few blocks encoded all settings as JSON and hashed
them dozens of times per request. The fingerprint is now kept together
with the settings array it was computed from. Comparing the two is
constant time while the settings are unchanged and still detects every
change, including reloads and direct writes; reset() clears it.
@dnnsjsk
dnnsjsk merged commit 9617373 into inline0:main Oct 24, 2026
@dnnsjsk

dnnsjsk commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Merged and released in Blockstudio 7.7.8, with the reviewed implementation and regression coverage. The release commit passed all 20 CI and distribution checks before publication.

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.

2 participants