php / php/php-src

Opcache prevents file from being added to realpath cache?

Ouverte
#15,030 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Bug Extension: opcache Status: Needs Triage
Langage dominant
C
Étoiles
40.4k
Forks
8.2k
Merge moyen
2 j 13 h
PR mergées (30 j)
96

Description

Description

realpath cache is a per process cache
opcache is a shared cache

opcache is enabled with validation 2 seconds

foo.php contains:

<?php $t = time();

bar.php contains:

$path = '../foo.php';
require_once $path;
echo $t;

var_dump( realpath_cache_get() );

with php-fpm request bar.php multiple times.

when checking realpath_cache_get() we see foo.php is added to the realpath cache
as soon as opcache has cached this require once foo.php, foo.php is removed from realpath cache - for most worker processes.

Questions:

  1. opcache seems to be able to clear the realpath cache for some (?) workers - how is opcache able to do that? or does this happen on every request separately? (how come that foo.php is still in realpath cache for some workers though?)

  2. no matter what (is_file, realpath,...) calls with ../foo.php will never make it populate realpath cache again with this file, once it's in opcache - even when calling clearstatcache before it because the file is potentially deleted beforehand. It always seems to fetch the full path again from disk instead of storing it in realpath?

PHP Version

8.3

Operating System

No response

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Reproduire le comportement avec foo.php et bar.php sous php-fpm, en utilisant require_once, realpath_cache_get(), is_file(), realpath() et clearstatcache(), avec la validation de opcache activée. Comparer les résultats entre les processus worker et suivre l’interaction entre opcache et realpath-cache ; le travail est considéré comme terminé lorsque le contenu différent des caches et l’échec du repeuplement du cache sont expliqués, ou qu’un correctif confirmé est identifié.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
c, php
Domaine
backend, performance
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
30/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.