Skip to content
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

High performance logging (NET6+) #361

Merged
merged 2 commits into from
Jan 13, 2025
Merged

High performance logging (NET6+) #361

merged 2 commits into from
Jan 13, 2025

Conversation

zarusz
Copy link
Owner

@zarusz zarusz commented Jan 12, 2025

  • Added source generated logging via the [LoggerMessage] attribute to the NET6, NET8 targets.
  • This PR covers layers:
    • SlimMessageBus.Host
    • SlimMessageBus.Host.AspNetCore
    • SlimMessageBus.Host.Memory

Related to #335

Some stats are captured using the SlimMessageBus.Host.Memory.Benchmark on my machine.

BenchmarkDotNet v0.14.0, Windows 11 (10.0.26100.2605)
12th Gen Intel Core i7-1260P, 1 CPU, 16 logical and 12 physical cores
.NET SDK 9.0.100
  [Host]     : .NET 8.0.11 (8.0.1124.51707), X64 RyuJIT AVX2
  Job-SXUBYX : .NET 8.0.11 (8.0.1124.51707), X64 RyuJIT AVX2

MaxIterationCount=30  MaxWarmupIterationCount=10

Before the changes:

Type Method messageCount createMessageScope Mean Error StdDev Gen0 Gen1 Gen2 Allocated
PubSubBenchmark PubSub 1000000 False 717.6 ms 12.65 ms 15.53 ms 121000.0000 3000.0000 3000.0000 1.06 GB
PubSubWithConsumerInterceptorBenchmark PubSubWithConsumerInterceptor 1000000 False 818.6 ms 15.65 ms 20.89 ms 148000.0000 3000.0000 3000.0000 1.3 GB
PubSubWithProducerInterceptorBenchmark PubSubWithProducerInterceptor 1000000 False 833.4 ms 13.25 ms 12.39 ms 158000.0000 3000.0000 3000.0000 1.39 GB
PubSubWithPublishInterceptorBenchmark PubSubWithPublishInterceptor 1000000 False 840.1 ms 15.11 ms 13.39 ms 158000.0000 3000.0000 3000.0000 1.39 GB
PubSubBenchmark PubSub 1000000 True 771.5 ms 8.56 ms 7.59 ms 138000.0000 3000.0000 3000.0000 1.22 GB
PubSubWithConsumerInterceptorBenchmark PubSubWithConsumerInterceptor 1000000 True 939.7 ms 18.38 ms 23.90 ms 166000.0000 3000.0000 3000.0000 1.45 GB
PubSubWithProducerInterceptorBenchmark PubSubWithProducerInterceptor 1000000 True 918.3 ms 8.86 ms 6.92 ms 176000.0000 3000.0000 3000.0000 1.54 GB
PubSubWithPublishInterceptorBenchmark PubSubWithPublishInterceptor 1000000 True 935.9 ms 7.61 ms 6.75 ms 176000.0000 3000.0000 3000.0000 1.54 GB

After the changes:

Type Method messageCount createMessageScope Mean Error StdDev Gen0 Gen1 Gen2 Allocated
PubSubBenchmark PubSub 1000000 False 651.3 ms 11.20 ms 11.51 ms 116000.0000 3000.0000 3000.0000 1.02 GB
PubSubWithConsumerInterceptorBenchmark PubSubWithConsumerInterceptor 1000000 False 729.8 ms 14.52 ms 12.12 ms 144000.0000 3000.0000 3000.0000 1.26 GB
PubSubWithProducerInterceptorBenchmark PubSubWithProducerInterceptor 1000000 False 759.4 ms 12.06 ms 11.28 ms 154000.0000 3000.0000 3000.0000 1.35 GB
PubSubWithPublishInterceptorBenchmark PubSubWithPublishInterceptor 1000000 False 752.2 ms 10.63 ms 9.94 ms 154000.0000 3000.0000 3000.0000 1.35 GB
PubSubBenchmark PubSub 1000000 True 673.1 ms 6.32 ms 5.91 ms 130000.0000 3000.0000 3000.0000 1.14 GB
PubSubWithConsumerInterceptorBenchmark PubSubWithConsumerInterceptor 1000000 True 769.8 ms 10.16 ms 9.01 ms 157000.0000 3000.0000 3000.0000 1.38 GB
PubSubWithProducerInterceptorBenchmark PubSubWithProducerInterceptor 1000000 True 789.1 ms 14.11 ms 12.51 ms 167000.0000 3000.0000 3000.0000 1.47 GB
PubSubWithPublishInterceptorBenchmark PubSubWithPublishInterceptor 1000000 True 802.6 ms 9.42 ms 7.87 ms 167000.0000 3000.0000 3000.0000 1.47 GB

Signed-off-by: Tomasz Maruszak <[email protected]>
@zarusz
Copy link
Owner Author

zarusz commented Jan 12, 2025

@EtherZa when you get a moment, could you review?

Copy link
Contributor

@EtherZa EtherZa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @zarusz. It looks good.

The only thing I can see is that you aren't specifying the access modifie for any of the delegates/net20 implementations. Not a problem in itself, but it is a deviation from the SMB coding style.

@zarusz zarusz self-assigned this Jan 12, 2025
@zarusz zarusz added this to the 3.0.0 milestone Jan 12, 2025
@zarusz zarusz force-pushed the feature/hpl branch 6 times, most recently from b01fd8b to dd670e5 Compare January 12, 2025 21:58
Signed-off-by: Tomasz Maruszak <[email protected]>
@zarusz zarusz merged commit dd54670 into release/v3 Jan 13, 2025
6 checks passed
@zarusz zarusz deleted the feature/hpl branch January 13, 2025 12:02
@zarusz zarusz mentioned this pull request Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants