Hard reload re-reads every plugin template folder for every template (O(plugins²) stat calls)

Open
#5,480 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
python

Research direction

Start by reading _process_template_config() and compare its template candidate handling with the linked commit, which describes a fix. Reproduce a hard reload and measure statx calls with the issue's strace command; done means the resolved path is checked without probing every plugin template folder.

Written by the indexing model from the issue text.

Description

triage
The problem

On every hard reload OctoPrint performs ~13k stat calls on files that cannot exist.

_process_template_config() prefixes the template candidate with the plugin's
template folder key, so data["template"] is e.g.
navbartemp/navbartemp_navbar.jinja2 and can only exist in that one folder. The
existence check still walks the whole loader chain, statting every plugin template
folder and raising a TemplateNotFound for each. With 21 plugins that is 21 probes ×
~30 template types × 21 folders per rebuild, and a rebuild runs on every request
carrying Cache-Control: no-cache, i.e. every hard reload.

strace -c -f -e trace=statx around a single reload on a Pi 2 with 21 plugins:

27568 statx, 26143 ENOENT (94.9%)

GET / app time (Server-Timing): ~3.1s on the hard reload path, ~200ms normally.

Fix (stat the resolved path instead of probing every folder), after: ~600 statx,
no failing probes:
https://github.com/davtur19/OctoPrint/commit/c963f02dae6bfc3ef7130a4cc3bff0fd1aef2615

Did the issue persist even in safe mode?

Yes, it did persist

If you could not test in safe mode, please state why ("currently printing" is NOT an excuse!)

No response

Version of OctoPrint

1.11.8

Operating system running OctoPrint

octopi

Browser and version of browser, operating system running browser

No response

Printer model & used firmware incl. version

No response

Systeminfo Bundle

octoprint-systeminfo-20261031014254.zip[^bundle1]

Checklist of files to include below
  • Contents of the JavaScript browser console (always include in cases of issues with the user interface)
  • Screenshots and/or videos showing the problem (always include in case of issues with the user interface)
  • GCODE file with which to reproduce (always include in case of issues with GCODE analysis or printing behaviour)
Additional information & file uploads

No response

[^bundle1]: octoprint-systeminfo-20261031014254.zip (bundleviewer) (download)
OctoPrint: 1.11.8
Python: 3.11.2
OS: Linux-6.12.96+rpt-rpi-v7-armv7l-with-glibc2.36
RPi: Raspberry Pi 2 Model B Rev 1.1
OctoPi: 1.1.0 (build 2025.05.13.134411)
Browser:

Dominant language
Python
Stars
9.2k
Forks
1.7k
Avg merge
6d 8h
Merged PRs (30d)
6

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from OctoPrint/OctoPrint

All issues in OctoPrint/OctoPrint

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.