Repository navigation
perf: frankenphp_get_vars() keeps its copy until the snapshot changes - #2827
Open
nicolas-grekas wants to merge 4 commits into
Open
nicolas-grekas wants to merge 4 commits into
nicolas-grekas wants to merge 4 commits into
Conversation
This was referenced Nov 8, 2026
nicolas-grekas
force-pushed
the
bgworker-vars-cache
branch
7 times, most recently
from
November 12, 2026 10:13
78579a7 to
014cd3b
Compare
nicolas-grekas
force-pushed
the
bgworker-vars-cache
branch
from
November 12, 2026 14:56
014cd3b to
1941f20
Compare
Each snapshot gets a generation, unique in the process. A thread keeps the copy it made, with that generation, for the rest of the request, so a read of an unchanged snapshot hands the same array out again instead of copying it. In a worker, the request is the whole run of the script.
nicolas-grekas
force-pushed
the
bgworker-vars-cache
branch
from
November 12, 2026 17:18
1941f20 to
f1e2282
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #2617, #2635 and #2636: review the last commit.
The per-request cache #2635 left out until there were numbers for it. A thread keeps the copy
frankenphp_get_vars()made, tagged with the generation of its snapshot, and hands the same array out again while the snapshot doesn't change. In a worker, the request is the whole run of the script, so each thread of an HTTP worker copies a snapshot once per publication instead of once per request. A thread drops its copies when it takes a request of anotherphp_server, since namespaces resolve per server.Reading a snapshot of 1000 small arrays goes from 240 µs to 0.05 µs once the copy is kept.