Skip to content

Commit 3a27fbf

Browse files
chore: add benchmark for init duration integration test (#36)
1 parent 3aaaae2 commit 3a27fbf

23 files changed

Lines changed: 3913 additions & 4 deletions

.github/workflows/deploy.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,23 @@ jobs:
7979
env:
8080
GH_TOKEN: ${{ github.token }}
8181
run: |
82+
PYTHON="${{ steps.layers.outputs.python_version }}"
83+
NODE="${{ steps.layers.outputs.node_version }}"
84+
JAVA="${{ steps.layers.outputs.java_version }}"
85+
MANUAL="${{ steps.layers.outputs.manual_version }}"
86+
8287
cat <<EOF | gh release create "${{ steps.tag.outputs.tag }}" --title "${{ steps.tag.outputs.tag }}" --notes-file -
8388
## Layer ARNs
8489
8590
**Python:**
86-
`arn:aws:lambda:<region>:115813213817:layer:dash0-extension-python:${{ steps.layers.outputs.python_version }}`
91+
\`arn:aws:lambda:<region>:115813213817:layer:dash0-extension-python:${PYTHON}\`
8792
8893
**Node:**
89-
`arn:aws:lambda:<region>:115813213817:layer:dash0-extension-node:${{ steps.layers.outputs.node_version }}`
94+
\`arn:aws:lambda:<region>:115813213817:layer:dash0-extension-node:${NODE}\`
9095
9196
**Java:**
92-
`arn:aws:lambda:<region>:115813213817:layer:dash0-extension-java:${{ steps.layers.outputs.java_version }}`
97+
\`arn:aws:lambda:<region>:115813213817:layer:dash0-extension-java:${JAVA}\`
9398
9499
**Manual:**
95-
`arn:aws:lambda:<region>:115813213817:layer:dash0-extension-manual:${{ steps.layers.outputs.manual_version }}`
100+
\`arn:aws:lambda:<region>:115813213817:layer:dash0-extension-manual:${MANUAL}\`
96101
EOF

benchmarks/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules/
2+
cdk.out/
3+
dist/
4+
5+
# Gradle
6+
.gradle/
7+
build/

benchmarks/README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Extension Performance Benchmarks
2+
3+
Measures the init duration and memory overhead added by the Dash0 Lambda extension across all supported runtimes.
4+
5+
## What it measures
6+
7+
For each runtime version (Python 3.10-3.14, Node.js 20/22/24, Java 17/21/25), two Lambda functions are deployed:
8+
- **Baseline**: minimal handler, no layer
9+
- **Instrumented**: same handler with the Dash0 extension layer
10+
11+
Each function is invoked multiple times with forced cold starts. Init duration and max memory used are extracted from the Lambda REPORT line (via `LogType: Tail`).
12+
13+
## Running via GitHub Actions
14+
15+
Trigger the `Benchmark` workflow manually from the Actions tab. Inputs:
16+
- `cold_start_invocations`: number of cold starts per function (default: 10)
17+
- `commit_results`: whether to commit results back to the repo
18+
19+
## Running locally
20+
21+
```bash
22+
# Prerequisites: AWS credentials configured, layers already published
23+
24+
# Deploy the benchmark stack
25+
cd benchmarks/iac
26+
npm ci
27+
npx cdk deploy
28+
29+
# Install script dependencies & run
30+
cd ../scripts
31+
npm ci
32+
npx tsx run-benchmark.ts
33+
34+
# Clean up
35+
cd ../iac
36+
npx cdk destroy --force
37+
```
38+
39+
### Environment variables
40+
41+
| Variable | Default | Description |
42+
|---|---|---|
43+
| `RESOURCE_PREFIX` | `""` | Prefix for function/layer names |
44+
| `AWS_REGION` | `us-west-2` | AWS region |
45+
| `COLD_START_INVOCATIONS` | `10` | Number of cold starts per function |
46+
| `BENCHMARK_CONCURRENCY` | `10` | Max functions benchmarked in parallel |
47+
| `OUTPUT_FILE` | `results/YYYY-MM-DD.json` | Output file path |
48+
49+
## Results
50+
51+
Results are saved as JSON in `results/`. The script also prints a comparison table to stdout showing init duration and memory overhead per runtime.

benchmarks/iac/bin/benchmark.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env node
2+
import * as cdk from 'aws-cdk-lib/core';
3+
import { BenchmarkStack } from '../lib/benchmark-stack';
4+
5+
const prefix = process.env.RESOURCE_PREFIX ?? '';
6+
const app = new cdk.App();
7+
new BenchmarkStack(app, `${prefix}BenchmarkStack`);

benchmarks/iac/cdk.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"app": "npx ts-node --prefer-ts-exts bin/benchmark.ts",
3+
"requireApproval": "never",
4+
"context": {
5+
"@aws-cdk/aws-lambda:recognizeLayerVersion": true,
6+
"@aws-cdk/core:checkSecretUsage": true,
7+
"@aws-cdk/core:target-partitions": ["aws"],
8+
"@aws-cdk/aws-iam:minimizePolicies": true,
9+
"@aws-cdk/core:validateSnapshotRemovalPolicy": true,
10+
"@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion": true,
11+
"@aws-cdk/customresources:installLatestAwsSdkDefault": false,
12+
"@aws-cdk/custom-resources:logApiResponseDataPropertyTrueDefault": false
13+
}
14+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
plugins {
2+
id("java")
3+
}
4+
5+
group = "org.example"
6+
version = "1.0-SNAPSHOT"
7+
8+
repositories {
9+
mavenCentral()
10+
}
11+
12+
dependencies {
13+
implementation("com.amazonaws:aws-lambda-java-core:1.2.3")
14+
}
15+
16+
tasks.register<Zip>("buildZip") {
17+
from(tasks.named("compileJava"))
18+
from(tasks.named("processResources"))
19+
into("lib") {
20+
from(configurations.runtimeClasspath)
21+
}
22+
}
23+
24+
tasks.named("build") {
25+
dependsOn("buildZip")
26+
}
59.3 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Tue Feb 17 12:41:19 IST 2026
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
5+
zipStoreBase=GRADLE_USER_HOME
6+
zipStorePath=wrapper/dists

benchmarks/iac/lambdas/java/gradlew

Lines changed: 234 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = "benchmark-java"

0 commit comments

Comments
 (0)