php / php/php-src

Opcache prevents file from being added to realpath cache?

オープン
#15,030 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Bug Extension: opcache Status: Needs Triage
主要言語
C
スター
40.4k
フォーク
8.1k
平均マージ
2日 13時間
マージ済み PR(30日)
96

説明

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

opcache の検証を有効にした状態で、require_once、realpath_cache_get()、is_file()、realpath()、clearstatcache() を使用し、php-fpm 上で foo.php と bar.php による動作を再現する。worker プロセス間で結果を比較し、opcache と realpath-cache の相互作用を追跡する。異なるキャッシュ内容とキャッシュの再投入に失敗する理由を説明できるか、確認済みの修正を特定できれば完了とする。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
c, php
領域
backend, performance
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
30/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。