Skip to content

fix(xhgui): raise upload limits to 100M so large profiles import, fixes #9025 - #9027

Merged
rfay merged 3 commits into
ddev:mainfrom
rfay:20261028_rfay_xhgui_body_size
Oct 28, 2026
Merged

rfay merged 3 commits into
ddev:mainfrom
rfay:20261028_rfay_xhgui_body_size

Conversation

@rfay

@rfay rfay commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Short Summary (TL;DR)

XHGui now imports xhprof profiles up to 100MB. Before, nginx rejected any profile over 5MB with a 413, and the run never appeared.

The Issue

How This PR Solves The Issue

The ddev-xhgui image raises client_max_body_size in nginx and post_max_size in PHP to 100M. Both limits must change, because PHP rejects a body over its default 8M after nginx accepts it.

XHGui needs about 30-35 times the profile size in memory, so the image also sets memory_limit=-1. The webserver's XHGui collector waits up to 30s for the upload instead of 3s, because an 18MB profile takes about 2s to import.

Manual Testing Instructions

ddev utility download-ddev --pr 9027
export PATH="$HOME/tmp/ddev-download-ddev/pr-9027:$PATH"
ddev config --project-type=php
ddev start
ddev xhgui on
ddev exec 'head -c 11000000 /dev/zero | tr "\0" a > /tmp/big.json'
ddev exec 'curl -s -w "\n%{http_code}\n" -X POST -H "Content-Type: application/json" --data-binary @/tmp/big.json http://xhgui/run/import'
# Expect 401 "Failed to decode payload" instead of 413

For a real profile, profile a page that calls many distinct functions, for example 120,000 generated functions, so the profile is over 5MB. The profile appears in ddev xhgui.

🤖 Developed with assistance from Claude Code

@rfay
rfay requested a review from a team as a code owner October 28, 2026 15:37
@github-actions github-actions Bot added bugfix dependencies Pull requests that update a dependency file labels Oct 28, 2026
@rfay
rfay requested a review from stasadev October 28, 2026 15:38
@github-actions

Copy link
Copy Markdown

Pushed updated container image(s) for this PR:

  • ddev/ddev-xhgui:8e4d872d4f

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Download this PR's build for your OS and architecture with:

ddev utility download-ddev --pr 9027

Or download the artifact for your OS and architecture directly:

See Testing a PR.

Open in GitHub Codespaces

@stasadev stasadev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 10.8MB profile from the issue imports now, but bigger ones hit the PHP memory_limit=512M in the same Dockerfile. Claude Code ran real profiles on Docker 29:

Profile v1.25.5 This PR
13.2MB 413 imported
18.4MB 413 500, Allowed memory size of 536870912 bytes exhausted ... NormalizingSaver.php on line 35

XHGui needs about 30-35x the profile size in memory, so 100M would need around 3G. With 640M the 18.4MB profile imports. The 500 is worse than the old 413, because the profiler only falls back to /tmp/xhgui.data.jsonl when the upload fails, and here XHGui accepts the body and then dies.

Maybe raise the memory limit too? It is only a local tool:

RUN echo 'memory_limit=-1' >> $PHP_INI_DIR/conf.d/99-memory-limit.ini

Or keep 512M and change "up to 100MB" in the description to about 15MB.

Small things:

  1. The 18.4MB import takes 1.3-2.4s here, and the collector uploads with 'timeout' => 3. On slower machines this will be the next limit. Can be a follow-up.
  2. With 80,000 generated functions, Claude Code got a 4.7MB profile, which also imports on v1.25.5. The test needs something above 5MB to show the difference.

🤖 Reviewed with assistance from Claude Code

@rfay

rfay commented Oct 28, 2026

Copy link
Copy Markdown
Member Author

Thanks, updated. Went with memory_limit=-1

@stasadev stasadev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, works now. Claude Code applied the new memory_limit=-1 and 'timeout' => 30 by hand to the previous PR images, because the new ones were not pushed yet:

Profile Result xhgui peak memory
18MB imported 634M
30MB imported 1.1G
42MB imported 1.9G

The 42MB import takes 3.5-4.3s, so the old 3s timeout would also fail here.

About memory_limit=512M: there was no deeper reason for it. It came from the add-on in ddev/ddev-xhgui#4 (Nov 2023), which raised it from PHP's default 128M because "I fairly easily hit the 128MB limit profiling a real site". client_max_body_size 5M came from the upstream XHGui nginx.conf. #7069 copied both from the add-on into the core image as they were. So removing the limit is fine.

🤖 Reviewed with assistance from Claude Code

@github-actions

Copy link
Copy Markdown

Pushed updated container image(s) for this PR:

  • ddev/ddev-webserver-prod:986b21b643
  • ddev/ddev-webserver:986b21b643
  • ddev/ddev-xhgui:41ec619271

rfay and others added 3 commits October 28, 2026 20:18
ddev#9025

XHGui now imports xhprof profiles up to 100MB. Before, nginx rejected any profile over 5MB with a 413, and the run never appeared.

- Fixes ddev#9025

The `ddev-xhgui` image raises `client_max_body_size` in nginx and `post_max_size` in PHP to 100M. Both limits must change, because PHP rejects a body over its default 8M after nginx accepts it.

```bash
ddev utility download-ddev --pr 9027
export PATH="$HOME/tmp/ddev-download-ddev/pr-9027:$PATH"
ddev config --project-type=php
ddev start
ddev xhgui on
ddev exec 'head -c 11000000 /dev/zero | tr "\0" a > /tmp/big.json'
ddev exec 'curl -s -w "\n%{http_code}\n" -X POST -H "Content-Type: application/json" --data-binary @/tmp/big.json http://xhgui/run/import'
```

For a real profile, profile a page that calls many distinct functions, for example 80,000 generated functions. The profile is about 6.6MB, and it appears in `ddev xhgui`.

🤖 Developed with assistance from [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…out to 30s

XHGui needs about 30-35 times the profile size in memory, so an 18MB profile failed with a 500 at memory_limit=512M. XHGui is a local tool, so memory_limit=-1 removes the limit.

The collector's 3s upload timeout was close to the 1.3-2.4s that an 18MB import takes. The collector now waits up to 30s before it falls back to /tmp/xhgui.data.jsonl.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rfay
rfay force-pushed the 20261028_rfay_xhgui_body_size branch from b0f7bf9 to fcc243f Compare October 28, 2026 20:40
@github-actions

Copy link
Copy Markdown

Pushed updated container image(s) for this PR:

  • ddev/ddev-webserver-prod:536c30e697
  • ddev/ddev-webserver:536c30e697
  • ddev/ddev-xhgui:e0675a31b3

@rfay
rfay merged commit 0f11a2e into ddev:main Oct 28, 2026
53 of 56 checks passed
@rfay
rfay deleted the 20261028_rfay_xhgui_body_size branch October 28, 2026 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

xhgui rejects profiles over 5MB with 413: client_max_body_size and post_max_size too small

3 participants