Skip to content

Improve stackcollapse-xdebug script#359

Open
lucc wants to merge 1 commit intobrendangregg:masterfrom
lucc:php-xdebug-1
Open

Improve stackcollapse-xdebug script#359
lucc wants to merge 1 commit intobrendangregg:masterfrom
lucc:php-xdebug-1

Conversation

@lucc
Copy link
Copy Markdown

@lucc lucc commented Dec 18, 2025

The script did call sed in a blocking manner and did also instruct it to create a backup of the original trace file before modifying it in place. This results in a copy of the potentially huge trace file on disk.

The sed command is now called in a pipeline allowing the php script to start reading its output before the sed command completes. Also the sed command only parses the original file and does not create a copy.

The first argument to the script is now optional, defaulting to stdin.


I know that php/xdebug has been updated to include an xdebug.trace_format=3 option that produces the collapsed format for flamegraph.pl directly. But for older versions of php/xdebug which only offer the format 1 it was interesting for me to improve this script.

The script did call sed in a blocking manner and did also instruct it to
create a backup of the original trace file before modifying it in place.
This results in a copy of the potentially huge trace file on disk.

The sed command is now called in a pipeline allowing the php script to
start reading its output before the sed command completes.  Also the sed
command only parses the original file and does not create a copy.

The first argument to the script is now optional, defaulting to stdin.
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.

1 participant