Slow page loads with many entities: getEntries() checks entities and rights container by container on every request
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 領域
- backend, performance
調査の方向性
Start at plugin_init_fields() and PluginFieldsContainer::getEntries(), then inspect getSonsOf() and PluginFieldsProfile::getRightOnContainer() to trace the per-container work. The issue describes the target behavior: compute visibility once per entity and fetch profile rights for visible containers in one query. Compare results across entities and profiles, then measure getEntries(); done means unchanged visibility and rights with lower request time.
索引モデルが issue の本文から書いたものです。
説明
Code of Conduct
- I agree to follow this project's Code of Conduct
Is there an existing issue for this?
- I have searched the existing issues
GLPI Version
12.0.1 (same code in the plugin for GLPI 11)
Plugin version
1.25.1 (same code in 1.24.7 on 11.0/bugfixes)
Bug description
plugin_init_fields() calls PluginFieldsContainer::getEntries() on every authenticated request, to register the container tabs. For each active container, getEntries():
- if the container entity is not one of the active entities, calls
getSonsOf()on the container entity and intersects the result with$_SESSION['glpiactiveentities']usingarray_intersect(); - runs one SQL query to get the right of the active profile on the container (
PluginFieldsProfile::getRightOnContainer()).
With containers defined on the root entity (recursive) and users working with many active entities, this becomes expensive. Measured on our instance (22 active containers, all on the root entity, 5591 entities, users with up to 1168 or 5591 active entities): getEntries() takes about 47 ms, on every request, including lightweight AJAX calls (ajax/actorinformation.php, ajax/comments.php, ...). array_intersect() alone costs about 3 ms per container, and the same getSonsOf() result is intersected 22 times.
Since a ticket page sends many AJAX calls at once and they are processed one at a time per session (session lock), this cost adds up to several seconds on the last calls.
Steps To reproduce
- Create about 20 active tab containers on the root entity, recursive.
- Log in with a profile and active entities covering a large entity tree (thousands of entities).
- Measure
PluginFieldsContainer::getEntries(), or the response time of any AJAX endpoint.
Anything else?
This is the same kind of issue as the one fixed in #1187 for findContainer() / findAllContainers(), but on getEntries(), which runs on every request. A fix is proposed in the linked PR: visibility is computed once per entity, and the rights of the profile on all visible containers are read in a single query. Results are unchanged: on our instance, identical for 39 real user/profile combinations and for the 700 profile × container pairs, and getEntries() goes from about 47 ms to about 2 ms (AJAX call from about 240 ms to about 190 ms).
findAllContainers() still calls getRightOnContainer() in a loop and could reuse the same batched query, but it is not called on every request, so it is left out of the PR.
- 主要言語
- PHP
- スター
- 122
- フォーク
- 85
- 平均マージ
- 1日 15時間
- マージ済み PR(30日)
- 20
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
pluginsGLPI/fields のほかの issue
-
Value lookups by items_id do not use the itemtype index and scan the whole values table対応中かも @marifex が 26 日前に担当しました。 オープンStale
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
pluginsGLPI/fields#1310 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[GLPI 11] GenericObject plugin cannot be migrated. Please update it to the latest version対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 30/100
pluginsGLPI/fields#1015 ·
メンテナーはふだん 1 日以内に返信
pluginsGLPI/fields の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
pluginsGLPI/carbon#396 ·
-
[BUG] Bundle products lose their price in RSS feeds: getPrices() was removed対応中かも @pcvelz が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
OpenMage/magento-lts#5869 ·
メンテナーはふだん 2 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 85/100
modelcontextprotocol/php-sdk#746 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
OpenGIS/waymark-wp#82 ·