forked from swift-otel/swift-otel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/log-processing-wip
- Loading branch information
Showing
20 changed files
with
277 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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 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,73 @@ | ||
name: Benchmark PR vs. main | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }}-benchmark | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
benchmark: | ||
name: Check benchmark regressions | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
continue-on-error: true | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4.1.7 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install jemalloc | ||
run: sudo apt-get install -y libjemalloc-dev | ||
|
||
- name: Benchmark PR | ||
run: | | ||
cd Benchmarks | ||
swift package --allow-writing-to-directory .benchmarkBaselines/ benchmark baseline update pr | ||
- name: Benchmark main | ||
run: | | ||
git switch main | ||
cd Benchmarks | ||
swift package --allow-writing-to-directory .benchmarkBaselines/ benchmark baseline update main | ||
- name: Check benchmark delta | ||
id: check_delta | ||
run: | | ||
echo $(date) >> $GITHUB_STEP_SUMMARY | ||
echo "BENCHMARK_STATUS=1" >> "$GITHUB_OUTPUT" | ||
cd Benchmarks | ||
swift package benchmark baseline check main pr --format markdown >> $GITHUB_STEP_SUMMARY | ||
echo "BENCHMARK_STATUS=0" >> "$GITHUB_OUTPUT" | ||
continue-on-error: true | ||
|
||
- name: Produce success comment | ||
if: ${{ steps.check_delta.outputs.BENCHMARK_STATUS == '0' }} | ||
run: | | ||
echo 'PRTEST<<EOF' >> $GITHUB_ENV | ||
echo "[Pull request benchmark comparison with 'main' run at $(date -Iseconds)](https://github.com/slashmo/${{ github.event.repository.name }}/actions/runs/${{ github.run_id }})" >> $GITHUB_ENV | ||
echo 'EOF' >> $GITHUB_ENV | ||
- name: Produce failure comment | ||
if: ${{ steps.check_delta.outputs.BENCHMARK_STATUS != '0' }} | ||
run: | | ||
echo 'PRTEST<<EOF' >> $GITHUB_ENV | ||
echo "[Pull request benchmark comparison with 'main' run at $(date -Iseconds)](https://github.com/slashmo/${{ github.event.repository.name }}/actions/runs/${{ github.run_id }})" >> $GITHUB_ENV | ||
echo "_Pull request had performance regressions_" >> $GITHUB_ENV | ||
echo 'EOF' >> $GITHUB_ENV | ||
- name: Comment PR | ||
uses: thollander/actions-comment-pull-request@v2 | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
message: ${{ env.PRTEST }} | ||
comment_tag: benchmark | ||
|
||
- name: Exit with correct status | ||
run: | | ||
exit ${{ steps.check_delta.outputs.BENCHMARK_STATUS }} |
This file contains 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 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 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 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 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the Swift OTel open source project | ||
// | ||
// Copyright (c) 2023 Moritz Lang and the Swift OTel project authors | ||
// Licensed under Apache License v2.0 | ||
// | ||
// See LICENSE.txt for license information | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
import Benchmark | ||
import Foundation | ||
|
||
let benchmarks = { | ||
let ciMetrics: [BenchmarkMetric] = [ | ||
.instructions, | ||
.mallocCountTotal, | ||
] | ||
let localMetrics = BenchmarkMetric.default | ||
|
||
Benchmark.defaultConfiguration = .init( | ||
metrics: ProcessInfo.processInfo.environment["CI"] != nil ? ciMetrics : localMetrics, | ||
warmupIterations: 10 | ||
) | ||
|
||
// MARK: - Benchmarks | ||
|
||
tracerBenchmarks() | ||
} |
This file contains 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,76 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the Swift OTel open source project | ||
// | ||
// Copyright (c) 2023 Moritz Lang and the Swift OTel project authors | ||
// Licensed under Apache License v2.0 | ||
// | ||
// See LICENSE.txt for license information | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
import Benchmark | ||
@_spi(OTelBenchmarking) import OTel | ||
import ServiceContextModule | ||
import W3CTraceContext | ||
|
||
func tracerBenchmarks() { | ||
Benchmark("Starting sampled root spans") { benchmark in | ||
let tracer = OTelTracer( | ||
idGenerator: OTelRandomIDGenerator(), | ||
sampler: OTelConstantSampler(isOn: true), | ||
propagator: OTelW3CPropagator(), | ||
processor: OTelNoOpSpanProcessor(), | ||
environment: [:], | ||
resource: OTelResource() | ||
) | ||
|
||
benchmark.startMeasurement() | ||
for _ in benchmark.scaledIterations { | ||
blackHole(tracer.startSpan("test")) | ||
} | ||
} | ||
|
||
Benchmark("Starting sampled child spans") { benchmark in | ||
let tracer = OTelTracer( | ||
idGenerator: OTelRandomIDGenerator(), | ||
sampler: OTelConstantSampler(isOn: true), | ||
propagator: OTelW3CPropagator(), | ||
processor: OTelNoOpSpanProcessor(), | ||
environment: [:], | ||
resource: OTelResource() | ||
) | ||
|
||
let parentSpanContext = OTelSpanContext.local( | ||
traceID: .random(), | ||
spanID: .random(), | ||
parentSpanID: nil, | ||
traceFlags: .sampled, | ||
traceState: TraceState() | ||
) | ||
let parentContext = ServiceContext.withSpanContext(parentSpanContext) | ||
|
||
benchmark.startMeasurement() | ||
for _ in benchmark.scaledIterations { | ||
blackHole(tracer.startSpan("test", context: parentContext)) | ||
} | ||
} | ||
|
||
Benchmark("Starting dropped root spans") { benchmark in | ||
let tracer = OTelTracer( | ||
idGenerator: OTelRandomIDGenerator(), | ||
sampler: OTelConstantSampler(isOn: false), | ||
propagator: OTelW3CPropagator(), | ||
processor: OTelNoOpSpanProcessor(), | ||
environment: [:], | ||
resource: OTelResource() | ||
) | ||
|
||
benchmark.startMeasurement() | ||
for _ in benchmark.scaledIterations { | ||
blackHole(tracer.startSpan("test")) | ||
} | ||
} | ||
} |
This file contains 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,26 @@ | ||
// swift-tools-version:5.9 | ||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "swif-otel-benchmarks", | ||
platforms: [ | ||
.macOS(.v13), | ||
], | ||
dependencies: [ | ||
.package(url: "https://github.com/ordo-one/package-benchmark.git", from: "1.0.0"), | ||
.package(path: ".."), | ||
], | ||
targets: [ | ||
.executableTarget( | ||
name: "OTelTracing", | ||
dependencies: [ | ||
.product(name: "Benchmark", package: "package-benchmark"), | ||
.product(name: "OTel", package: "swift-otel"), | ||
], | ||
path: "Benchmarks/OTelTracing", | ||
plugins: [ | ||
.plugin(name: "BenchmarkPlugin", package: "package-benchmark"), | ||
] | ||
), | ||
] | ||
) |
This file contains 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 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 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 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,23 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the Swift OTel open source project | ||
// | ||
// Copyright (c) 2023 Moritz Lang and the Swift OTel project authors | ||
// Licensed under Apache License v2.0 | ||
// | ||
// See LICENSE.txt for license information | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
import ServiceContextModule | ||
|
||
extension ServiceContext { | ||
@_spi(OTelBenchmarking) | ||
public static func withSpanContext(_ spanContext: OTelSpanContext) -> Self { | ||
var context = ServiceContext.topLevel | ||
context.spanContext = spanContext | ||
return context | ||
} | ||
} |
This file contains 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 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 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 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 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 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
Oops, something went wrong.