Skip to content

Perf: read the configuration once per request - #180

Merged
Herafia merged 1 commit into
11.0/bugfixesfrom
perf/cache-configuration
Dec 1, 2026
Merged

Herafia merged 1 commit into
11.0/bugfixesfrom
perf/cache-configuration

Conversation

@Lainow

@Lainow Lainow commented Nov 13, 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.

Description

Each generated number read the plugin configuration again: 9 queries per asset. The generation switch, the per-type rows and the enabled itemtypes are now read once per request. The cache is cleared when a configuration is saved, added or removed. The counter and its reset date are still read from the database for each number.

Benchmark

GLPI 11.0, 2 000 computers, generation on for computers.

Scenario SQL before SQL after Time before Time after
Massive action "Regenerate inventory number", 50 computers 1 142 queries (450 on plugin tables) 844 (152) 940 ms 925 ms (not significant)
Computer creation (number generated), plugin queries 7 5 39 ms within noise

This is a small gain: most of the time is GLPI updating each asset.

Tests

A new test changes the template and the generation switch between two generations in the same process. It checks that each change is seen and that the numbers stay consecutive.

@Rom1-B
Rom1-B requested review from a team, AdrienClairembault, Herafia, Mary-Clb, MyvTsv, Rom1-B and jdurand-teclib and removed request for a team, AdrienClairembault, Rom1-B and jdurand-teclib November 18, 2026 13:08
Herafia
Herafia previously approved these changes Nov 20, 2026
stonebuzz
stonebuzz previously approved these changes Nov 25, 2026
- Cache the generation switch, the per-type configuration rows and the
  enabled itemtypes for the request, cleared when a configuration is
  saved, added or removed
- The counter and its reset date are still read from the database for
  each generated number
@Lainow
Lainow dismissed stale reviews from stonebuzz and Herafia via f7221ff December 1, 2026 09:02
@Lainow
Lainow force-pushed the perf/cache-configuration branch from 7f3fb26 to f7221ff Compare December 1, 2026 09:02
@Herafia
Herafia merged commit b1d348a into 11.0/bugfixes Dec 1, 2026
7 checks passed
@Herafia
Herafia deleted the perf/cache-configuration branch December 1, 2026 10:30
@glpi-project

glpi-project Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Backport-action backported this pull request in workflow run 46627198826.

Target Status
main ⚠️ Drafted with conflicts #186

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants