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

[Profiler] Add custom dl_iterate_phdr and use it in libunwind #5660

Merged
merged 11 commits into from
Jun 28, 2024

Conversation

gleocadie
Copy link
Collaborator

@gleocadie gleocadie commented Jun 6, 2024

Summary of changes

Add a custom dl_iterate_phdr function which will be used by libunwind.

Reason for change

Currently, when unwind callstacks, libunwind uses dl_iterate_phdr to resolve instruction pointers into shared objects files.
We recently hit a deadlock case:

  • The thread to sample was allocating memory when interrupting by our sampling thread. This means that the malloc lock was acquired. When libunwind started to unwind the callstack, the execution got blocked on a lock in dl_iterate_phdr. This lock is shared amongst other functions (dlopen, dlclose, dladdr...)
  • At the same time, another thread acquired the dlopen & co lock, started loading a library (using dlopen) and was trying to allocate memory, but got blocked on the malloc lock.

Implementation details

  • Create a cache that will be filled by struct dl_phdr_info* objects. Update the cache if needed every time the sampling thread is about to interrupt a thread.
  • Wrap dlclose & dlopen to know if a change occured in the loaded libraries set.
  • Implement a custom dl_iterate_phdr function which will use the cache and instruct libunwind to use it.

Test coverage

Other details

@github-actions github-actions bot added the area:profiler Issues related to the continous-profiler label Jun 6, 2024
@datadog-ddstaging
Copy link

datadog-ddstaging bot commented Jun 6, 2024

Datadog Report

Branch report: gleocadie/add-custom-dl_iterate_phdr
Commit report: 4a50889
Test service: dd-trace-dotnet

✅ 0 Failed, 351666 Passed, 1929 Skipped, 30h 20m 17.74s Total Time
❄️ 2 New Flaky
⌛ 3 Performance Regressions

New Flaky Tests (2)

  • CheckSmokeForOldWayToStackWalk - Datadog.Profiler.SmokeTests.ExceptionGeneratorTest - Last Failure

    Expand for error
     The test Samples.ExceptionGenerator is running for too long or was lost
    
  • NoExceptions - Datadog.Trace.ClrProfiler.IntegrationTests.SmokeTests.AssemblyLoadContextRedirectSmokeTest - Last Failure

    Expand for error
     Expected no errors in smoke test: ptrace(ATTACH, 13745) FAILED Operation not permitted
     
     Expected: True
     Actual:   False
    

⌛ Performance Regressions vs Default Branch (3)

  • CallTarget+Inlining+NGEN - Samples.HttpMessageHandler.windows.net60.json.scenarios 962.79ms (+106.73ms, +12%) - Details
  • CallTarget+Inlining+NGEN - Samples.HttpMessageHandler.windows.netcoreapp31.json.scenarios 950.8ms (+80.82ms, +9%) - Details
  • Baseline - Samples.HttpMessageHandler.windows.net60.json.scenarios 290.25ms (+24.68ms, +9%) - Details

@andrewlock
Copy link
Member

andrewlock commented Jun 6, 2024

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:

  • Welch test with statistical test for significance of 5%
  • Only results indicating a difference greater than 5% and 5 ms are considered.

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).

gantt
    title Execution time (ms) FakeDbCommand (.NET Framework 4.6.2) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5660) - mean (75ms)  : 63, 86
     .   : milestone, 75,
    master - mean (74ms)  : 65, 83
     .   : milestone, 74,

    section CallTarget+Inlining+NGEN
    This PR (5660) - mean (1,006ms)  : 964, 1048
     .   : milestone, 1006,
    master - mean (991ms)  : 973, 1009
     .   : milestone, 991,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5660) - mean (111ms)  : 108, 114
     .   : milestone, 111,
    master - mean (110ms)  : 107, 113
     .   : milestone, 110,

    section CallTarget+Inlining+NGEN
    This PR (5660) - mean (734ms)  : 694, 775
     .   : milestone, 734,
    master - mean (698ms)  : 675, 722
     .   : milestone, 698,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5660) - mean (99ms)  : 97, 101
     .   : milestone, 99,
    master - mean (93ms)  : 90, 96
     .   : milestone, 93,

    section CallTarget+Inlining+NGEN
    This PR (5660) - mean (678ms)  : 655, 701
     .   : milestone, 678,
    master - mean (657ms)  : 630, 683
     .   : milestone, 657,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.6.2) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5660) - mean (192ms)  : 187, 197
     .   : milestone, 192,
    master - mean (192ms)  : 188, 196
     .   : milestone, 192,

    section CallTarget+Inlining+NGEN
    This PR (5660) - mean (1,089ms)  : 1060, 1118
     .   : milestone, 1089,
    master - mean (1,081ms)  : 1059, 1103
     .   : milestone, 1081,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5660) - mean (277ms)  : 272, 282
     .   : milestone, 277,
    master - mean (276ms)  : 271, 281
     .   : milestone, 276,

    section CallTarget+Inlining+NGEN
    This PR (5660) - mean (876ms)  : 852, 900
     .   : milestone, 876,
    master - mean (874ms)  : 849, 899
     .   : milestone, 874,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5660) - mean (267ms)  : 263, 271
     .   : milestone, 267,
    master - mean (269ms)  : 263, 275
     .   : milestone, 269,

    section CallTarget+Inlining+NGEN
    This PR (5660) - mean (863ms)  : 838, 887
     .   : milestone, 863,
    master - mean (867ms)  : 839, 894
     .   : milestone, 867,

Loading

@andrewlock
Copy link
Member

andrewlock commented Jun 6, 2024

Throughput/Crank Report:zap:

Throughput results for AspNetCoreSimpleController comparing the following branches/commits:

Cases where throughput results for the PR are worse than latest master (5% drop or greater), results are shown in red.

Note that these results are based on a single point-in-time result for each branch. For full results, see one of the many, many dashboards!

gantt
    title Throughput Linux x64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (5660) (11.947M)   : 0, 11947217
    master (11.753M)   : 0, 11753412
    benchmarks/2.9.0 (11.542M)   : 0, 11542126

    section Automatic
    This PR (5660) (8.110M)   : 0, 8109706
    master (7.853M)   : 0, 7853279
    benchmarks/2.9.0 (8.263M)   : 0, 8262905

    section Trace stats
    master (8.259M)   : 0, 8258966

    section Manual
    This PR (5660) (10.287M)   : 0, 10287299
    master (9.899M)   : 0, 9899401

    section Manual + Automatic
    This PR (5660) (7.681M)   : 0, 7680864
    master (7.433M)   : 0, 7432897

    section Version Conflict
    master (6.731M)   : 0, 6730574

Loading
gantt
    title Throughput Linux arm64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (5660) (9.343M)   : 0, 9342723
    master (9.574M)   : 0, 9574121
    benchmarks/2.9.0 (9.596M)   : 0, 9596140

    section Automatic
    This PR (5660) (6.500M)   : 0, 6499572
    master (6.671M)   : 0, 6671192

    section Trace stats
    master (6.990M)   : 0, 6990244

    section Manual
    This PR (5660) (8.187M)   : 0, 8186573
    master (8.307M)   : 0, 8306500

    section Manual + Automatic
    This PR (5660) (6.210M)   : 0, 6209609
    master (6.251M)   : 0, 6250704

    section Version Conflict
    master (5.762M)   : 0, 5761603

Loading
gantt
    title Throughput Windows x64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (5660) (9.682M)   : 0, 9682346
    master (10.202M)   : 0, 10201759
    benchmarks/2.9.0 (10.213M)   : 0, 10213239

    section Automatic
    This PR (5660) (6.911M)   : 0, 6910573
    master (7.212M)   : 0, 7212394
    benchmarks/2.9.0 (7.482M)   : 0, 7482023

    section Trace stats
    master (7.549M)   : 0, 7549360

    section Manual
    This PR (5660) (8.799M)   : 0, 8798971
    master (9.013M)   : 0, 9012822

    section Manual + Automatic
    This PR (5660) (6.663M)   : crit ,0, 6663489
    master (7.018M)   : 0, 7017920

    section Version Conflict
    master (6.365M)   : 0, 6365432

Loading

@andrewlock
Copy link
Member

andrewlock commented Jun 6, 2024

Benchmarks Report for tracer 🐌

Benchmarks for #5660 compared to master:

  • 2 benchmarks are faster, with geometric mean 1.136
  • 1 benchmarks have fewer allocations

The following thresholds were used for comparing the benchmark speeds:

  • Mann–Whitney U test with statistical test for significance of 5%
  • Only results indicating a difference greater than 10% and 0.3 ns are considered.

Allocation changes below 0.5% are ignored.

Benchmark details

Benchmarks.Trace.ActivityBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartStopWithChild net6.0 7.78μs 43.6ns 279ns 0.0154 0.00768 0 5.42 KB
master StartStopWithChild netcoreapp3.1 9.78μs 52.8ns 280ns 0.0241 0.00963 0 5.62 KB
master StartStopWithChild net472 16μs 49ns 190ns 1.01 0.293 0.0952 6.07 KB
#5660 StartStopWithChild net6.0 7.72μs 43.7ns 293ns 0.0152 0.0076 0 5.42 KB
#5660 StartStopWithChild netcoreapp3.1 10μs 56.4ns 374ns 0.0246 0.00983 0 5.61 KB
#5660 StartStopWithChild net472 16.2μs 65ns 252ns 1.04 0.311 0.0956 6.07 KB
Benchmarks.Trace.AgentWriterBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 489μs 145ns 563ns 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 640μs 294ns 1.14μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 838μs 306ns 1.19μs 0.414 0 0 3.3 KB
#5660 WriteAndFlushEnrichedTraces net6.0 473μs 77ns 288ns 0 0 0 2.7 KB
#5660 WriteAndFlushEnrichedTraces netcoreapp3.1 638μs 204ns 791ns 0 0 0 2.7 KB
#5660 WriteAndFlushEnrichedTraces net472 830μs 155ns 560ns 0.414 0 0 3.3 KB
Benchmarks.Trace.AspNetCoreBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendRequest net6.0 170μs 229ns 886ns 0.168 0 0 18.44 KB
master SendRequest netcoreapp3.1 191μs 299ns 1.16μs 0.192 0 0 20.6 KB
master SendRequest net472 0.000295ns 0.000179ns 0.000692ns 0 0 0 0 b
#5660 SendRequest net6.0 169μs 173ns 669ns 0.169 0 0 18.44 KB
#5660 SendRequest netcoreapp3.1 192μs 195ns 754ns 0.191 0 0 20.6 KB
#5660 SendRequest net472 0.000353ns 0.000163ns 0.000609ns 0 0 0 0 b
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed ✔️ Fewer allocations 🎉

Fewer allocations 🎉 in #5660

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑netcoreapp3.1 41.89 KB 41.53 KB -351 B -0.84%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 547μs 312ns 1.12μs 0.543 0 0 41.65 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 664μs 946ns 3.67μs 0.332 0 0 41.89 KB
master WriteAndFlushEnrichedTraces net472 852μs 3.28μs 12.7μs 8.36 2.64 0.44 53.25 KB
#5660 WriteAndFlushEnrichedTraces net6.0 540μs 302ns 1.13μs 0.558 0 0 41.45 KB
#5660 WriteAndFlushEnrichedTraces netcoreapp3.1 646μs 1.57μs 5.87μs 0.324 0 0 41.53 KB
#5660 WriteAndFlushEnrichedTraces net472 862μs 4.3μs 18.3μs 8.04 2.23 0.446 53.23 KB
Benchmarks.Trace.DbCommandBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master ExecuteNonQuery net6.0 1μs 0.463ns 1.79ns 0.011 0 0 808 B
master ExecuteNonQuery netcoreapp3.1 1.48μs 0.933ns 3.61ns 0.011 0 0 808 B
master ExecuteNonQuery net472 1.74μs 0.748ns 2.9ns 0.122 0 0 770 B
#5660 ExecuteNonQuery net6.0 1.07μs 0.795ns 3.08ns 0.0112 0 0 808 B
#5660 ExecuteNonQuery netcoreapp3.1 1.43μs 0.442ns 1.65ns 0.0108 0 0 808 B
#5660 ExecuteNonQuery net472 1.74μs 0.752ns 2.71ns 0.122 0 0 770 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.23μs 0.499ns 1.93ns 0.0141 0 0 976 B
master CallElasticsearch netcoreapp3.1 1.48μs 0.716ns 2.58ns 0.0134 0 0 976 B
master CallElasticsearch net472 2.43μs 1.49ns 5.77ns 0.157 0.00121 0 995 B
master CallElasticsearchAsync net6.0 1.23μs 1.16ns 4.34ns 0.0131 0 0 952 B
master CallElasticsearchAsync netcoreapp3.1 1.62μs 0.763ns 2.85ns 0.0138 0 0 1.02 KB
master CallElasticsearchAsync net472 2.65μs 1.89ns 7.33ns 0.167 0.00132 0 1.05 KB
#5660 CallElasticsearch net6.0 1.27μs 1.53ns 5.91ns 0.0133 0 0 976 B
#5660 CallElasticsearch netcoreapp3.1 1.56μs 1.55ns 5.79ns 0.0132 0 0 976 B
#5660 CallElasticsearch net472 2.5μs 2.06ns 7.71ns 0.157 0.00125 0 995 B
#5660 CallElasticsearchAsync net6.0 1.26μs 0.569ns 2.13ns 0.0132 0 0 952 B
#5660 CallElasticsearchAsync netcoreapp3.1 1.58μs 1.63ns 5.87ns 0.0135 0 0 1.02 KB
#5660 CallElasticsearchAsync net472 2.67μs 2ns 7.75ns 0.166 0.00134 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.22μs 0.474ns 1.84ns 0.0135 0 0 952 B
master ExecuteAsync netcoreapp3.1 1.68μs 2.5ns 9.69ns 0.0126 0 0 952 B
master ExecuteAsync net472 1.78μs 1.12ns 4.32ns 0.145 0 0 915 B
#5660 ExecuteAsync net6.0 1.19μs 0.555ns 2.15ns 0.0132 0 0 952 B
#5660 ExecuteAsync netcoreapp3.1 1.62μs 0.835ns 3.13ns 0.0128 0 0 952 B
#5660 ExecuteAsync net472 1.78μs 0.898ns 3.48ns 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.22μs 2.32ns 8.99ns 0.0295 0 0 2.22 KB
master SendAsync netcoreapp3.1 5.12μs 2.73ns 10.2ns 0.0382 0 0 2.76 KB
master SendAsync net472 7.52μs 1.46ns 5.45ns 0.499 0 0 3.15 KB
#5660 SendAsync net6.0 4.1μs 1.55ns 5.79ns 0.0308 0 0 2.22 KB
#5660 SendAsync netcoreapp3.1 4.97μs 2.71ns 10.1ns 0.0374 0 0 2.76 KB
#5660 SendAsync net472 7.5μs 1.66ns 6ns 0.499 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.61μs 0.474ns 1.71ns 0.0226 0 0 1.64 KB
master EnrichedLog netcoreapp3.1 2.1μs 0.702ns 2.63ns 0.0221 0 0 1.64 KB
master EnrichedLog net472 2.62μs 1.87ns 7.01ns 0.25 0 0 1.57 KB
#5660 EnrichedLog net6.0 1.52μs 0.837ns 3.13ns 0.0228 0 0 1.64 KB
#5660 EnrichedLog netcoreapp3.1 2.07μs 1.17ns 4.53ns 0.0226 0 0 1.64 KB
#5660 EnrichedLog net472 2.57μs 1.58ns 5.92ns 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 114μs 261ns 1.01μs 0.057 0 0 4.28 KB
master EnrichedLog netcoreapp3.1 119μs 188ns 726ns 0.0605 0 0 4.28 KB
master EnrichedLog net472 147μs 97.3ns 377ns 0.658 0.219 0 4.46 KB
#5660 EnrichedLog net6.0 115μs 154ns 595ns 0.057 0 0 4.28 KB
#5660 EnrichedLog netcoreapp3.1 117μs 158ns 611ns 0.059 0 0 4.28 KB
#5660 EnrichedLog net472 147μs 87.3ns 338ns 0.658 0.219 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 2.93μs 0.882ns 3.42ns 0.0304 0 0 2.2 KB
master EnrichedLog netcoreapp3.1 4.1μs 1.35ns 4.86ns 0.0288 0 0 2.2 KB
master EnrichedLog net472 4.87μs 5.57ns 19.3ns 0.32 0 0 2.02 KB
#5660 EnrichedLog net6.0 3.14μs 0.923ns 3.57ns 0.0298 0 0 2.2 KB
#5660 EnrichedLog netcoreapp3.1 4.03μs 0.997ns 3.86ns 0.0299 0 0 2.2 KB
#5660 EnrichedLog net472 4.94μs 1.21ns 4.68ns 0.318 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.32μs 0.73ns 2.73ns 0.0159 0 0 1.14 KB
master SendReceive netcoreapp3.1 1.74μs 1.63ns 6.32ns 0.0149 0 0 1.14 KB
master SendReceive net472 1.98μs 1.51ns 5.67ns 0.183 0.000988 0 1.16 KB
#5660 SendReceive net6.0 1.44μs 1.18ns 4.56ns 0.0158 0 0 1.14 KB
#5660 SendReceive netcoreapp3.1 1.82μs 0.589ns 2.12ns 0.0155 0 0 1.14 KB
#5660 SendReceive net472 2.02μs 0.603ns 2.17ns 0.183 0 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 0.51ns 1.91ns 0.022 0 0 1.6 KB
master EnrichedLog netcoreapp3.1 3.83μs 2.96ns 11.1ns 0.0226 0 0 1.65 KB
master EnrichedLog net472 4.34μs 1.34ns 5.02ns 0.323 0 0 2.04 KB
#5660 EnrichedLog net6.0 2.72μs 0.753ns 2.92ns 0.0218 0 0 1.6 KB
#5660 EnrichedLog netcoreapp3.1 3.91μs 1.35ns 5.24ns 0.0216 0 0 1.65 KB
#5660 EnrichedLog net472 4.49μs 3.5ns 12.6ns 0.322 0 0 2.04 KB
Benchmarks.Trace.SpanBenchmark - Faster 🎉 Same allocations ✔️

Faster 🎉 in #5660

Benchmark base/diff Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.SpanBenchmark.StartFinishScope‑net6.0 1.148 550.64 479.44
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑net472 1.123 685.60 610.64

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartFinishSpan net6.0 403ns 0.338ns 1.31ns 0.0081 0 0 576 B
master StartFinishSpan netcoreapp3.1 602ns 0.431ns 1.55ns 0.00789 0 0 576 B
master StartFinishSpan net472 686ns 0.62ns 2.4ns 0.0915 0 0 578 B
master StartFinishScope net6.0 551ns 0.815ns 3.16ns 0.00967 0 0 696 B
master StartFinishScope netcoreapp3.1 703ns 0.375ns 1.45ns 0.00948 0 0 696 B
master StartFinishScope net472 869ns 0.795ns 3.08ns 0.105 0 0 658 B
#5660 StartFinishSpan net6.0 391ns 0.172ns 0.668ns 0.00806 0 0 576 B
#5660 StartFinishSpan netcoreapp3.1 573ns 0.791ns 3.06ns 0.0079 0 0 576 B
#5660 StartFinishSpan net472 610ns 0.523ns 2.03ns 0.0916 0 0 578 B
#5660 StartFinishScope net6.0 479ns 0.142ns 0.55ns 0.00988 0 0 696 B
#5660 StartFinishScope netcoreapp3.1 757ns 0.286ns 1.11ns 0.00942 0 0 696 B
#5660 StartFinishScope net472 847ns 0.557ns 2.16ns 0.104 0 0 658 B
Benchmarks.Trace.TraceAnnotationsBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master RunOnMethodBegin net6.0 607ns 0.164ns 0.636ns 0.00971 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 882ns 0.563ns 2.1ns 0.0093 0 0 696 B
master RunOnMethodBegin net472 1.04μs 0.653ns 2.53ns 0.104 0 0 658 B
#5660 RunOnMethodBegin net6.0 588ns 0.333ns 1.29ns 0.00966 0 0 696 B
#5660 RunOnMethodBegin netcoreapp3.1 918ns 1.43ns 5.54ns 0.00928 0 0 696 B
#5660 RunOnMethodBegin net472 1.1μs 1.08ns 4.19ns 0.104 0 0 658 B

Comment on lines 59 to 68
_phdr = std::make_unique<ElfW(Phdr)[]>(source->dlpi_phnum);
memcpy(_phdr.get(), source->dlpi_phdr, sizeof(ElfW(Phdr)) * source->dlpi_phnum);
destination.dlpi_phdr = _phdr.get();

// Those fields appeared in glibc 2.4 (with two others).
// Since we compile with glibc 2.17, those fields are present (size of struct dl_phdr_info contains those fields),
// so need to check the size/offset.
// We do not know how to copy dlpi_tls_data field and libunwind does not use them, we can nullify/zeroify them
destination.dlpi_tls_modid = 0;
destination.dlpi_tls_data = nullptr;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

wonder what about alpine 🤔 . Will check

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok it looks safe on musl libc: the oldest one I could find contains those 2 fields. The oldest musl libc used by our customers is 1.1.22 and dl_phdr_info contains those fields.

@gleocadie gleocadie marked this pull request as ready for review June 10, 2024 09:08
@gleocadie gleocadie requested a review from a team as a code owner June 10, 2024 09:08
@gleocadie gleocadie force-pushed the gleocadie/add-custom-dl_iterate_phdr branch 4 times, most recently from 47ecbe4 to abe5f8d Compare June 10, 2024 10:22
Copy link
Contributor

@chrisnas chrisnas left a comment

Choose a reason for hiding this comment

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

LGTM

@gleocadie gleocadie force-pushed the gleocadie/add-custom-dl_iterate_phdr branch 5 times, most recently from 0961502 to 95fbf54 Compare June 24, 2024 10:56
@gleocadie gleocadie force-pushed the gleocadie/add-custom-dl_iterate_phdr branch 2 times, most recently from 48712f4 to 2c0b163 Compare June 26, 2024 14:38
@gleocadie gleocadie force-pushed the gleocadie/add-custom-dl_iterate_phdr branch from 2c0b163 to 83931f8 Compare June 27, 2024 07:59
@gleocadie gleocadie merged commit 8cbbb4b into master Jun 28, 2024
62 of 65 checks passed
@gleocadie gleocadie deleted the gleocadie/add-custom-dl_iterate_phdr branch June 28, 2024 09:52
@github-actions github-actions bot added this to the vNext-v2 milestone Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:profiler Issues related to the continous-profiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants