xoofx / ultra

An advanced profiler for .NET Applications on Windows
BSD 2-Clause "Simplified" License
397 stars 5 forks source link

Symbols aren't loaded for --pid mode #13

Open EgorBo opened 14 hours ago

EgorBo commented 14 hours ago

I've integrated ultra into my bot here https://github.com/EgorBot/runtime-utils/issues/173 🙂 but it seems like it's not picking up symbols when it's attached to an already running app via --pid (it works when it itself starts the app).

Repro:

using System.Text.Json;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;

BenchmarkSwitcher.FromAssembly(typeof(Perf_Basic).Assembly).Run(args);

public class Perf_Basic
{
    static readonly Employee[] Data = Enumerable.Range(1, 4096)
        .Select(i => new Employee("John", "Manager", 30, 185.5, new DateTime(1990, 10, 10),
            new Employee("John", "Developer", 30 + i, 185.5, new DateTime(1990, 10, 10), null))).ToArray();

    [Benchmark]
    public Employee[]? JsonRoundtrip()
    {
        var str = JsonSerializer.Serialize(Data);
        return JsonSerializer.Deserialize<Employee[]>(str);
    }
}

public record Employee(string name, string title, int age, double height, DateTime applyDate, Employee? manager);

which I then build & run as

dotnet publish -c Release --sc -r win-x64 -f net9.0 && .\bin\Release\net9.0\win-x64\publish\ConsoleApp10.exe --filter * --noForcedGCs --noOverheadEvaluation --disableLogFile --maxWarmupCount 8 --minIterationCount 15000000 --maxIterationCount 20000000 -a perfarts -i

and in a separate window:

ultra profile --pid $(Get-Process -Name ConsoleApp10).Id

I tried to use dotnet-symbol --symbols and <DebugType> with no luck

xoofx commented 12 hours ago

ultra profile --pid $(Get-Process -Name ConsoleApp10).Id

hm... but isn't BenchmarkDotNet launching another process actually to run the actual benchmarks?

I have thought about maybe adding something like attach child process... and this could fit into this use case.

EgorBo commented 12 hours ago

hm... but isn't BenchmarkDotNet launching another process actually to run the actual benchmarks?

not with -i parameter (stands for InProcessToolchain)

xoofx commented 10 hours ago

not with -i parameter (stands for InProcessToolchain)

Hm, interesting. Have you ever tried with perfview similarly?

I will double check locally what is happening, but I'm not doing anything particular for the symbol resolution, so BenchmarkDotNet might still interfere in some ways...

xoofx commented 8 hours ago

So I just tried your exact steps above and I got it working, so it might be something else...

image