Skip to content

Fix - Reduce SQL queries and page weight added by the plugin - #54

Draft
RomainLvr wants to merge 2 commits into
11.0/bugfixesfrom
fix/jamf-performance-improvements
Draft

RomainLvr wants to merge 2 commits into
11.0/bugfixesfrom
fix/jamf-performance-improvements

Conversation

@RomainLvr

@RomainLvr RomainLvr commented Nov 12, 2026 •

Copy link
Copy Markdown

Checklist before requesting a review

  • I have performed a self-review of my code.
  • I have added tests (when available) that prove my fix is effective or that my feature works.
  • I have updated the CHANGELOG with a short functional description of the fix or new feature.
  • This change requires a documentation update.

Description

  • Here is a brief description of what this PR does

A benchmark on a seeded database (4 000 assets, 3 900 Jamf devices, 50 000 extension attribute values, 50 000 pending imports) showed several avoidable costs added by the plugin to every GLPI request and to its own pages. It also showed a crash on the main tab of Jamf-linked assets when Twig strict variables are enabled (dev and test environments):

Key "url" for sequence/mapping with keys "caption, on_click" does not exist in "@jamf/inventory_info.html.twig" at line 43.

Fix

  • setup.php: remove the Plugin::isPluginActive('jamf') check from plugin_init_jamf(). GLPI already calls the init only for active plugins, and the check read glpi_plugins twice on every HTTP request, AJAX calls included.
  • inc/migration.class.php: add an index on glpi_plugin_jamf_mobiledevices.glpi_plugin_jamf_devices_id in the 3.2.4 migration. The join done on every Phone form scanned the whole table.
  • front/merge.php / merge.html.twig: hide the already linked items with a dropdown condition (subquery) instead of an inline used list of every linked id in each row. The page no longer reads the whole devices table.
  • inc/abstractdevice.class.php: cache getJamfItemClassForGLPIItem() per request (it runs once per tab name and once for the information block). The cache entry is cleared when the item is purged.
  • inc/connection.class.php: add a connect timeout (5 s) and a total timeout (30 s) to the Jamf API calls (Guzzle client and token requests). The MDM commands tab calls the API while it renders, and a slow Jamf server could block the page and the PHP worker.
  • js/jamf.js is now loaded only by the MDM commands tab instead of every GLPI page.
  • inventory_info.html.twig: test button.url is defined to fix the crash above.

Results

Measure Before After
SQL queries per HTTP request added by the plugin init 2 0
Phone form, rows examined 8 355 4 352
Computer write cycle (14 requests), SQL queries 1 090 1 059
Merge page HTML 523 KB 355 KB
Plugin scripts loaded on every page 1 0

Display times did not change significantly at these volumes. The gains grow with the size of the fleet.

Notes

  • The MDM commands tab could not be tested without a Jamf server.

@RomainLvr RomainLvr added the Performance Performance improvement label Nov 12, 2026
@RomainLvr RomainLvr self-assigned this Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

GLPI 11 Performance Performance improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant