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 小時
- 30 天內合併 PR
- 20
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 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可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉
難度 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 ·