Skip to content

Move loading dynamic library mechanism to shared code#2624

Merged
gleocadie merged 5 commits into
masterfrom
gleocadie/share-dynamic-loading-mechanism
Apr 8, 2022
Merged

Move loading dynamic library mechanism to shared code#2624
gleocadie merged 5 commits into
masterfrom
gleocadie/share-dynamic-loading-mechanism

Conversation

@gleocadie

Copy link
Copy Markdown
Collaborator

Summary of changes

Reason for change

Dynamic loading a library is not shared. Soon the profiler will need to load dynamically a library and it will be better to share the code.

Implementation details

Create a DynamicLibraryBase and DynamicCOMLibrary classes to wrap the loading and the access to member functions.
Move the code in the shared folder hierarchy.

Test coverage

All the current tests must pass (tracer windows integration tests....)

Other details

@gleocadie gleocadie added the area:native-library Automatic instrumentation native C++ code (Datadog.Trace.ClrProfiler.Native) label Mar 31, 2022
@gleocadie gleocadie changed the title Move dynamic library mechanism to shared code Move loading dynamic library mechanism to shared code Mar 31, 2022
@gleocadie
gleocadie force-pushed the gleocadie/share-dynamic-loading-mechanism branch from 4fa8453 to 41bce4d Compare March 31, 2022 13:44
@gleocadie
gleocadie marked this pull request as ready for review March 31, 2022 14:09
@gleocadie
gleocadie requested review from a team as code owners March 31, 2022 14:09
@gleocadie
gleocadie requested a review from tonyredondo March 31, 2022 14:09
@gleocadie
gleocadie force-pushed the gleocadie/share-dynamic-loading-mechanism branch from 41bce4d to 992d4d9 Compare March 31, 2022 16:35
@andrewlock

This comment has been minimized.

@andrewlock

This comment has been minimized.

@andrewlock

This comment has been minimized.

@andrewlock

This comment has been minimized.

@andrewlock

This comment has been minimized.

@tonyredondo tonyredondo left a comment

Copy link
Copy Markdown
Member

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/share-dynamic-loading-mechanism branch from fecb442 to 0f03f5a Compare April 7, 2022 18:50
@andrewlock

Copy link
Copy Markdown
Member

Code Coverage Report 📊

✔️ Merging #2624 into master will not change line coverage
✔️ Merging #2624 into master will not change branch coverage
✔️ Merging #2624 into master will not change complexity

master #2624 Change
Lines 13438 / 18464 13374 / 18464
Lines % 73% 72% 0% ✔️
Branches 7754 / 11017 7721 / 11017
Branches % 70% 70% 0% ✔️
Complexity 12307 12307 0 ✔️

View the full report for further details:

Datadog.Trace Breakdown ✔️

master #2624 Change
Lines % 73% 72% 0% ✔️
Branches % 70% 70% 0% ✔️
Complexity 12307 12307 0 ✔️

The following classes have significant coverage changes.

File Line coverage change Branch coverage change Complexity change
Datadog.Trace.Ci.Processors.OriginTagTraceProcessor -9% -17% 0 ✔️

View the full reports for further details:

@andrewlock

Copy link
Copy Markdown
Member

Benchmarks Report 🐌

Benchmarks for #2624 compared to master:

  • 1 benchmarks are slower, with geometric mean 1.189
  • All benchmarks have the same 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.AgentWriterBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net472 926μs 4.19μs 19.2μs 0 0 0 3.16 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 688μs 2.44μs 8.82μs 0 0 0 2.57 KB
#2624 WriteAndFlushEnrichedTraces net472 918μs 3.65μs 15μs 0 0 0 3.16 KB
#2624 WriteAndFlushEnrichedTraces netcoreapp3.1 702μs 3.61μs 17μs 0 0 0 2.57 KB
Benchmarks.Trace.AppSecBodyBenchmark - Slower ⚠️ Same allocations ✔️

Slower ⚠️ in #2624

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.AppSecBodyBenchmark.BodyExtractorMoreComplexBody‑netcoreapp3.1 1.189 20,912.61 24,862.77

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master AllCycleSimpleBody net472 295ns 1.24ns 4.49ns 0.052 0 0 329 B
master AllCycleSimpleBody netcoreapp3.1 378ns 1.83ns 7.55ns 0.00445 0 0 328 B
master AllCycleMoreComplexBody net472 291ns 1.25ns 4.32ns 0.0482 0 0 305 B
master AllCycleMoreComplexBody netcoreapp3.1 358ns 1.23ns 4.75ns 0.00431 0 0 304 B
master BodyExtractorSimpleBody net472 440ns 2.34ns 11.9ns 0.0569 0 0 361 B
master BodyExtractorSimpleBody netcoreapp3.1 478ns 2.07ns 8ns 0.00377 0 0 272 B
master BodyExtractorMoreComplexBody net472 24.7μs 136ns 905ns 1.19 0.012 0 7.62 KB
master BodyExtractorMoreComplexBody netcoreapp3.1 21μs 70ns 271ns 0.0941 0 0 6.75 KB
#2624 AllCycleSimpleBody net472 291ns 1.02ns 3.93ns 0.0521 0 0 329 B
#2624 AllCycleSimpleBody netcoreapp3.1 375ns 1.27ns 4.91ns 0.00441 0 0 328 B
#2624 AllCycleMoreComplexBody net472 290ns 0.926ns 3.59ns 0.0482 0 0 305 B
#2624 AllCycleMoreComplexBody netcoreapp3.1 366ns 1.68ns 10.3ns 0.00418 0 0 304 B
#2624 BodyExtractorSimpleBody net472 422ns 1.71ns 6.39ns 0.057 0 0 361 B
#2624 BodyExtractorSimpleBody netcoreapp3.1 435ns 2.14ns 8.57ns 0.00368 0 0 272 B
#2624 BodyExtractorMoreComplexBody net472 24μs 98.1ns 380ns 1.18 0.0122 0 7.62 KB
#2624 BodyExtractorMoreComplexBody netcoreapp3.1 24.9μs 107ns 414ns 0.0876 0 0 6.75 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 net472 0ns 0ns 0ns 0 0 0 0 b
master SendRequest netcoreapp3.1 291μs 611ns 2.2μs 0.286 0 0 19.74 KB
#2624 SendRequest net472 0ns 0ns 0ns 0 0 0 0 b
#2624 SendRequest netcoreapp3.1 296μs 832ns 3.11μs 0.286 0 0 19.74 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 net472 1.8μs 10.2ns 66.7ns 0.0943 0.000865 0 594 B
master ExecuteNonQuery netcoreapp3.1 1.46μs 7.12ns 30.2ns 0.0089 0 0 632 B
#2624 ExecuteNonQuery net472 1.74μs 9.25ns 48.9ns 0.0941 0.000904 0 594 B
#2624 ExecuteNonQuery netcoreapp3.1 1.45μs 2.79ns 9.66ns 0.00878 0 0 632 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 net472 2.8μs 15.1ns 80.1ns 0.126 0 0 803 B
master CallElasticsearch netcoreapp3.1 1.71μs 8.14ns 45.3ns 0.0108 0 0 792 B
master CallElasticsearchAsync net472 3.01μs 15.9ns 84.2ns 0.149 0.00186 0 939 B
master CallElasticsearchAsync netcoreapp3.1 1.86μs 8.86ns 34.3ns 0.0126 0 0 912 B
#2624 CallElasticsearch net472 2.64μs 9.88ns 35.6ns 0.126 0 0 803 B
#2624 CallElasticsearch netcoreapp3.1 1.69μs 7.06ns 26.4ns 0.011 0 0 792 B
#2624 CallElasticsearchAsync net472 2.92μs 11.6ns 45.1ns 0.148 0 0 939 B
#2624 CallElasticsearchAsync netcoreapp3.1 1.8μs 6.57ns 24.6ns 0.0124 0 0 912 B
Benchmarks.Trace.GraphQLBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master ExecuteAsync net472 3.13μs 10.3ns 40.1ns 0.167 0.00153 0 1.06 KB
master ExecuteAsync netcoreapp3.1 2.09μs 10.3ns 42.4ns 0.0145 0 0 1.03 KB
#2624 ExecuteAsync net472 3.08μs 9.55ns 37ns 0.168 0 0 1.06 KB
#2624 ExecuteAsync netcoreapp3.1 2.11μs 11.4ns 65.4ns 0.0141 0 0 1.03 KB
Benchmarks.Trace.HttpClientBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendAsync net472 6.74μs 27.7ns 124ns 0.362 0 0 2.28 KB
master SendAsync netcoreapp3.1 4.74μs 17.6ns 63.4ns 0.0304 0 0 2.21 KB
#2624 SendAsync net472 6.8μs 26.9ns 101ns 0.36 0 0 2.28 KB
#2624 SendAsync netcoreapp3.1 4.86μs 17.4ns 65.1ns 0.0314 0 0 2.21 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 net472 3.4μs 10.1ns 36.3ns 0.228 0 0 1.45 KB
master EnrichedLog netcoreapp3.1 3.07μs 9.29ns 34.8ns 0.0213 0 0 1.53 KB
#2624 EnrichedLog net472 3.51μs 20ns 153ns 0.227 0 0 1.45 KB
#2624 EnrichedLog netcoreapp3.1 3.11μs 12.3ns 46.1ns 0.0217 0 0 1.53 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 net472 293μs 1.15μs 4.47μs 0.451 0.15 0 4.33 KB
master EnrichedLog netcoreapp3.1 232μs 585ns 2.27μs 0 0 0 4.21 KB
#2624 EnrichedLog net472 293μs 1.42μs 6.18μs 0.458 0.153 0 4.33 KB
#2624 EnrichedLog netcoreapp3.1 232μs 816ns 3.16μs 0 0 0 4.21 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 net472 8.05μs 42.7ns 263ns 0.503 0 0 3.23 KB
master EnrichedLog netcoreapp3.1 6.51μs 36.4ns 239ns 0.0484 0 0 3.6 KB
#2624 EnrichedLog net472 7.88μs 36.4ns 136ns 0.507 0 0 3.23 KB
#2624 EnrichedLog netcoreapp3.1 6.56μs 30.6ns 119ns 0.0478 0 0 3.6 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 net472 2.48μs 12.7ns 73.8ns 0.16 0.00124 0 1.01 KB
master SendReceive netcoreapp3.1 2.15μs 9.17ns 35.5ns 0.0141 0 0 1.01 KB
#2624 SendReceive net472 2.39μs 11.5ns 52.7ns 0.16 0.00119 0 1.01 KB
#2624 SendReceive netcoreapp3.1 2.25μs 8.14ns 30.5ns 0.0141 0 0 1.01 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 net472 6.05μs 28.8ns 112ns 0.291 0 0 1.87 KB
master EnrichedLog netcoreapp3.1 5.13μs 24.8ns 108ns 0.0199 0 0 1.49 KB
#2624 EnrichedLog net472 6.27μs 34.9ns 239ns 0.291 0 0 1.87 KB
#2624 EnrichedLog netcoreapp3.1 5.46μs 16.6ns 62.1ns 0.0192 0 0 1.49 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 net472 931ns 4.8ns 23.5ns 0.0718 0 0 457 B
master StartFinishSpan netcoreapp3.1 864ns 2.3ns 8.62ns 0.00608 0 0 456 B
master StartFinishScope net472 1.13μs 6.05ns 34.2ns 0.0843 0 0 538 B
master StartFinishScope netcoreapp3.1 1.03μs 4.48ns 16.1ns 0.00779 0 0 576 B
#2624 StartFinishSpan net472 915ns 2.7ns 10.5ns 0.072 0 0 457 B
#2624 StartFinishSpan netcoreapp3.1 884ns 4.48ns 26.5ns 0.00599 0 0 456 B
#2624 StartFinishScope net472 1.1μs 4.09ns 15.3ns 0.0843 0 0 538 B
#2624 StartFinishScope netcoreapp3.1 1.02μs 3.55ns 12.8ns 0.008 0 0 576 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 net472 1.39μs 7.06ns 30.8ns 0.0839 0 0 538 B
master RunOnMethodBegin netcoreapp3.1 1.22μs 6.12ns 28.1ns 0.00804 0 0 576 B
#2624 RunOnMethodBegin net472 1.29μs 5.44ns 24.9ns 0.0838 0 0 538 B
#2624 RunOnMethodBegin netcoreapp3.1 1.18μs 5.48ns 21.2ns 0.0077 0 0 576 B

@gleocadie
gleocadie merged commit 6f0d718 into master Apr 8, 2022
@gleocadie
gleocadie deleted the gleocadie/share-dynamic-loading-mechanism branch April 8, 2022 17:17
@github-actions github-actions Bot added this to the vNext milestone Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:native-library Automatic instrumentation native C++ code (Datadog.Trace.ClrProfiler.Native) area:shared-components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants