View Issue Details

IDProjectCategoryView StatusLast Update
0001710XdebugProfilingpublic2021-05-12 19:11
Reporterenor Assigned Toderick  
PriorityhighSeverityminorReproducibilityalways
Status closedResolutionduplicate 
Product Version2.6.0 
Target Version3.1dev 
Summary0001710: Doubled recursion count in kcachegrind on select recursive function
Description

I tried profiling a recursive function with a little test script. When viewing the cachegrind output in kcachegrind I can see the correct number of function calls when clicking the main entry point in the call graph (27).

However, when i click the recursive function, it shows doubled count (54) which I did not expect.

Steps To Reproduce
  1. Run the following script in documentRoot with profiling enabled.
  2. Inspect the output with kcachegrind.

<?php

$list = ['one', 'two', 'three'];
foreach ($list as $item) {
outputWithRecursion($item, 10);
}

function outputWithRecursion(string $item, int $countdown): void
{
$countdown--;
if ($countdown > 0) {
echo sprintf('not yet (%d)...', $countdown);
outputWithRecursion($item, $countdown);
} else {
echo sprintf('Finally there: %s(%d)
', $item, $countdown);
}
}

Additional Information

PHP Version 7.2.19-0ubuntu0.18.04.2

HTTP Response Headers
X-Xdebug-Profile-Filename /var/www/xworkshop/cachegrind.out.832

xdebug support enabled
Version 2.6.0
IDE Key PHPSTORM

xdebug.ini settings

zend_extension=xdebug.so
xdebug.remote_connect_back=0
xdebug.remote_enable=0
xdebut.remote_host=localhost
xdebug.remote_port=9001
xdebug.remote_log=/var/www/xworkshop/remote.log
xdebug.auto_trace=1
xdebug.profiler_enable=1
xdebug.profiler_output_dir=/var/www/xworkshop

TagsNo tags attached.
Attached Files
cachegrind_recursion_main.png (90,301 bytes)   
cachegrind_recursion_main.png (90,301 bytes)   
cachegrind_recursion_output.png (91,907 bytes)   
cachegrind_recursion_output.png (91,907 bytes)   
Operating SystemUbuntu 18.04
PHP Version7.2.15-7.2.19

Relationships

duplicate of 0000077 acknowledgedderick Profiler doesn't handle recursive functions 

Activities

derick

2019-10-07 14:48

administrator   ~0005168

Thanks for filing this ticket. I'll likely address this in Xdebug 3.0, after I've done some major refactoring.

Issue History

Date Modified Username Field Change
2019-10-04 16:59 enor New Issue
2019-10-04 16:59 enor File Added: cachegrind_recursion_main.png
2019-10-04 16:59 enor File Added: cachegrind_recursion_output.png
2019-10-07 14:48 derick Assigned To => derick
2019-10-07 14:48 derick Status new => acknowledged
2019-10-07 14:48 derick Note Added: 0005168
2019-10-07 14:49 derick Target Version => 3.0dev
2020-11-18 15:33 derick Target Version 3.0dev => 3.1dev
2021-03-17 08:36 derick Priority low => high
2021-05-12 19:11 derick Status acknowledged => closed
2021-05-12 19:11 derick Resolution open => duplicate
2021-05-12 19:11 derick Relationship added duplicate of 0000077