perfview icon indicating copy to clipboard operation
perfview copied to clipboard

Frames for recursive calls added to MutableTraceEventStackSource are shown as merged

Open ara-ayvazyan opened this issue 1 year ago • 2 comments

The following stack doesn't show X calling into X in the stack view:

public class Commands : CommandEnvironment
{
    public void TestFileView(string fileName, string viewName)
    {
        var etlFile = OpenETLFile(fileName);
        OpenStackViewer(new Stacks(new RecursiveCallRepro(etlFile.TraceLog), viewName, etlFile));
    }
}

internal class RecursiveCallRepro : MutableTraceEventStackSource
{
    public RecursiveCallRepro(TraceLog traceLog)
        : base(traceLog)
    {
        var sample = new StackSourceSample(this);
        sample.StackIndex = Interner.CallStackIntern(Interner.FrameIntern("X"), sample.StackIndex);
        sample.StackIndex = Interner.CallStackIntern(Interner.FrameIntern("X"), sample.StackIndex);
        AddSample(sample);
    }
}

image image

ara-ayvazyan avatar Aug 09 '24 19:08 ara-ayvazyan

This is interesting - I had not seen it before. This appears to be in the stack viewer itself, and not in the StackSource code. I did a test where I wrote some recursive code, but didn't hit this:

image

I suspect that this is due to the fact that there are IPs involved in the trace where we're just dealing with names in the code above, and so there is no way to disambiguate between the two X frames when it comes to how the viewer works. I have not had enough time to dig through and figure out what you'd need to do here to address this - do you have a scenario that is blocked here, or were you just testing and ran into this?

brianrob avatar Aug 12 '24 21:08 brianrob

I have a use case for this (if actual recursive call happens in user code, which is less likely), but can probably inject an intermediate frame to work around for now.

ara-ayvazyan avatar Aug 12 '24 22:08 ara-ayvazyan