-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
ServiceBus EventSource remove allocations and boxing #27080
ServiceBus EventSource remove allocations and boxing #27080
Conversation
Thank you for your contribution @danielmarbach! We will review the pull request and get back to you soon. |
sdk/servicebus/Azure.Messaging.ServiceBus/src/Diagnostics/ServiceBusEventSource.cs
Outdated
Show resolved
Hide resolved
/azp run net - servicebus - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
The test |
I can also look into it sometime next week. I'm mostly AFK enjoying carnival 🙃 |
bd52623
to
650b775
Compare
Pushed an update |
Is it possible to rerun the tests here to see if things are still flaky? |
/azp run net - servicebus - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
650b775
to
9106271
Compare
Eyeballing it again I think the order of parameters, types as well as the sizes of the parameters should match what we had before. I can explain why it is failing. I pushed now an update the removes the |
/azp run net - servicebus - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
Agreed. I've revisited this a couple of times in the last two weeks, and I am at a loss. The results are consistent, though, and show that something in |
One thing I was thinking too is how the nullable long gets marshalled. |
Narrator: It was a bool who made fool not sleep. |
This simple repro helped quite a bit // See https://aka.ms/new-console-template for more information
using System.Diagnostics.Tracing;
using System.Runtime.CompilerServices;
SomeEventSourceListener listener = new SomeEventSourceListener();
SomeEventSource.Log.TransactionDischarged("TransactionId", " AmqpTransactionId", true);
Console.ReadLine();
sealed class SomeEventSourceListener : EventListener
{
protected override void OnEventSourceCreated(EventSource eventSource)
{
if (eventSource.Name.Equals("Some-EventSource"))
{
EnableEvents(eventSource, EventLevel.Verbose, EventKeywords.All);
}
}
// from https://blogs.msdn.microsoft.com/dotnet/2018/12/04/announcing-net-core-2-2/
// Called whenever an event is written.
protected override void OnEventWritten(EventWrittenEventArgs eventData)
{
// Write the contents of the event to the console.
Console.WriteLine($"ThreadID = {eventData.OSThreadId} ID = {eventData.EventId} Name = {eventData.EventName}");
for (int i = 0; i < eventData.Payload.Count; i++)
{
string payloadString = eventData.Payload[i] != null ? eventData.Payload[i].ToString() : string.Empty;
Console.WriteLine($" Name = \"{eventData.PayloadNames[i]}\" Value = \"{payloadString}\"");
}
Console.WriteLine("\n");
}
}
[EventSource(Name = EventSourceName)]
internal class SomeEventSource : EventSource
{
private const string EventSourceName = "Some-EventSource";
internal const int TransactionDischargedEvent = 91;
protected SomeEventSource()
{
}
public static SomeEventSource Log { get; } = new SomeEventSource();
[Event(TransactionDischargedEvent, Level = EventLevel.Informational, Message = "AmqpTransactionDischarged for LocalTransactionId: {0} AmqpTransactionId: {1} Rollback: {2}.")]
public void TransactionDischarged(string transactionId, string amqpTransactionId, bool rollback)
{
//WriteEvent(TransactionDischargedEvent, transactionId, amqpTransactionId, rollback);
TransactionDischargedCore(TransactionDischargedEvent, transactionId, amqpTransactionId, rollback);
}
[NonEvent]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private unsafe void TransactionDischargedCore(int eventId, string transactionId, string amqpTransactionId, bool rollback)
{
fixed (char* transactionIdPtr = transactionId)
fixed (char* amqpTransactionIdPtr = amqpTransactionId)
{
var eventPayload = stackalloc EventData[3];
eventPayload[0].Size = (transactionId.Length + 1) * sizeof(char);
eventPayload[0].DataPointer = (IntPtr)transactionIdPtr;
eventPayload[1].Size = (amqpTransactionId.Length + 1) * sizeof(char);
eventPayload[1].DataPointer = (IntPtr)amqpTransactionIdPtr;
var rollbackInt = Convert.ToInt32(rollback);
eventPayload[2].Size = Unsafe.SizeOf<int>();
eventPayload[2].DataPointer = (IntPtr) Unsafe.AsPointer(ref rollbackInt);
WriteEventCore(eventId, 3, eventPayload);
}
}
} |
This should now pass (famous last words) |
sdk/servicebus/Azure.Messaging.ServiceBus/src/Diagnostics/ServiceBusEventSource.cs
Outdated
Show resolved
Hide resolved
/azp run net - servicebus - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
sdk/servicebus/Azure.Messaging.ServiceBus/src/Diagnostics/ServiceBusEventSource.cs
Outdated
Show resolved
Hide resolved
sdk/servicebus/Azure.Messaging.ServiceBus/src/Diagnostics/ServiceBusEventSource.cs
Outdated
Show resolved
Hide resolved
sdk/servicebus/Azure.Messaging.ServiceBus/src/Diagnostics/ServiceBusEventSource.cs
Outdated
Show resolved
Hide resolved
sdk/servicebus/Azure.Messaging.ServiceBus/src/Diagnostics/ServiceBusEventSource.cs
Outdated
Show resolved
Hide resolved
sdk/servicebus/Azure.Messaging.ServiceBus/src/Diagnostics/ServiceBusEventSource.cs
Outdated
Show resolved
Hide resolved
sdk/servicebus/Azure.Messaging.ServiceBus/src/Diagnostics/ServiceBusEventSource.cs
Show resolved
Hide resolved
/azp run net - servicebus - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
.... and I just realized Josh already ran the tests, so now we get two clean runs. 😄 |
Ping ;) |
Will take a look today - thanks again for your patience @danielmarbach! |
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.
Thanks @danielmarbach!
Similar to #26989 but for ServiceBus to make @JoshLove-msft a happy person too.
Contributing to the Azure SDK
Please see our CONTRIBUTING.md if you are not familiar with contributing to this repository or have questions.
For specific information about pull request etiquette and best practices, see this section.