Profiler HTML output exceeds browser rendering capacity on complex pages
0 reputation · 20 Jun 2022, 08:11 UTC
0 reputation · 20 Jun 2022, 08:11 UTC
Magento 2's built-in profiler (Magento\Framework\Profiler) can be enabled via bin/magento dev:profiler:enable html_file to generate flame-graph HTML reports in var/profiler.*.html. The profiler captures timer IDs, elapsed time, memory usage, and call counts for each instrumented code block.
On complex pages (e.g., category listings with layered navigation, checkout with many quote items), the generated HTML file frequently exceeds 50 MB. Browsers struggle to parse and render such large single-page flame graphs, resulting in frozen tabs, excessive memory consumption, or outright crashes before analysis can begin. The profiler does not implement pagination, streaming, or incremental rendering for the HTML driver.
What configuration or workflow allows analyzing bottlenecks on heavy pages without hitting the browser rendering limit? Is there a supported method to split or stream the HTML profiler output? Can the CSV data be reliably transformed into a navigable flame graph using offline tooling?
30775 reputation · 20 Jun 2022, 12:03 UTC
Enable the CSV profiler driver, convert the CSV to a flame‑graph offline, and only fall back to HTML splitting if a visual flame‑graph is required.
bin/magento dev:profiler:enable csv_filevar/profiler.*.csv.parent_timer (or a similar hierarchy column), convert it to a collapsed stack format:# Example: produce "timer;elapsed_time" lines
awk -F, '{print $2";"$4}' var/profiler.*.csv > collapsed.txt
# Adjust column numbers if your CSV differs
flamegraph.pl:perl flamegraph.pl collapsed.txt > profiler.svg
Or import the CSV into SpeedScope (File → Import → CSV) and select the timer and elapsed‑time columns.
If you must keep the HTML driver, split the generated file after collection:
profiler_full.html.<tr> block into its own HTML page with shared CSS/JS:awk '/^<tr class="top"/ {if (out) close(out); out=sprintf("part%02d.html",++n); print "<!DOCTYPE html><html><head><link rel=\"stylesheet\" href=\"profiler.css\"></head><body>" > out; print $0 > out; next}
{print $0 > out}' profiler_full.html
Adjust the pattern to match your actual markup; duplicate any required CSS/JS files or reference them via relative paths.
Confirm whether your CSV export contains a parent_timer column (or equivalent hierarchy). If it does not, you will need to reconstruct the call stack from timer IDs and timestamps before converting to a flame‑graph.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.