-
Notifications
You must be signed in to change notification settings - Fork 150
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
NLogProviderOptions with support for CaptureEventId #538
Conversation
4dedd9f
to
8fdc74d
Compare
Tempted to merge EventId-property-capture into NLogMessageParameterList, as it would reduce memory-allocation even more. |
8fdc74d
to
ef67032
Compare
Codecov Report
@@ Coverage Diff @@
## master #538 +/- ##
==========================================
- Coverage 80.87% 80.66% -0.21%
==========================================
Files 17 17
Lines 1443 1438 -5
Branches 236 237 +1
==========================================
- Hits 1167 1160 -7
Misses 171 171
- Partials 105 107 +2
Continue to review full report at Codecov.
|
ef67032
to
45c0509
Compare
Sounds good :) |
If this capture selection logic exists for performance, is it really faster to do all this than just to capture EventId struct? if (@event != default)
properties["EventId"] = @event; I've run a benchmark and seems like simple capturing could be faster. It consistently allocates 32B for a single eventId but is also consistently faster, while current logic can either save allocation completely in case of separate properties and pre-generated eventId, or allocate even more if user chooses to log eventId as struct |
In my world, then memory-allocation / boxing is always slow. And you can performs lots cpu-instructions for the price of a single allocation. |
I agree that boxing is an expensive operation, Microsoft says that it can take up to 20 times longer than a reference assignment. My concern is that the optimization code here can also be expensive relative to a boxing operation. Benchmark, (if it is correct), confirms it - 23ns boxing vs 30-40ns optimization. This difference could also be a result of compile-time/JIT optimization though, which is why I'm not sure about my benchmark, you know more about the code and can write a correct one to check this theory. |
I'm guessing your benchmark is comparing "time to insert single eventid" vs. "time to insert two properties". And your benchmark shows that string-hashcode and dictionary-insert is the most expensive part (Notice that the longer Happy that the change to enum, now allows you to perform single insert (or completely skip it) |
Follow up to #319. Better granularity of how to capture EventId. See also #537