-
Notifications
You must be signed in to change notification settings - Fork 345
[SqlClient] Add benchmarks for SqlProcessor and implement initial quick wins #3031
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
Merged
Kielek
merged 7 commits into
open-telemetry:main
from
stevejgordon:sql-summary-optimisation
Sep 2, 2025
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3235505
Add initial benchmark for SqlProcessor
stevejgordon 9af19eb
Initial performance improvements
stevejgordon 1e3692a
Update markdown lint
stevejgordon b2e5283
Merge branch 'main' into sql-summary-optimisation
Kielek b833bc4
Merge branch 'main' into sql-summary-optimisation
Kielek 77a567b
Detect changes in CI for Shared.Benchmarks
Kielek abac1cd
Include Benchmarks into compilation in CI
Kielek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,4 @@ jobs: | |
globs: | | ||
**/*.md | ||
!.github/**/*.md | ||
!**/*-report-github.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...penTelemetry.Instrumentation.Benchmarks.SqlProcessorBenchmarks-report-github.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
``` | ||
|
||
BenchmarkDotNet v0.13.12, Windows 11 (10.0.26100.4946) | ||
Unknown processor | ||
.NET SDK 9.0.304 | ||
[Host] : .NET 9.0.8 (9.0.825.36511), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI | ||
DefaultJob : .NET 9.0.8 (9.0.825.36511), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI | ||
|
||
|
||
``` | ||
| Method | Sql | Iterations | Mean | Error | StdDev | Allocated | | ||
|------- |--------------------- |----------- |----------:|----------:|----------:|----------:| | ||
| **Simple** | **SELEC(...)ls od [39]** | **1** | **16.42 ns** | **0.362 ns** | **0.818 ns** | **-** | | ||
| **Simple** | **SELEC(...)ls od [39]** | **20** | **335.73 ns** | **6.616 ns** | **9.698 ns** | **-** | | ||
| **Simple** | **SELE(...)_id) [101]** | **1** | **33.42 ns** | **0.700 ns** | **1.445 ns** | **-** | | ||
| **Simple** | **SELE(...)_id) [101]** | **20** | **654.29 ns** | **12.859 ns** | **13.759 ns** | **-** | |
21 changes: 21 additions & 0 deletions
21
test/OpenTelemetry.Contrib.Shared.Benchmarks/OpenTelemetry.Contrib.Shared.Benchmarks.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>$(SupportedNetTargets)</TargetFrameworks> | ||
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);$(NetFrameworkMinimumSupportedVersion)</TargetFrameworks> | ||
<OutputType>Exe</OutputType> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="BenchmarkDotNet" Version="$(BenchmarkDotNetPkgVer)" /> | ||
<PackageReference Include="JetBrains.Profiler.Api" Version="1.4.10" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="$(RepoRoot)\src\Shared\SqlProcessor.cs" Link="Includes\SqlProcessor.cs" /> | ||
<Compile Include="$(RepoRoot)\src\Shared\SqlStatementInfo.cs" Link="Includes\SqlStatementInfo.cs" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
using System.Diagnostics; | ||
using BenchmarkDotNet.Configs; | ||
using BenchmarkDotNet.Running; | ||
using JetBrains.Profiler.Api; | ||
using OpenTelemetry.Instrumentation.Benchmarks; | ||
|
||
if (Debugger.IsAttached || (args.Length > 0 && args[0] == "execute")) | ||
{ | ||
var benchmarks = new SqlProcessorBenchmarks | ||
{ | ||
Sql = "SELECT * FROM Orders o, OrderDetails od", | ||
Iterations = 100, | ||
}; | ||
|
||
MemoryProfiler.CollectAllocations(true); | ||
|
||
MemoryProfiler.GetSnapshot(); | ||
|
||
benchmarks.Simple(); | ||
|
||
MemoryProfiler.GetSnapshot(); | ||
} | ||
else | ||
{ | ||
var config = ManualConfig.Create(DefaultConfig.Instance) | ||
.WithArtifactsPath(@"..\..\..\BenchmarkResults"); | ||
|
||
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args, config); | ||
} |
7 changes: 7 additions & 0 deletions
7
test/OpenTelemetry.Contrib.Shared.Benchmarks/Properties/launchSettings.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"profiles": { | ||
"OpenTelemetry.Contrib.Shared.Benchmarks": { | ||
"commandName": "Project" | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
test/OpenTelemetry.Contrib.Shared.Benchmarks/SqlProcessorBenchmarks.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
using BenchmarkDotNet.Attributes; | ||
|
||
namespace OpenTelemetry.Instrumentation.Benchmarks; | ||
|
||
[MemoryDiagnoser] | ||
public class SqlProcessorBenchmarks | ||
{ | ||
[Params("SELECT * FROM Orders o, OrderDetails od", "SELECT order_date\nFROM (SELECT *\nFROM orders o\nJOIN customers c\nON o.customer_id = c.customer_id)")] | ||
public string Sql { get; set; } = string.Empty; | ||
|
||
[Params(1, 20)] | ||
public int Iterations { get; set; } | ||
|
||
[Benchmark] | ||
public void Simple() | ||
{ | ||
for (int i = 0; i < this.Iterations; i++) | ||
{ | ||
SqlProcessor.GetSanitizedSql(this.Sql); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.