Container listing cache includes every .meta sidecar, doubling its size

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

メンテナーはふだん 1 日以内に返信

@edalzell がすでに取り組んでいます。

2026年10月7日 から。

  • #15610 @edalzell による — オープン

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
57/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
aws, laravel, php, redis

調査の方向性

Start with src/Assets/AssetContainerContents.php, especially all(), metaFilesIn(), ensureMissingDirectoriesExist(), add(), and forget(); trace callers in AssetContainer.php, AssetsMetaClean.php, and Asset.php. Run the relevant tests in tests/Assets/AssetContainerContentsTest.php, including root, folder, recursive, and orphan-cleanup cases. Done means cached listings exclude .meta entries while meta-file lookups and cleanup still work.

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

説明

assets performance
Bug description

AssetContainerContents::all() (src/Assets/AssetContainerContents.php:31) caches the raw recursive Flysystem listing of the container, including every .meta/*.yaml sidecar. With cache_meta enabled each asset has one, so roughly half of the cached listing is meta files that nothing reads through the listing: Asset::meta() reads them by path via disk()->get($this->metaPath()), and filteredFilesIn() filters them back out for every consumer.

Only two callers want them: metaFilesIn() (src/Assets/AssetContainerContents.php:179), used by AssetContainer::metaFiles() for assets:meta-clean and folder deletion, and Asset::metaExists() (src/Assets/Asset.php:316).

Real numbers from one site: 197,603 entries in the listing, 99,944 of them .meta yaml. The cached key is 80 MB serialized and loading it exhausts a 1 GB PHP-FPM worker.

How to reproduce
  1. S3 container with cache_meta on and a large number of assets.
  2. Warm the listing (AssetContainer::find('x')->files()).
  3. Inspect the cached asset-list-contents-<handle> value: half the entries are under .meta/.
Logs
Allowed memory size of 1073741824 bytes exhausted (tried to allocate 80320709 bytes) at vendor/laravel/framework/src/Illuminate/Redis/Connections/Connection.php:124
Environment

Statamic 6.35.0, Laravel 11, PHP 8.3, Redis cache, S3 (Flysystem v3) container.

Installation

Existing Laravel app

Additional details

Suggested fix: drop .meta paths from the cached listing in all() (filter in the remember callback, next to normalizeFlysystemAttributes()), and have metaFilesIn() list <folder>/.meta directly from the filesystem on demand instead of filtering files(). ensureMissingDirectoriesExist() should not synthesize .meta directory entries either.

Callers to check: AssetContainer::metaFiles() / metaFilesIn() (src/Assets/AssetContainer.php:376), AssetsMetaClean (src/Console/Commands/AssetsMetaClean.php:85), Asset::metaExists(), and AssetContainerContents::add() / forget() which currently insert meta paths into the list on write.

Tests in tests/Assets/AssetContainerContentsTest.php (or wherever the listing is covered): cached listing contains no .meta entries; metaFilesIn() still returns the right files for root, a folder, and recursive; assets:meta-clean still finds orphaned meta. Existing filteredFilesIn() tests should pass unchanged.

Related: #11998 moves meta off the container disk entirely, which would make this moot for sites that opt in, but the default layout still benefits. Companion issue: Asset::exists() loading the full listing.

主要言語
PHP
スター
4.9k
フォーク
647
平均マージ
1日 45分
マージ済み PR(30日)
221

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

statamic/cms のほかの issue

statamic/cms の issue をすべて見る

似ている issue

PHP の issue をもっと見る

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

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