python / python/cpython

Attribute cache silently disabled after 1000 class edit, leading to poor performance

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

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

interpreter-core performance type-bug
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

Bug report

Bug description:

After the changes from https://github.com/python/cpython/pull/114900 modifying a class more than 1000 times causes the attribute cache to be permanently disabled for that class. This was done to solve a crash when a class is modified more than 2**32 times ( https://github.com/python/cpython/issues/113462 )

It seems this number (1000) is too low for some real case applications.

I initially observed this as a ~50% performance regression in ERP5 performance tests when updating from python3.11 to python3.13. ERP5 is an application where classes are generated dynamically based on some configuration and some classes are modified more than 1000 times in the "normal" generation process.

This seems to also affect odoo, another ERP application, for this they resorted to using ctypes to reset the class version attribute ( https://github.com/odoo/odoo/pull/275640 )

My suggestion would be to use a much higher number before disabling the cache, 1000 is low.

CPython versions tested on:

3.13

Operating systems tested on:

Linux

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

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

はじめの一歩

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

調査の方向性

まず CPython の pull request 114900 と issue 113462 を確認し、その後、クラスが繰り返し変更された際に属性キャッシュがどのように無効化されるかを追跡します。issue に記載されている ERP5 と Odoo のケースをパフォーマンスシナリオとして使用します。報告されたリグレッションを回避しつつ、issue 113462 のクラッシュシナリオにも対処できれば完了です。

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

評価

技術スタック
python
領域
performance
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
活発
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

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

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