Use a native logger for critical failures in the loader#5929
Conversation
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing the following branches/commits: Execution-time benchmarks measure the whole time it takes to execute a program. And are intended to measure the one-off costs. Cases where the execution time results for the PR are worse than latest master results are shown in red. The following thresholds were used for comparing the execution times:
Note that these results are based on a single point-in-time result for each branch. For full results, see the dashboard. Graphs show the p99 interval based on the mean and StdDev of the test run, as well as the mean value of the run (shown as a diamond below the graph). |
Datadog ReportBranch report: ✅ 0 Failed, 306654 Passed, 2349 Skipped, 22h 2m 18.67s Total Time |
Benchmarks Report for tracer 🐌Benchmarks for #5929 compared to master:
The following thresholds were used for comparing the benchmark speeds:
Allocation changes below 0.5% are ignored. Benchmark detailsBenchmarks.Trace.ActivityBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.AgentWriterBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.AspNetCoreBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.DbCommandBenchmark - Faster 🎉 Same allocations ✔️
|
| Benchmark | base/diff | Base Median (ns) | Diff Median (ns) | Modality |
|---|---|---|---|---|
| Benchmarks.Trace.DbCommandBenchmark.ExecuteNonQuery‑net6.0 | 1.121 | 1,315.94 | 1,173.53 |
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | ExecuteNonQuery |
net6.0 | 1.32μs | 1.49ns | 5.75ns | 0.0144 | 0 | 0 | 1.02 KB |
| master | ExecuteNonQuery |
netcoreapp3.1 | 1.67μs | 1.14ns | 4.42ns | 0.0135 | 0 | 0 | 1.02 KB |
| master | ExecuteNonQuery |
net472 | 2.03μs | 1.88ns | 7.05ns | 0.157 | 0 | 0 | 987 B |
| #5929 | ExecuteNonQuery |
net6.0 | 1.17μs | 1.31ns | 5.06ns | 0.0141 | 0 | 0 | 1.02 KB |
| #5929 | ExecuteNonQuery |
netcoreapp3.1 | 1.65μs | 1.21ns | 4.67ns | 0.0132 | 0 | 0 | 1.02 KB |
| #5929 | ExecuteNonQuery |
net472 | 1.94μs | 2.67ns | 10.3ns | 0.156 | 0 | 0 | 987 B |
Benchmarks.Trace.ElasticsearchBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | CallElasticsearch |
net6.0 | 1.21μs | 1.88ns | 7.02ns | 0.0135 | 0 | 0 | 976 B |
| master | CallElasticsearch |
netcoreapp3.1 | 1.49μs | 0.988ns | 3.83ns | 0.0135 | 0 | 0 | 976 B |
| master | CallElasticsearch |
net472 | 2.49μs | 1.67ns | 6.45ns | 0.158 | 0 | 0 | 995 B |
| master | CallElasticsearchAsync |
net6.0 | 1.35μs | 0.614ns | 2.3ns | 0.0135 | 0 | 0 | 952 B |
| master | CallElasticsearchAsync |
netcoreapp3.1 | 1.63μs | 0.668ns | 2.5ns | 0.0138 | 0 | 0 | 1.02 KB |
| master | CallElasticsearchAsync |
net472 | 2.58μs | 3.29ns | 12.7ns | 0.166 | 0 | 0 | 1.05 KB |
| #5929 | CallElasticsearch |
net6.0 | 1.27μs | 0.818ns | 3.17ns | 0.0135 | 0 | 0 | 976 B |
| #5929 | CallElasticsearch |
netcoreapp3.1 | 1.57μs | 0.758ns | 2.84ns | 0.0127 | 0 | 0 | 976 B |
| #5929 | CallElasticsearch |
net472 | 2.43μs | 1.79ns | 6.69ns | 0.157 | 0.00122 | 0 | 995 B |
| #5929 | CallElasticsearchAsync |
net6.0 | 1.32μs | 0.504ns | 1.95ns | 0.0132 | 0 | 0 | 952 B |
| #5929 | CallElasticsearchAsync |
netcoreapp3.1 | 1.58μs | 0.724ns | 2.71ns | 0.0144 | 0 | 0 | 1.02 KB |
| #5929 | CallElasticsearchAsync |
net472 | 2.65μs | 2.08ns | 7.5ns | 0.166 | 0.00133 | 0 | 1.05 KB |
Benchmarks.Trace.GraphQLBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | ExecuteAsync |
net6.0 | 1.33μs | 1.13ns | 4.06ns | 0.0134 | 0 | 0 | 952 B |
| master | ExecuteAsync |
netcoreapp3.1 | 1.51μs | 0.745ns | 2.89ns | 0.0127 | 0 | 0 | 952 B |
| master | ExecuteAsync |
net472 | 1.81μs | 1.35ns | 5.24ns | 0.145 | 0 | 0 | 915 B |
| #5929 | ExecuteAsync |
net6.0 | 1.28μs | 0.781ns | 3.02ns | 0.0129 | 0 | 0 | 952 B |
| #5929 | ExecuteAsync |
netcoreapp3.1 | 1.56μs | 0.653ns | 2.35ns | 0.0125 | 0 | 0 | 952 B |
| #5929 | ExecuteAsync |
net472 | 1.72μs | 1.36ns | 5.25ns | 0.145 | 0 | 0 | 915 B |
Benchmarks.Trace.HttpClientBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | SendAsync |
net6.0 | 4.19μs | 1.91ns | 7.41ns | 0.0313 | 0 | 0 | 2.22 KB |
| master | SendAsync |
netcoreapp3.1 | 5.06μs | 1.56ns | 5.83ns | 0.0377 | 0 | 0 | 2.76 KB |
| master | SendAsync |
net472 | 7.79μs | 2.13ns | 8.25ns | 0.498 | 0 | 0 | 3.15 KB |
| #5929 | SendAsync |
net6.0 | 4.13μs | 1.6ns | 5.77ns | 0.0309 | 0 | 0 | 2.22 KB |
| #5929 | SendAsync |
netcoreapp3.1 | 5.24μs | 3.76ns | 14.6ns | 0.0366 | 0 | 0 | 2.76 KB |
| #5929 | SendAsync |
net472 | 7.75μs | 2.28ns | 8.85ns | 0.497 | 0 | 0 | 3.15 KB |
Benchmarks.Trace.ILoggerBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | EnrichedLog |
net6.0 | 1.64μs | 0.963ns | 3.6ns | 0.023 | 0 | 0 | 1.64 KB |
| master | EnrichedLog |
netcoreapp3.1 | 2.01μs | 0.896ns | 3.35ns | 0.0222 | 0 | 0 | 1.64 KB |
| master | EnrichedLog |
net472 | 2.72μs | 2.69ns | 10.4ns | 0.249 | 0 | 0 | 1.57 KB |
| #5929 | EnrichedLog |
net6.0 | 1.53μs | 1.09ns | 4.21ns | 0.023 | 0 | 0 | 1.64 KB |
| #5929 | EnrichedLog |
netcoreapp3.1 | 2.2μs | 1.54ns | 5.95ns | 0.0218 | 0 | 0 | 1.64 KB |
| #5929 | EnrichedLog |
net472 | 2.72μs | 1.68ns | 6.52ns | 0.249 | 0 | 0 | 1.57 KB |
Benchmarks.Trace.Log4netBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | EnrichedLog |
net6.0 | 115μs | 285ns | 1.11μs | 0.0567 | 0 | 0 | 4.28 KB |
| master | EnrichedLog |
netcoreapp3.1 | 119μs | 223ns | 833ns | 0.0597 | 0 | 0 | 4.28 KB |
| master | EnrichedLog |
net472 | 149μs | 155ns | 601ns | 0.667 | 0.222 | 0 | 4.46 KB |
| #5929 | EnrichedLog |
net6.0 | 114μs | 282ns | 1.09μs | 0.0573 | 0 | 0 | 4.28 KB |
| #5929 | EnrichedLog |
netcoreapp3.1 | 120μs | 354ns | 1.37μs | 0 | 0 | 0 | 4.28 KB |
| #5929 | EnrichedLog |
net472 | 150μs | 191ns | 738ns | 0.673 | 0.224 | 0 | 4.46 KB |
Benchmarks.Trace.NLogBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | EnrichedLog |
net6.0 | 3.08μs | 0.724ns | 2.71ns | 0.0309 | 0 | 0 | 2.2 KB |
| master | EnrichedLog |
netcoreapp3.1 | 4.25μs | 1.81ns | 7.03ns | 0.0297 | 0 | 0 | 2.2 KB |
| master | EnrichedLog |
net472 | 4.83μs | 0.936ns | 3.38ns | 0.319 | 0 | 0 | 2.02 KB |
| #5929 | EnrichedLog |
net6.0 | 3.11μs | 1.15ns | 4.47ns | 0.0311 | 0 | 0 | 2.2 KB |
| #5929 | EnrichedLog |
netcoreapp3.1 | 4.19μs | 2.11ns | 7.88ns | 0.0292 | 0 | 0 | 2.2 KB |
| #5929 | EnrichedLog |
net472 | 4.94μs | 0.844ns | 3.16ns | 0.32 | 0 | 0 | 2.02 KB |
Benchmarks.Trace.RedisBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | SendReceive |
net6.0 | 1.42μs | 0.767ns | 2.97ns | 0.0162 | 0 | 0 | 1.14 KB |
| master | SendReceive |
netcoreapp3.1 | 1.77μs | 1.32ns | 4.95ns | 0.015 | 0 | 0 | 1.14 KB |
| master | SendReceive |
net472 | 2.2μs | 1.69ns | 6.53ns | 0.184 | 0 | 0 | 1.16 KB |
| #5929 | SendReceive |
net6.0 | 1.31μs | 1.09ns | 4.22ns | 0.0157 | 0 | 0 | 1.14 KB |
| #5929 | SendReceive |
netcoreapp3.1 | 1.76μs | 1.93ns | 7.48ns | 0.015 | 0 | 0 | 1.14 KB |
| #5929 | SendReceive |
net472 | 2.22μs | 1.6ns | 5.97ns | 0.184 | 0.00111 | 0 | 1.16 KB |
Benchmarks.Trace.SerilogBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | EnrichedLog |
net6.0 | 2.76μs | 1.38ns | 4.78ns | 0.0221 | 0 | 0 | 1.6 KB |
| master | EnrichedLog |
netcoreapp3.1 | 3.95μs | 1.17ns | 4.53ns | 0.0219 | 0 | 0 | 1.65 KB |
| master | EnrichedLog |
net472 | 4.6μs | 1.63ns | 6.33ns | 0.322 | 0 | 0 | 2.04 KB |
| #5929 | EnrichedLog |
net6.0 | 2.84μs | 1.27ns | 4.94ns | 0.0224 | 0 | 0 | 1.6 KB |
| #5929 | EnrichedLog |
netcoreapp3.1 | 3.96μs | 0.756ns | 2.72ns | 0.0216 | 0 | 0 | 1.65 KB |
| #5929 | EnrichedLog |
net472 | 4.46μs | 2.76ns | 10.7ns | 0.324 | 0 | 0 | 2.04 KB |
Benchmarks.Trace.SpanBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | StartFinishSpan |
net6.0 | 400ns | 0.675ns | 2.61ns | 0.00802 | 0 | 0 | 576 B |
| master | StartFinishSpan |
netcoreapp3.1 | 547ns | 1.85ns | 6.69ns | 0.00772 | 0 | 0 | 576 B |
| master | StartFinishSpan |
net472 | 660ns | 0.227ns | 0.878ns | 0.0916 | 0 | 0 | 578 B |
| master | StartFinishScope |
net6.0 | 513ns | 0.596ns | 2.31ns | 0.00981 | 0 | 0 | 696 B |
| master | StartFinishScope |
netcoreapp3.1 | 741ns | 0.291ns | 1.13ns | 0.00933 | 0 | 0 | 696 B |
| master | StartFinishScope |
net472 | 859ns | 0.632ns | 2.36ns | 0.104 | 0 | 0 | 658 B |
| #5929 | StartFinishSpan |
net6.0 | 395ns | 0.255ns | 0.988ns | 0.0081 | 0 | 0 | 576 B |
| #5929 | StartFinishSpan |
netcoreapp3.1 | 559ns | 0.238ns | 0.89ns | 0.00783 | 0 | 0 | 576 B |
| #5929 | StartFinishSpan |
net472 | 596ns | 0.41ns | 1.59ns | 0.0917 | 0 | 0 | 578 B |
| #5929 | StartFinishScope |
net6.0 | 498ns | 0.17ns | 0.658ns | 0.00976 | 0 | 0 | 696 B |
| #5929 | StartFinishScope |
netcoreapp3.1 | 813ns | 0.53ns | 2.05ns | 0.00939 | 0 | 0 | 696 B |
| #5929 | StartFinishScope |
net472 | 833ns | 0.969ns | 3.75ns | 0.104 | 0 | 0 | 658 B |
Benchmarks.Trace.TraceAnnotationsBenchmark - Faster 🎉 Same allocations ✔️
Faster 🎉 in #5929
Benchmark
base/diff
Base Median (ns)
Diff Median (ns)
Modality
Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin‑net6.0
1.128
673.62
597.22
| Benchmark | base/diff | Base Median (ns) | Diff Median (ns) | Modality |
|---|---|---|---|---|
| Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin‑net6.0 | 1.128 | 673.62 | 597.22 |
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | RunOnMethodBegin |
net6.0 | 673ns | 0.659ns | 2.38ns | 0.00958 | 0 | 0 | 696 B |
| master | RunOnMethodBegin |
netcoreapp3.1 | 942ns | 0.427ns | 1.65ns | 0.00901 | 0 | 0 | 696 B |
| master | RunOnMethodBegin |
net472 | 1.12μs | 1.54ns | 5.55ns | 0.104 | 0 | 0 | 658 B |
| #5929 | RunOnMethodBegin |
net6.0 | 597ns | 0.373ns | 1.44ns | 0.00959 | 0 | 0 | 696 B |
| #5929 | RunOnMethodBegin |
netcoreapp3.1 | 922ns | 0.541ns | 2.09ns | 0.00928 | 0 | 0 | 696 B |
| #5929 | RunOnMethodBegin |
net472 | 1.08μs | 0.198ns | 0.766ns | 0.104 | 0 | 0 | 658 B |
andrewlock
left a comment
There was a problem hiding this comment.
LGTM AFAICT but you know, it's C++ so.... yeah
| auto catchBegin = rewriterWrapper_void.CallMember(object_to_string_member_ref, true); | ||
| rewriterWrapper_void.StLocal(6); | ||
| rewriterWrapper_void.LoadStr(error_token); | ||
| rewriterWrapper_void.LoadLocal(6); | ||
| rewriterWrapper_void.CallMember(string_concat_member_ref, false); | ||
| rewriterWrapper_void.StLocal(6); | ||
| rewriterWrapper_void.LoadLocal(6); | ||
| rewriterWrapper_void.CallMember(string_to_char_array_member_ref, true); | ||
| rewriterWrapper_void.StLocal(8); | ||
| rewriterWrapper_void.LoadLocal(8); | ||
| rewriterWrapper_void.CreateInstr(CEE_LDC_I4_0); | ||
| rewriterWrapper_void.CreateInstr(CEE_LDELEMA, char_type_ref); | ||
| rewriterWrapper_void.CreateInstr(CEE_CONV_U); | ||
| rewriterWrapper_void.StLocal(7); | ||
| rewriterWrapper_void.CreateInstr(CEE_LDC_I4_3); | ||
| rewriterWrapper_void.LoadLocal(7); | ||
| rewriterWrapper_void.LoadLocal(6); | ||
| rewriterWrapper_void.CallMember(string_get_length_member_ref, true); | ||
| rewriterWrapper_void.LoadInt64((INT64)&NativeLog); | ||
| rewriterWrapper_void.CreateInstr(CEE_CONV_I); | ||
| rewriterWrapper_void.CreateInstr(CEE_CALLI, log_signature_token); | ||
| rewriterWrapper_void.CreateInstr(CEE_LDNULL); | ||
| rewriterWrapper_void.StLocal(8); | ||
| auto catchEnd = rewriterWrapper_void.CreateInstr(CEE_LEAVE_S, returnInstr); |
There was a problem hiding this comment.
Would love if we could get a https://sharplab.io/ kind of view of this 😄
| hr = metadata_emit->DefineTypeRefByName(corlib_ref, WStr("System.Char"), &char_type_ref); | ||
| if (FAILED(hr)) | ||
| { | ||
| Logger::Warn("GenerateVoidILStartupMethod: DefineTypeRefByName::System.Char failed"); |
There was a problem hiding this comment.
Shouldn't all these Warns be Errs? If this fails something nasty has happened
There was a problem hiding this comment.
True, but the existing logs are all warnings. I can we can change that in another PR
## Summary of changes Wrap the call to the managed loader in a try/catch, and use a native logger to log the exception if any. ## Reason for change There's already a try/catch in the managed loader, but in some situations we can fail before even getting there (if jitting the method failed, for instance because of a trimmed runtime). Also, the managed loader logger can fail. ## Implementation details This PR adds a try/catch in the code emitted to load the managed loader. In the catch clause, we call a native logging function, with a direct unmanaged `calli` call to its address. Because we have now this outer catch block, I removed the `IsInSsi` logic which isn't needed anymore.
…#5939) ## Summary of changes Wrap the call to the managed loader in a try/catch, and use a native logger to log the exception if any. ## Reason for change There's already a try/catch in the managed loader, but in some situations we can fail before even getting there (if jitting the method failed, for instance because of a trimmed runtime). Also, the managed loader logger can fail. ## Implementation details This PR adds a try/catch in the code emitted to load the managed loader. In the catch clause, we call a native logging function, with a direct unmanaged `calli` call to its address. Because we have now this outer catch block, I removed the `IsInSsi` logic which isn't needed anymore. ## Other details Backport of #5929 Co-authored-by: Kevin Gosse <[email protected]>
Summary of changes
Wrap the call to the managed loader in a try/catch, and use a native logger to log the exception if any.
Reason for change
There's already a try/catch in the managed loader, but in some situations we can fail before even getting there (if jitting the method failed, for instance because of a trimmed runtime). Also, the managed loader logger can fail.
Implementation details
This PR adds a try/catch in the code emitted to load the managed loader. In the catch clause, we call a native logging function, with a direct unmanaged
callicall to its address.Because we have now this outer catch block, I removed the
IsInSsilogic which isn't needed anymore.