Skip to content

Conversation

@tonyredondo
Copy link
Member

@tonyredondo tonyredondo commented Jan 15, 2026

Summary of changes

  • Add git command caching and telemetry improvements for CI visibility.
  • Update GitInfo discovery and CI environment logging.
  • Update impacted tests for new git discovery behavior.

Reason for change

Reduce git command overhead and improve visibility into CI git metadata collection.

Implementation details

  • Disk cache keyed by RunId in GitCommandHelper with safe.directory handling.
  • JSON annotations in ProcessHelpers for cache serialization.
  • Adjusted CI runner git discovery logic and tests.

Test coverage

CI passes then all changes are good.

Other details

@tonyredondo tonyredondo changed the title ci: git caching + env improvements [Test Optimization] ci: git caching + env improvements Jan 15, 2026
@pr-commenter
Copy link

pr-commenter bot commented Jan 15, 2026

Benchmarks

Benchmark execution time: 2026-01-19 10:11:07

Comparing candidate commit 87c7fd2 in PR branch tony/testoptimization-performance-work-pr3 with baseline commit 0e23a10 in branch master.

Found 6 performance improvements and 13 performance regressions! Performance is the same for 158 metrics, 15 unstable metrics.

scenario:Benchmarks.Trace.AgentWriterBenchmark.WriteAndFlushEnrichedTraces netcoreapp3.1

  • 🟥 execution_time [+105.673ms; +106.275ms] or [+95.204%; +95.747%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleSimpleBody netcoreapp3.1

  • 🟥 execution_time [+13.410ms; +19.807ms] or [+6.812%; +10.061%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody net6.0

  • 🟩 execution_time [-16.842ms; -10.608ms] or [-7.974%; -5.022%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody netcoreapp3.1

  • 🟩 execution_time [-17.788ms; -13.139ms] or [-8.234%; -6.082%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeArgs net6.0

  • 🟥 execution_time [+11.262ms; +12.922ms] or [+5.734%; +6.580%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeLegacyArgs net6.0

  • 🟥 execution_time [+26.249ms; +26.772ms] or [+14.840%; +15.136%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeLegacyArgs netcoreapp3.1

  • 🟥 execution_time [+20.543ms; +21.147ms] or [+11.338%; +11.672%]

scenario:Benchmarks.Trace.AspNetCoreBenchmark.SendRequest net6.0

  • 🟥 execution_time [+61.357ms; +63.857ms] or [+65.298%; +67.958%]

scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool net472

  • 🟥 execution_time [+107.629µs; +110.278µs] or [+9.514%; +9.748%]
  • 🟥 throughput [-78.638op/s; -76.673op/s] or [-8.896%; -8.674%]

scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool net6.0

  • 🟥 execution_time [+145.795µs; +152.072µs] or [+14.188%; +14.799%]
  • 🟥 throughput [-125.849op/s; -120.556op/s] or [-12.932%; -12.388%]

scenario:Benchmarks.Trace.CharSliceBenchmark.OriginalCharSlice net6.0

  • 🟩 execution_time [-118.573µs; -112.001µs] or [-5.666%; -5.352%]
  • 🟩 throughput [+27.091op/s; +28.626op/s] or [+5.669%; +5.990%]

scenario:Benchmarks.Trace.DbCommandBenchmark.ExecuteNonQuery netcoreapp3.1

  • 🟩 throughput [+27492.307op/s; +35045.734op/s] or [+7.246%; +9.237%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark net6.0

  • 🟥 throughput [-318.224op/s; -117.626op/s] or [-15.067%; -5.569%]

scenario:Benchmarks.Trace.SerilogBenchmark.EnrichedLog netcoreapp3.1

  • 🟩 throughput [+10789.299op/s; +12377.255op/s] or [+6.604%; +7.576%]

scenario:Benchmarks.Trace.SingleSpanAspNetCoreBenchmark.SingleSpanAspNetCore net6.0

  • 🟥 execution_time [+41.470ms; +43.783ms] or [+41.653%; +43.976%]

scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin net6.0

  • 🟥 execution_time [+10.142ms; +14.533ms] or [+5.121%; +7.339%]

@tonyredondo tonyredondo force-pushed the tony/testoptimization-performance-work-pr2 branch from d68d0a9 to de740b1 Compare January 15, 2026 22:06
@tonyredondo tonyredondo force-pushed the tony/testoptimization-performance-work-pr3 branch from 50fc18c to 2018124 Compare January 15, 2026 22:06
@datadog-official

This comment has been minimized.

@dd-trace-dotnet-ci-bot
Copy link

dd-trace-dotnet-ci-bot bot commented Jan 15, 2026

Execution-Time Benchmarks Report ⏱️

Execution-time results for samples comparing This PR (8072) and master.

✅ No regressions detected - check the details below

Full Metrics Comparison

FakeDbCommand

Metric Master (Mean ± 95% CI) Current (Mean ± 95% CI) Change Status
.NET Framework 4.8 - Baseline
duration68.35 ± (68.35 - 68.58) ms71.78 ± (72.27 - 73.11) ms+5.0%✅⬆️
.NET Framework 4.8 - Bailout
duration72.12 ± (71.98 - 72.22) ms75.66 ± (75.67 - 76.00) ms+4.9%✅⬆️
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration996.99 ± (1000.79 - 1009.02) ms1020.53 ± (1021.21 - 1028.40) ms+2.4%✅⬆️
.NET Core 3.1 - Baseline
process.internal_duration_ms21.94 ± (21.91 - 21.96) ms22.09 ± (22.06 - 22.11) ms+0.7%✅⬆️
process.time_to_main_ms78.55 ± (78.37 - 78.73) ms80.65 ± (80.50 - 80.81) ms+2.7%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.90 ± (10.89 - 10.90) MB10.89 ± (10.89 - 10.90) MB-0.1%
runtime.dotnet.threads.count12 ± (12 - 12)12 ± (12 - 12)+0.0%
.NET Core 3.1 - Bailout
process.internal_duration_ms21.91 ± (21.89 - 21.94) ms22.15 ± (22.12 - 22.18) ms+1.1%✅⬆️
process.time_to_main_ms79.82 ± (79.70 - 79.93) ms82.85 ± (82.71 - 83.00) ms+3.8%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.92 ± (10.92 - 10.93) MB10.94 ± (10.93 - 10.94) MB+0.1%✅⬆️
runtime.dotnet.threads.count13 ± (13 - 13)13 ± (13 - 13)+0.0%
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms248.45 ± (245.12 - 251.78) ms239.60 ± (235.79 - 243.40) ms-3.6%
process.time_to_main_ms467.11 ± (466.56 - 467.66) ms479.97 ± (479.09 - 480.84) ms+2.8%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed48.36 ± (48.34 - 48.38) MB48.34 ± (48.31 - 48.36) MB-0.0%
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)-0.9%
.NET 6 - Baseline
process.internal_duration_ms20.78 ± (20.75 - 20.81) ms20.97 ± (20.95 - 21.00) ms+0.9%✅⬆️
process.time_to_main_ms68.18 ± (68.07 - 68.29) ms70.13 ± (70.00 - 70.26) ms+2.9%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.60 ± (10.60 - 10.60) MB10.63 ± (10.63 - 10.63) MB+0.3%✅⬆️
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 6 - Bailout
process.internal_duration_ms20.59 ± (20.57 - 20.61) ms20.88 ± (20.86 - 20.91) ms+1.4%✅⬆️
process.time_to_main_ms68.95 ± (68.90 - 69.00) ms71.28 ± (71.17 - 71.40) ms+3.4%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.66 ± (10.65 - 10.66) MB10.72 ± (10.72 - 10.73) MB+0.6%✅⬆️
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms250.94 ± (249.48 - 252.39) ms242.67 ± (239.50 - 245.84) ms-3.3%
process.time_to_main_ms445.20 ± (444.77 - 445.62) ms453.32 ± (452.84 - 453.79) ms+1.8%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed49.09 ± (49.07 - 49.12) MB49.11 ± (49.08 - 49.15) MB+0.0%✅⬆️
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)+0.1%✅⬆️
.NET 8 - Baseline
process.internal_duration_ms18.73 ± (18.70 - 18.76) ms19.07 ± (19.04 - 19.11) ms+1.8%✅⬆️
process.time_to_main_ms67.02 ± (66.91 - 67.13) ms69.08 ± (68.96 - 69.19) ms+3.1%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.64 ± (7.64 - 7.65) MB7.67 ± (7.66 - 7.68) MB+0.3%✅⬆️
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 8 - Bailout
process.internal_duration_ms18.78 ± (18.76 - 18.81) ms19.03 ± (19.00 - 19.06) ms+1.3%✅⬆️
process.time_to_main_ms68.12 ± (68.06 - 68.18) ms70.17 ± (70.08 - 70.26) ms+3.0%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.71 ± (7.70 - 7.72) MB7.73 ± (7.71 - 7.74) MB+0.2%✅⬆️
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms196.67 ± (194.14 - 199.21) ms179.15 ± (178.29 - 180.01) ms-8.9%
process.time_to_main_ms457.65 ± (452.86 - 462.44) ms435.44 ± (434.75 - 436.13) ms-4.9%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed36.78 ± (36.74 - 36.82) MB36.53 ± (36.51 - 36.56) MB-0.7%
runtime.dotnet.threads.count27 ± (27 - 27)26 ± (26 - 26)-0.7%

HttpMessageHandler

Metric Master (Mean ± 95% CI) Current (Mean ± 95% CI) Change Status
.NET Framework 4.8 - Baseline
duration192.67 ± (192.67 - 193.51) ms196.08 ± (196.18 - 197.09) ms+1.8%✅⬆️
.NET Framework 4.8 - Bailout
duration196.50 ± (196.29 - 197.06) ms199.01 ± (198.90 - 199.84) ms+1.3%✅⬆️
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1120.06 ± (1128.32 - 1138.04) ms1140.38 ± (1141.38 - 1150.60) ms+1.8%✅⬆️
.NET Core 3.1 - Baseline
process.internal_duration_ms187.78 ± (187.36 - 188.19) ms190.30 ± (189.85 - 190.74) ms+1.3%✅⬆️
process.time_to_main_ms80.92 ± (80.65 - 81.19) ms81.89 ± (81.67 - 82.11) ms+1.2%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.09 ± (16.07 - 16.11) MB16.08 ± (16.06 - 16.11) MB-0.0%
runtime.dotnet.threads.count20 ± (20 - 20)20 ± (20 - 20)+0.1%✅⬆️
.NET Core 3.1 - Bailout
process.internal_duration_ms187.22 ± (186.96 - 187.48) ms188.18 ± (187.86 - 188.51) ms+0.5%✅⬆️
process.time_to_main_ms82.16 ± (82.00 - 82.31) ms82.97 ± (82.78 - 83.15) ms+1.0%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.19 ± (16.16 - 16.22) MB16.12 ± (16.09 - 16.15) MB-0.4%
runtime.dotnet.threads.count21 ± (21 - 21)21 ± (21 - 21)-0.1%
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms428.15 ± (425.15 - 431.15) ms422.77 ± (419.33 - 426.21) ms-1.3%
process.time_to_main_ms473.00 ± (472.29 - 473.71) ms486.56 ± (485.43 - 487.70) ms+2.9%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed58.81 ± (58.71 - 58.92) MB58.81 ± (58.71 - 58.91) MB-0.0%
runtime.dotnet.threads.count29 ± (29 - 30)29 ± (29 - 30)+0.0%✅⬆️
.NET 6 - Baseline
process.internal_duration_ms192.21 ± (191.80 - 192.63) ms193.18 ± (192.76 - 193.60) ms+0.5%✅⬆️
process.time_to_main_ms70.23 ± (70.03 - 70.42) ms70.85 ± (70.67 - 71.03) ms+0.9%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.20 ± (16.09 - 16.32) MB16.18 ± (16.07 - 16.29) MB-0.2%
runtime.dotnet.threads.count19 ± (19 - 19)18 ± (18 - 19)-1.9%
.NET 6 - Bailout
process.internal_duration_ms190.80 ± (190.52 - 191.08) ms191.50 ± (191.23 - 191.78) ms+0.4%✅⬆️
process.time_to_main_ms70.99 ± (70.85 - 71.13) ms71.77 ± (71.64 - 71.90) ms+1.1%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.11 ± (15.96 - 16.25) MB15.94 ± (15.78 - 16.10) MB-1.0%
runtime.dotnet.threads.count19 ± (19 - 19)19 ± (19 - 19)-0.7%
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms442.35 ± (439.15 - 445.55) ms440.53 ± (436.95 - 444.10) ms-0.4%
process.time_to_main_ms451.52 ± (450.95 - 452.10) ms456.24 ± (455.59 - 456.89) ms+1.0%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed58.95 ± (58.82 - 59.09) MB59.13 ± (58.99 - 59.27) MB+0.3%✅⬆️
runtime.dotnet.threads.count29 ± (29 - 29)29 ± (29 - 29)+0.0%✅⬆️
.NET 8 - Baseline
process.internal_duration_ms190.62 ± (190.22 - 191.02) ms191.53 ± (191.13 - 191.94) ms+0.5%✅⬆️
process.time_to_main_ms69.97 ± (69.74 - 70.21) ms70.75 ± (70.51 - 70.98) ms+1.1%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.77 ± (11.75 - 11.80) MB11.74 ± (11.71 - 11.76) MB-0.3%
runtime.dotnet.threads.count18 ± (18 - 18)18 ± (18 - 18)+0.2%✅⬆️
.NET 8 - Bailout
process.internal_duration_ms189.80 ± (189.45 - 190.14) ms190.16 ± (189.91 - 190.41) ms+0.2%✅⬆️
process.time_to_main_ms71.08 ± (70.97 - 71.20) ms71.43 ± (71.30 - 71.57) ms+0.5%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.84 ± (11.82 - 11.87) MB11.81 ± (11.79 - 11.84) MB-0.3%
runtime.dotnet.threads.count19 ± (19 - 19)19 ± (19 - 19)+0.7%✅⬆️
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms367.09 ± (365.66 - 368.51) ms366.83 ± (365.05 - 368.61) ms-0.1%
process.time_to_main_ms434.83 ± (434.15 - 435.50) ms440.38 ± (439.41 - 441.35) ms+1.3%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed48.11 ± (48.07 - 48.14) MB48.08 ± (48.03 - 48.12) MB-0.1%
runtime.dotnet.threads.count28 ± (28 - 29)29 ± (29 - 29)+1.6%✅⬆️
Comparison explanation

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

Duration charts
FakeDbCommand (.NET Framework 4.8)
gantt
    title Execution time (ms) FakeDbCommand (.NET Framework 4.8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8072) - mean (73ms)  : 66, 79
    master - mean (68ms)  : 67, 70

    section Bailout
    This PR (8072) - mean (76ms)  : 74, 78
    master - mean (72ms)  : 71, 73

    section CallTarget+Inlining+NGEN
    This PR (8072) - mean (1,025ms)  : 974, 1076
    master - mean (1,005ms)  : 947, 1063

Loading
FakeDbCommand (.NET Core 3.1)
gantt
    title Execution time (ms) FakeDbCommand (.NET Core 3.1)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8072) - mean (108ms)  : 106, 111
    master - mean (106ms)  : 104, 108

    section Bailout
    This PR (8072) - mean (111ms)  : 109, 113
    master - mean (107ms)  : 105, 108

    section CallTarget+Inlining+NGEN
    This PR (8072) - mean (751ms)  : 697, 806
    master - mean (738ms)  : 687, 789

Loading
FakeDbCommand (.NET 6)
gantt
    title Execution time (ms) FakeDbCommand (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8072) - mean (96ms)  : 94, 99
    master - mean (94ms)  : 91, 96

    section Bailout
    This PR (8072) - mean (97ms)  : 96, 99
    master - mean (94ms)  : 93, 95

    section CallTarget+Inlining+NGEN
    This PR (8072) - mean (720ms)  : 659, 781
    master - mean (719ms)  : 687, 751

Loading
FakeDbCommand (.NET 8)
gantt
    title Execution time (ms) FakeDbCommand (.NET 8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8072) - mean (95ms)  : 92, 97
    master - mean (92ms)  : 90, 94

    section Bailout
    This PR (8072) - mean (96ms)  : 94, 98
    master - mean (93ms)  : 92, 94

    section CallTarget+Inlining+NGEN
    This PR (8072) - mean (644ms)  : 625, 662
    master - mean (684ms)  : 576, 791

Loading
HttpMessageHandler (.NET Framework 4.8)
gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8072) - mean (197ms)  : 190, 203
    master - mean (193ms)  : 189, 197

    section Bailout
    This PR (8072) - mean (199ms)  : 195, 204
    master - mean (197ms)  : 193, 200

    section CallTarget+Inlining+NGEN
    This PR (8072) - mean (1,146ms)  : 1078, 1214
    master - mean (1,133ms)  : 1064, 1203

Loading
HttpMessageHandler (.NET Core 3.1)
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8072) - mean (281ms)  : 271, 291
    master - mean (278ms)  : 270, 285

    section Bailout
    This PR (8072) - mean (279ms)  : 275, 283
    master - mean (278ms)  : 275, 281

    section CallTarget+Inlining+NGEN
    This PR (8072) - mean (947ms)  : 900, 995
    master - mean (935ms)  : 889, 981

Loading
HttpMessageHandler (.NET 6)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8072) - mean (272ms)  : 267, 277
    master - mean (271ms)  : 265, 276

    section Bailout
    This PR (8072) - mean (272ms)  : 268, 275
    master - mean (270ms)  : 266, 273

    section CallTarget+Inlining+NGEN
    This PR (8072) - mean (927ms)  : 865, 989
    master - mean (922ms)  : 874, 969

Loading
HttpMessageHandler (.NET 8)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8072) - mean (273ms)  : 267, 278
    master - mean (271ms)  : 265, 276

    section Bailout
    This PR (8072) - mean (272ms)  : 268, 275
    master - mean (270ms)  : 266, 275

    section CallTarget+Inlining+NGEN
    This PR (8072) - mean (841ms)  : 823, 859
    master - mean (833ms)  : 816, 851

Loading

@tonyredondo tonyredondo force-pushed the tony/testoptimization-performance-work-pr2 branch from de740b1 to a92777c Compare January 16, 2026 11:38
@tonyredondo tonyredondo force-pushed the tony/testoptimization-performance-work-pr3 branch from b98a4d3 to e77015c Compare January 16, 2026 11:38
@tonyredondo tonyredondo force-pushed the tony/testoptimization-performance-work-pr2 branch from a92777c to d0595bf Compare January 16, 2026 12:31
@tonyredondo tonyredondo force-pushed the tony/testoptimization-performance-work-pr3 branch from e77015c to 8fae54a Compare January 16, 2026 12:32
@tonyredondo tonyredondo force-pushed the tony/testoptimization-performance-work-pr2 branch from d0595bf to 7216d32 Compare January 16, 2026 12:39
@tonyredondo tonyredondo force-pushed the tony/testoptimization-performance-work-pr3 branch from 8fae54a to 33077cb Compare January 16, 2026 12:39
Comment on lines +113 to +123
if (gitInfo.Errors.Count > 0)
{
var sb = StringBuilderCache.Acquire();
sb.AppendLine();
foreach (var err in gitInfo.Errors)
{
sb.AppendLine(" Error: " + err);
}

Log.Warning("CIEnvironmentValues: Errors detected in the local gitInfo: {Errors}", StringBuilderCache.GetStringAndRelease(sb));
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Before this we were swallowing all the git errors when extracting the local git info (without any ci provider info)

Comment on lines +125 to +140
if (Log.IsEnabled(LogEventLevel.Debug))
{
var sb = StringBuilderCache.Acquire();
sb.AppendLine();
var values = ValueProvider.GetValues();
foreach (var field in typeof(CIEnvironmentValues.Constants).GetFields())
{
var fieldName = field.GetValue(null) as string;
if (!StringUtil.IsNullOrEmpty(fieldName) && values.TryGetValue<string>(fieldName, out var value))
{
sb.AppendFormat("\t{0}={1}{2}", fieldName, value == string.Empty ? "(empty)" : $"\"{value}\"", Environment.NewLine);
}
}

Log.Debug("CIEnvironmentValues: Values detected:{Values}", StringBuilderCache.GetStringAndRelease(sb));
}
Copy link
Member Author

Choose a reason for hiding this comment

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

To help to debug issues in the CI providers parser here we dump the environment variables defined in the Contants class related to the CI Providers environment variables.

Comment on lines -35 to -45
// Ensure we have permissions to read the git directory
var safeDirectory = ProcessHelpers.RunCommand(
new ProcessHelpers.Command(
cmd: "git",
arguments: $"config --global --add safe.directory {gitDirectory.FullName}",
workingDirectory: gitDirectory.FullName,
useWhereIsIfFileNotFound: true));
if (safeDirectory?.ExitCode != 0)
{
localGitInfo.Errors.Add($"Error setting safe.directory: {safeDirectory?.Error}");
}
Copy link
Member Author

Choose a reason for hiding this comment

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

we no longer need to modify the git global configuration, we will use the -c safe.directory option on each git command call.

}

// Get the repository URL
var repositoryOutput = ProcessHelpers.RunCommand(
Copy link
Member Author

Choose a reason for hiding this comment

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

we already have a helper to call git commands

Comment on lines +128 to +134
var baseDirectory = AppContext.BaseDirectory;
if (!baseDirectory.Contains("/dotnet/sdk") && !string.IsNullOrWhiteSpace(RuntimeFolder) && !baseDirectory.Contains(RuntimeFolder))
{
if (!File.Exists(Path.Combine(baseDirectory, DatadogTraceToolsRunnerAssembly)))
{
searchPaths.Add(baseDirectory);
}
}
Copy link
Member Author

@tonyredondo tonyredondo Jan 16, 2026

Choose a reason for hiding this comment

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

for the testhost process the base directory is the dotnet sdk, so we need to check that before considering it as a search path for the git metadata.

Comment on lines 46 to 88
if (useCache && string.IsNullOrEmpty(input))
{
string runId;
if (TestOptimization.Instance is TestOptimization { } tOpt)
{
runId = tOpt.EnsureRunId(workingDirectory);
}
else
{
runId = TestOptimization.Instance.RunId;
}

var cacheFolder = Path.Combine(workingDirectory, ".dd", runId, "git");
try
{
if (!Directory.Exists(cacheFolder))
{
Directory.CreateDirectory(cacheFolder);
}

lock (Hasher)
{
var hash = Hasher.ComputeHash(Encoding.UTF8.GetBytes(arguments));
cacheKey = Path.Combine(cacheFolder, BitConverter.ToString(hash).ToLowerInvariant() + ".json");
}

if (File.Exists(cacheKey))
{
var jsonValue = File.ReadAllText(cacheKey);
if (JsonConvert.DeserializeObject<ProcessHelpers.CommandOutput>(jsonValue) is { } cachedOutput)
{
cachedOutput.Cached = true;
return cachedOutput;
}
}
}
catch (Exception ex)
{
Log.Warning(ex, "Error in the git cache.");
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

this prepares the cache folder for the git commands, so we avoid running the same git commands over and over again from different processes (that's the issue with test optimization, involves multiple processes per run)

try
{
var sw = System.Diagnostics.Stopwatch.StartNew();
arguments = $"-c safe.directory={workingDirectory} {arguments}";
Copy link
Member Author

Choose a reason for hiding this comment

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

here's the -c safe.directory to avoid changing the global git configuration.

Copy link
Member Author

Choose a reason for hiding this comment

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

we need to make this serializable for the git commands cache

Directory.Exists(testItem.GitFolderPath).Should().BeTrue();

// Let's try with the git info provider based on manual parsing of the git folder
if (!ManualParserGitInfoProvider.Instance.TryGetFrom(testItem.GitFolderPath, out var gitInfo))
Copy link
Member Author

Choose a reason for hiding this comment

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

we are removing the ManualParser provider, because we now always need the git command, so it doesn't worth having a manual .git folder parser.

@tonyredondo tonyredondo marked this pull request as ready for review January 16, 2026 14:36
@tonyredondo tonyredondo requested review from a team as code owners January 16, 2026 14:36
@tonyredondo tonyredondo force-pushed the tony/testoptimization-performance-work-pr2 branch from 7216d32 to 4a70c7a Compare January 19, 2026 09:19
@tonyredondo tonyredondo force-pushed the tony/testoptimization-performance-work-pr3 branch from 07b09e0 to 566cf1c Compare January 19, 2026 09:19
@tonyredondo tonyredondo force-pushed the tony/testoptimization-performance-work-pr2 branch from 4a70c7a to b3116fd Compare January 19, 2026 09:27
@tonyredondo tonyredondo force-pushed the tony/testoptimization-performance-work-pr3 branch from 566cf1c to 87c7fd2 Compare January 19, 2026 09:28
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.

3 participants