adsr / phpspy

low-overhead sampling profiler for PHP 7+

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Interlaced output from multiple threads being traced

parthpatel1001 opened this issue · comments

Occasionally phpspy will interlace output from multiple threads of tracing like so:

ternal>:-1
1 FooBarBaz::execute /var/foo/bar/phplib/Baz/DBBaz.php:104
2 FooBarBaz::bindAndExecuteStatement /var/foo/bar/Baz/Baz/Baz.php:1379
3 FooBarBaz::callFunc /var/foo/bar0 curl_exec <internal>:-1
1 Baz::execute /var/foo/bar/Bazify.php:152
2 FooBarBaz::singleCurlFetch /var/foo/bar/Baz/SuperBaz.php:503

An strace points to these fprintf calls happening multiple times on a single trace/with multiple threads they could be overlapping with each other.

@keyurdg suggested:

Instead of line buffering here maybe full buffer _IOFBF and fflush when completed

and fflush here

commented

Thanks!