Skip to content

Fix PFA caching with file_cache_only after priming from SHM - #25709

Draft
arnaud-lb wants to merge 1 commit into
php:PHP-8.6from
arnaud-lb:pfa-caching
Draft

arnaud-lb wants to merge 1 commit into
php:PHP-8.6from
arnaud-lb:pfa-caching

Conversation

@arnaud-lb

@arnaud-lb arnaud-lb commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Follow up GH-25374.

PFAs that will not be cached in SHM are cached in EG(partial_function_application_cache) instead. The cache key is concat(PFA name addr, called fun addr) with the assumption that the name is not interned, therefore has a unique address.

A file cache primed from SHM breaks this assumption: In that case the name is interned before being persisted to the file cache. On a subsequent file_cache_only request the PFA will not be SHM-cacheable, but its name will not be unique either.

Fix by using &ast->lineno as key, which is unique as long as the AST is live. Invalidate related cache entries when destroying the AST.

Fixes https://github.com/php/php-src/actions/runs/45303330074/job/138141503801#step:13:151

cc @jorgsowa

PFA that can not be cached in SHM are cached in EG(partial_function_application_cache).
The cache key is concat(PFA name addr, called fun addr) with the assumption that
PFA names are not interned, therefore have a unique address.

File cache breaks this assumption.

Fix by using &ast->lineno as key prefix, which is unique as long as the
AST is live. Invalidate related cache entries when destroying the AST.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant