Skip to content

Commit d8df798

Browse files
faydefKevin Gossebricefriha
authored andcommitted
[Benchmarks] Add Micro-benchmarks (#6802)
## Summary of changes https://datadoghq.atlassian.net/browse/APMSP-1712 This PR introduces running benchmarks through the Benchmarking-platform all while keeping the current benchmarks running. The tests are setup to run: - On commit to the master branch - On schedule if BENCHMARK_RUN is set to "true" for the scheduled pipeline. - On manual trigger (keep in mind that it requires build artifacts from the Azure Pipeline) ## Reason for change Related to efforts to use Gitlab as our main CI Provider. ## Implementation details ## Test coverage ## Other details Results from the benchmarks report do differ as we do not run on master currently so the comparaison is done against an old seeded run <!-- Fixes #{issue} --> <!-- ⚠️ Note: where possible, please obtain 2 approvals prior to merging. Unless CODEOWNERS specifies otherwise, for external teams it is typically best to have one review from a team member, and one review from apm-dotnet. Trivial changes do not require 2 reviews. --> --------- Co-authored-by: Kevin Gosse <kevin.gosse@datadoghq.com> Co-authored-by: Brice Friha <37577669+bricefriha@users.noreply.github.com>
1 parent ee4a8a0 commit d8df798

File tree

4 files changed

+97
-1
lines changed

4 files changed

+97
-1
lines changed

.gitlab-ci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,4 +213,17 @@ macrobenchmarks:
213213
- if: '$CI_PIPELINE_SOURCE == "schedule" && $BENCHMARK_RUN == "true"'
214214
when: always
215215
- when: manual
216+
217+
microbenchmarks:
218+
stage: benchmarks
219+
needs: [ ]
220+
trigger:
221+
include: .gitlab/benchmarks/microbenchmarks.yml
222+
allow_failure: true
223+
rules:
224+
- if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "master"'
225+
when: always
226+
- if: '$CI_PIPELINE_SOURCE == "schedule" && $BENCHMARK_RUN == "true"'
227+
when: always
228+
- when: manual
216229

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
stages:
2+
- benchmarks
3+
4+
run-benchmarks:
5+
stage: benchmarks
6+
tags: ["arch:amd64"]
7+
interruptible: true
8+
timeout: 1h
9+
# Image created in the following job https://gitlab.ddbuild.io/DataDog/benchmarking-platform-tools/-/jobs/869830045
10+
image: registry.ddbuild.io/images/benchmarking-platform-tools-ubuntu:dotnet-microbenchmarks
11+
12+
script:
13+
- git clone --branch fayssal/test-micro-delivery https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.ddbuild.io/DataDog/benchmarking-platform platform
14+
- ./platform/steps/launch-instance.sh
15+
- ./platform/steps/post-pr-comment.sh
16+
# Temporarely commented out pending issue resolution with sending files to backend
17+
# - ./platform/steps/upload-to-bp-ui.sh
18+
19+
rules:
20+
- when: on_success
21+
variables:
22+
FF_USE_LEGACY_KUBERNETES_EXECUTION_STRATEGY: "true"
23+
AWS_REGION: "us-east-1"
24+
CLEANUP: "false"
25+
AWS_EPHEMERAL_INFRA_PROFILE_SSM_PARAMETER: "ci.dd-trace-dotnet.ephemeral-infra-ci.dd-trace-dotnet-profile"
26+
AWS_EPHEMERAL_INFRA_PROFILE_NAME: "ephemeral-infra-ci"
27+
AWS_EPHEMERAL_INFRA_ARTIFACTS_BUCKET_URI: "s3://windows-benchmarking-results/$CI_PROJECT_NAME/$CI_COMMIT_REF_NAME/$CI_JOB_ID"
28+
AWS_EPHEMERAL_INFRA_REGION: "us-east-1"
29+
30+
upload-to-bp-ui:
31+
stage: benchmarks
32+
tags: ["arch:amd64"]
33+
interruptible: true
34+
timeout: 1h
35+
# Image created in the following job https://gitlab.ddbuild.io/DataDog/benchmarking-platform-tools/-/jobs/869830045
36+
image: registry.ddbuild.io/images/benchmarking-platform-tools-ubuntu:dotnet-microbenchmarks
37+
38+
script:
39+
- git clone --branch fayssal/test-micro-delivery https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.ddbuild.io/DataDog/benchmarking-platform platform
40+
# - ./platform/steps/launch-instance.sh
41+
# - ./platform/steps/post-pr-comment.sh
42+
# Temporarely commented out pending issue resolution with sending files to backend
43+
- ./platform/steps/upload-to-bp-ui.sh
44+
45+
artifacts:
46+
name: "artifacts"
47+
when: always
48+
paths:
49+
- candidate-results/
50+
expire_in: 3 months
51+
52+
rules:
53+
- when: manual
54+
variables:
55+
FF_USE_LEGACY_KUBERNETES_EXECUTION_STRATEGY: "true"
56+
AWS_REGION: "us-east-1"
57+
CLEANUP: "false"
58+
AWS_EPHEMERAL_INFRA_PROFILE_SSM_PARAMETER: "ci.dd-trace-dotnet.ephemeral-infra-ci.dd-trace-dotnet-profile"
59+
AWS_EPHEMERAL_INFRA_PROFILE_NAME: "ephemeral-infra-ci"
60+
AWS_EPHEMERAL_INFRA_ARTIFACTS_BUCKET_URI: "s3://windows-benchmarking-results/$CI_PROJECT_NAME/$CI_COMMIT_REF_NAME/$CI_JOB_ID"
61+
AWS_EPHEMERAL_INFRA_REGION: "us-east-1"

tracer/build/_build/Build.GitHub.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,28 @@ await client.Issue.Milestone.Update(
986986
await ReplaceCommentInPullRequest(prNumber, $"## Benchmarks Report for " + BenchmarkCategory, markdown);
987987
});
988988

989+
Target CompareBenchmarksResultsBP => _ => _
990+
.Unlisted()
991+
.DependsOn(CreateRequiredDirectories)
992+
.Requires(() => GitHubRepositoryName)
993+
.Requires(() => BenchmarkCategory)
994+
.Executes(() =>
995+
{
996+
if (!int.TryParse(Environment.GetEnvironmentVariable("PR_NUMBER"), out var prNumber))
997+
{
998+
Logger.Warning("No PR_NUMBER variable found. Skipping benchmark comparison");
999+
return;
1000+
}
1001+
1002+
var masterDir = BuildDataDirectory / "previous_benchmarks";
1003+
var prDir = BuildDataDirectory / "benchmarks";
1004+
1005+
var markdown = CompareBenchmarks.GetMarkdown(masterDir, prDir, prNumber, "master", GitHubRepositoryName, BenchmarkCategory);
1006+
string filePath = Path.Combine(Path.GetTempPath(), "benchmarks_report.md");
1007+
Console.WriteLine($"The file was stored at: {filePath}");
1008+
File.WriteAllText(filePath, markdown);
1009+
});
1010+
9891011
Target CompareThroughputResults => _ => _
9901012
.Unlisted()
9911013
.DependsOn(CreateRequiredDirectories)

tracer/build/_build/Build.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ void DeleteReparsePoints(string path)
572572
.SetFramework(framework)
573573
.EnableNoRestore()
574574
.EnableNoBuild()
575-
.SetApplicationArguments($"-r {runtimes} -m -f {Filter ?? "*"} --anyCategories {BenchmarkCategory ?? "tracer"} --iterationTime 2000")
575+
.SetApplicationArguments($"-r {runtimes} -m -f {Filter ?? "*"} --anyCategories {BenchmarkCategory ?? "tracer"} --iterationTime 200")
576576
.SetProcessEnvironmentVariable("DD_SERVICE", "dd-trace-dotnet")
577577
.SetProcessEnvironmentVariable("DD_ENV", "CI")
578578
.SetProcessEnvironmentVariable("DD_DOTNET_TRACER_HOME", MonitoringHome)

0 commit comments

Comments
 (0)