-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Reduce overheads of EventSource.WriteEvent(int, object[]) with ETW #54925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Tagging subscribers to this area: @tarekgh, @tommcdon, @pjanotti Issue DetailsCuts allocation by ~3-4x on basic use cases by avoiding a
using BasicEventSourceTests;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.Diagnostics.Tracing;
[MemoryDiagnoser]
public class Program
{
static void Main(string[] args) => BenchmarkSwitcher.FromAssemblies(new[] { typeof(Program).Assembly }).Run(args);
private static EtwListener s_listener;
[GlobalSetup]
public void Setup()
{
s_listener = new EtwListener(null);
s_listener.EventSourceSynchronousEnable(MyEventSource.Log);
}
[GlobalCleanup]
public void Cleanup() => s_listener.Dispose();
[Benchmark]
public void Log() => MyEventSource.Log.SomethingCool(42, 84);
}
[EventSource]
class MyEventSource : EventSource
{
internal static readonly MyEventSource Log = new MyEventSource();
[Event(1, Level = EventLevel.LogAlways)]
public void SomethingCool(int i, float j) => WriteEvent(1, i, j);
}
|
brianrob
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but will defer to @josalem for final sign-off. It would also be good to run the EventSource tests elevated (locally is fine), to confirm that the expected payloads come all the way through. Historically, the CI doesn't run elevated, and so the ETW tests don't run - only the EventListener tests run.
Also, I suspect that you might need to #ifdef this (grr...) due to the fact that this code targets .NET Framework via the EventSource.Redist package. That might be where the CI error is coming from too.
c0b4fbc to
38e2065
Compare
|
LGTM! Thanks for running the tests elevated 😃. It looks like the CI failures are NuGet restore failures. Let me see about rerunning the innerloop legs. |
|
azp run runtime-dev-innerloop |
josalem
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, looks like GH posted that as a comment rather than a PR review.
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventProvider.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventProvider.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventProvider.cs
Outdated
Show resolved
Hide resolved
0c33683 to
304d4a5
Compare
Cuts allocation by ~3-4x on basic use cases by avoiding a `List<int>(8)` and `List<object>(8)` allocation along with the underlying arrays.
304d4a5 to
2055f51
Compare

Cuts allocation by ~3-4x on basic use cases by avoiding a
List<int>(8)andList<object>(8)allocation along with the underlying arrays.cc: @josalem, @brianrob