BUG: FIREDRAKE_CACHE_DIR is ignored by loopy's caches when loopy is imported before firedrake
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start with firedrake/configuration.py and setup_cache_dirs(), then trace when loopy and pytools create their persistent caches during imports; the reproduction names loopy.codegen.code_gen_cache and also exercises imports through tsfc. Run the supplied three import-order cases and check whether every cache directory is under FIREDRAKE_CACHE_DIR or a warning is issued when a cache was created earlier.
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
FIREDRAKE_CACHE_DIR does not apply to loopy's persistent caches if loopy is imported before firedrake, directly or through tsfc. setup_cache_dirs() (firedrake/configuration.py, from #5400) sets XDG_CACHE_HOME during import firedrake. But loopy creates its PersistentDicts at module import (e.g. loopy.codegen.code_gen_cache), and pytools resolves the container directory in __init__. So the caches stay in ~/.cache/pytools for the whole process, with no warning. The PyOP2 and TSFC caches do move to FIREDRAKE_CACHE_DIR.
Steps to Reproduce
for first in "import firedrake; import loopy" "import loopy; import firedrake" "import tsfc; import firedrake"; do
echo "== $first"
env -u XDG_CACHE_HOME FIREDRAKE_CACHE_DIR=$(mktemp -d) python -c "
$first
from loopy.codegen import code_gen_cache
print(code_gen_cache.container_dir)"
done
Output:
== import firedrake; import loopy
/tmp/tmp.wglcRkE7wS/pytools
== import loopy; import firedrake
/home/<user>/.cache/pytools
== import tsfc; import firedrake
/home/<user>/.cache/pytools
Expected behavior
All caches live under FIREDRAKE_CACHE_DIR whatever the import order. Failing that, warn when loopy's caches were already created at another location.
Additional Info
Found while benchmarking kernels from two FIAT branches with a fresh FIREDRAKE_CACHE_DIR for each. The script imported loopy first, so loopy's code-gen cache was still shared. Kernels already in that cache from earlier runs looked 10x faster to generate (0.9 s vs ~10 s), and the gap went away once XDG_CACHE_HOME was also set. Related: #2310.
Possible fixes: call setup_cache_dirs() when tsfc and pyop2 are imported too, and warn in setup_cache_dirs() if XDG_CACHE_HOME was unset but "loopy" in sys.modules.
Environment:
- OS: Linux
- Python 3.14.4, firedrake
mainat 2093d46b499, loopy 2025.2, pytools 2026.1.1 XDG_CACHE_HOMEunset,FIREDRAKE_CACHE_DIRset per run
- 主要言語
- Python
- スター
- 684
- フォーク
- 204
- 平均マージ
- 4日 14時間
- マージ済み PR(30日)
- 46
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
firedrakeproject/firedrake のほかの issue
-
BUG: NonlinearVariationalSolver errors with adj_kwargs対応中かも @dham が 151 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
firedrakeproject/firedrake#5186 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
firedrakeproject/firedrake#5091 ·
メンテナーはふだん 1 日以内に返信
-
documentation
難易度 1/5 1〜3時間 初心者へのやさしさ 82/100
firedrakeproject/firedrake#3556 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 22/100
firedrakeproject/firedrake#5644 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Function.assign on a subset fails with a Constant, a Real Function or abs in the expression対応中かも @connorjward が 2 日前に担当しました。 オープン
firedrakeproject/firedrake#5643 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
firedrakeproject/firedrake の issue をすべて見る
似ている issue
-
area:cli area:security bug priority:medium
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
docs pydanty:is-working
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
pydantic/pydantic-ai#13563 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
NCATSTranslator/Babel#1204 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
alltheplaces/alltheplaces#20570 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
sio2project/oioioi#981 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信