What is "<Cycle 1>" an indication of in Xdebug?

ProfilingXdebugKcachegrind

Profiling Problem Overview


I have an xdebug profile on a php script that I parsed with kcachegrind. Here is a screenshot showing that the most time spent inside any given function was spent inside <cycle 1> and the top 'Callers' were made from 'include' and 'include_once' in index.php.

kcachegrind of xdebug profile showing cycle 1

This profile was run during a stress-test using apache 'ab' so there were many concurrent connections occurring.

What does <cycle 1> indicate on an xdebug profile?

Profiling Solutions


Solution 1 - Profiling

It is heuristic cycle detection. You can turn it off from toolbar or from menu "View->Detect cycles" or "View->Do cycle detection".

Cycle is something like recursion, both direct ( f() -> f() -> f() where -> means call ) and indirect ( f()->g()->f()->g()->f())

Callgring format (used in kcachegrind) is not saving full call stack, it stores only pairs caller-callee and it may be hard to restore longer cycles from this information

Solution 2 - Profiling

Although @osgx mentions that you can turn off Cycle Detection, I just wanted to point out here that if you feel that <cycle 1> is hiding something of interest to you, that you probably should turn off cycle detection as he explains.

Disabling cycle detection in my case actually revealed some key pieces of information that were missing before.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDerek DowneyView Question on Stackoverflow
Solution 1 - ProfilingosgxView Answer on Stackoverflow
Solution 2 - ProfilingCory KleinView Answer on Stackoverflow