Benchmarkdotnet: ConcurrencyVisualizerProfiler Attribute Causing Exception

Created on 12 Jul 2019  路  13Comments  路  Source: dotnet/BenchmarkDotNet

I have a benchmark class that uses the ConcurrencyVisualizerProfiler attribute. When I add this attribute to my class I get the following exception (which is not logged).

benchmarkdotnet-screen grab

Let me know if you need any other info to track down this issue.

Most helpful comment

1248 (PR) is going to solve this issue, it should be a part of the next release

Thanks for providing the workaround and searching for the root cause!

All 13 comments

Could you please paste the source of your *.csproj file? I have problem with merge function in #1131

Microsoft.Diagnostics.Tracing.TraceEvent nuget internally use CreateMergedTraceFile function from KernelTraceControl.dll https://docs.microsoft.com/en-us/previous-versions/windows/desktop/xperf/createmergedtracefile which returns codes from this list:
https://docs.microsoft.com/pl-pl/windows/win32/debug/system-error-codes

0x3 means: ERROR_PATH_NOT_FOUND - The system cannot find the path specified.

I don't know why in your test, user session didn't create *.etl file. Are you able to provide a reproduction of this error?

I will get back to you on this. Saving that test until I get the others working correctly.

I don't get that same error anymore, now it's the one below. It also happens if I add the ETWProfiler attribute too. I run the test as admin on my laptop (not a VM).

// AfterAll
// * Artifacts cleanup *
Program Error! Merge operation failed return code 0x3

I got this error as well trying to use the EtwProfiler.

0x3 means: ERROR_PATH_NOT_FOUND - The system cannot find the path specified.

That is the key that helped me figure out the issue. I traced this down to also using an [ArgumentsSource(nameof(SomeArguments)] attribute in my benchmark.

The following code on 0.11.5 reproduces the error for me:

```C#
[EtwProfiler] //- needs elevated privileges
public class RegexMatchBenchmark
{
public IEnumerable MatchIdentifierArguments()
{
yield return new string('a', 128);
}
[Benchmark]
[ArgumentsSource(nameof(MatchIdentifierArguments))]
public bool MatchIdentifier_STRE(string value) =>
new Regex("a").IsMatch(value);
}

Changing it to:

```C#
    [EtwProfiler] //- needs elevated privileges
    public class RegexMatchBenchmark
    {
        private static readonly string test = new string('a', 128);

        [Benchmark]
        public bool MatchIdentifier_STRE() =>
            new Regex("a").IsMatch(test);
    }

Allows BenchmarkDotNet to successfully produce an .etl trace file.

/cc @adamsitnik

I will try to fix it.

Weird, I am able to repro the problem, but I get a different error:

Unhandled Exception: System.ArgumentException: File name too long
Parameter name: sessionName
   at Microsoft.Diagnostics.Tracing.Session.TraceEventSession.GetProperties(Byte* buffer)
   at Microsoft.Diagnostics.Tracing.Session.TraceEventSession.EnsureStarted(EVENT_TRACE_PROPERTIES* properties)
   at Microsoft.Diagnostics.Tracing.Session.TraceEventSession.EnableProvider(Guid providerGuid, TraceEventLevel providerLevel, UInt64 matchAnyKeywords, TraceEventProviderOptions options)
   at Microsoft.Diagnostics.Tracing.Session.TraceEventSession.EnableProvider(String providerName, TraceEventLevel providerLevel, UInt64 matchAnyKeywords, TraceEventProviderOptions options)
   at BenchmarkDotNet.Diagnostics.Windows.UserSession.EnableProviders()

Ran into this just now. Same error message as @RealDotNetDave. I've used this repo to reproduce: https://github.com/dotnetos/asyncexpert-course

Fired up ProcMon and looked at the .etl files BDN generates. The full path that the .etl files are written to, and the same exact one where BDN attempts to read them, is C:\Users\malbert\source\repos\asyncexpert-course\Module 01\Dotnetos.AsyncExpert.Homework.Module01.Benchmark\bin\Release\netcoreapp3.1\BenchmarkDotNet.Artifacts\Dotnetos.AsyncExpert.Homework.Module01.Benchmark.FibonacciCalc.Recursive(n_ 1)-20200620-220851..etl. This is exactly 259 chars.

Now moving the project directory closer to the drive root results in a successful run. The path this time is C:\t\Module 01\Dotnetos.AsyncExpert.Homework.Module01.Benchmark\bin\Release\netcoreapp3.1\BenchmarkDotNet.Artifacts\Dotnetos.AsyncExpert.Homework.Module01.Benchmark.FibonacciCalc.Recursive(n_ 1)-20200620-221421..kernel.etl. The length is now 222 chars.

The outcome seems to point to the infamous 260 path character limit, as described here.

Yes, I am also getting the same exception (and in the same project as @luckerby).

Ah that's a good tip @luckerby, will try to move my project to a different folder.
UPDATE it helped of course. The infamous 260 limitation.

1248 (PR) is going to solve this issue, it should be a part of the next release

Thanks for providing the workaround and searching for the root cause!

Thanks @adamsitnik ! We are also shrinking paths in the course

Thanks for working on this!

Was this page helpful?
0 / 5 - 0 ratings