-
Notifications
You must be signed in to change notification settings - Fork 5
Benchmarks v2 #118
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
base: main
Are you sure you want to change the base?
Benchmarks v2 #118
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 issues found across 7 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="benchmarks2/app.ts">
<violation number="1" location="benchmarks2/app.ts:31">
P3: Use nullish coalescing (or an explicit numeric check) so a valid `0` delay isn't replaced by the default.</violation>
<violation number="2" location="benchmarks2/app.ts:32">
P2: Global `fetch` is only available in Node 18+, but the project supports Node 16. Calling `fetch` here will crash on Node 16. Import a fetch implementation (e.g., undici/node-fetch) or guard for unsupported runtimes.</violation>
</file>
<file name="benchmarks2/run_benchmark.sh">
<violation number="1" location="benchmarks2/run_benchmark.sh:6">
P2: The benchmark command is piped into `tee` without `pipefail`, so failures in benchmark.py can be ignored and the script will continue with a bad baseline. Add `set -o pipefail` to ensure pipeline failures stop the script.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 issues found across 5 files (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="benchmarks2/benchmark.py">
<violation number="1" location="benchmarks2/benchmark.py:75">
P2: The health check treats any HTTP response as ready. If /health returns 4xx/5xx, the loop still breaks and benchmarks run against a failing server. Capture the response and call raise_for_status (or check status_code) before breaking.</violation>
</file>
<file name="benchmarks2/app.ts">
<violation number="1" location="benchmarks2/app.ts:36">
P2: http.get only supports http:// URLs, so a https DELAY_SERVER will now fail. Consider using a protocol-aware client (http/https switch) or revert to fetch to keep HTTPS support.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
20 issues found across 122 files (changes from recent commits).
Note: This PR contains a large number of files. cubic only reviews up to 75 files per PR, so some files may not have been reviewed.
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="src/instrumentation/libraries/firestore/e2e-tests/cjs-firestore/entrypoint.sh">
<violation number="1" location="src/instrumentation/libraries/firestore/e2e-tests/cjs-firestore/entrypoint.sh:16">
P2: Using `pkill -f "node"` is overly broad and can kill unrelated Node processes on the host. Track the server PID when starting `npm run dev` and terminate only that PID instead.</violation>
</file>
<file name="src/instrumentation/libraries/firestore/e2e-tests/esm-firestore/entrypoint.sh">
<violation number="1" location="src/instrumentation/libraries/firestore/e2e-tests/esm-firestore/entrypoint.sh:16">
P2: `pkill -f "node"` is too broad for test cleanup and can kill unrelated Node.js processes. Track the server PID from `npm run dev &` and kill only that process to avoid flakiness in shared CI or local environments.</violation>
</file>
<file name="src/instrumentation/libraries/mysql/e2e-tests/esm-mysql/entrypoint.sh">
<violation number="1" location="src/instrumentation/libraries/mysql/e2e-tests/esm-mysql/entrypoint.sh:41">
P2: Add an EXIT trap when starting the background server so it is always stopped, even if a curl command fails under `set -e`.</violation>
</file>
<file name="src/instrumentation/libraries/mysql/e2e-tests/cjs-mysql/entrypoint.sh">
<violation number="1" location="src/instrumentation/libraries/mysql/e2e-tests/cjs-mysql/entrypoint.sh:92">
P2: `curl -s` does not fail on HTTP error responses, so this E2E run can pass even when endpoints return 4xx/5xx. Use `--fail` (and ideally `-S`) so test failures are detected; apply the same change to the other curl calls in this phase.</violation>
</file>
<file name="src/instrumentation/libraries/ioredis/e2e-tests/cjs-ioredis/entrypoint.sh">
<violation number="1" location="src/instrumentation/libraries/ioredis/e2e-tests/cjs-ioredis/entrypoint.sh:16">
P2: `pkill -f "node"` is overly broad and can terminate unrelated Node.js processes on the host. Capture the server PID when starting it and kill only that PID to avoid collateral termination.</violation>
</file>
<file name="src/instrumentation/libraries/nextjs/e2e-tests/esm-nextjs/entrypoint.sh">
<violation number="1" location="src/instrumentation/libraries/nextjs/e2e-tests/esm-nextjs/entrypoint.sh:16">
P2: `pkill -f "node"` is too broad and can terminate unrelated Node.js processes on shared runners. Track the PID of the `npm run dev` process and kill only that PID instead.</violation>
</file>
<file name="src/e2e-common/python-base/README.md">
<violation number="1" location="src/e2e-common/python-base/README.md:126">
P3: The Dockerfile example’s line continuation is broken by an inline comment after the backslash, so the snippet won’t build if copied. Move the comment to its own line or remove it so the backslash is the last character.</violation>
</file>
<file name="src/instrumentation/libraries/ioredis/e2e-tests/esm-ioredis/entrypoint.sh">
<violation number="1" location="src/instrumentation/libraries/ioredis/e2e-tests/esm-ioredis/entrypoint.sh:16">
P2: `pkill -f "node"` is overly broad and can terminate unrelated Node processes. Capture the PID of the background server (`$!`) and kill that PID instead to avoid disrupting other jobs.</violation>
<violation number="2" location="src/instrumentation/libraries/ioredis/e2e-tests/esm-ioredis/entrypoint.sh:95">
P2: `curl -s` without `--fail` will treat HTTP errors as success, so the script can pass even when endpoints fail. Use `-f`/`--fail` (optionally with `-S`) so test failures are surfaced.</violation>
</file>
<file name="src/instrumentation/libraries/pg/e2e-tests/cjs-pg/entrypoint.sh">
<violation number="1" location="src/instrumentation/libraries/pg/e2e-tests/cjs-pg/entrypoint.sh:14">
P2: Using `pkill -f "node"` can terminate unrelated Node processes on the host. Track the server PID when you start it (`npm run dev & SERVER_PID=$!`) and kill only that PID to avoid disrupting other tests/services.</violation>
</file>
<file name="src/e2e-common/python-base/Dockerfile">
<violation number="1" location="src/e2e-common/python-base/Dockerfile:14">
P2: `CACHEBUST` is declared to invalidate the layer cache, but it isn't used in the install RUN step, so the CLI download layer will still be cached. This makes the cache-busting build arg ineffective.</violation>
</file>
<file name="src/instrumentation/libraries/mysql2/e2e-tests/cjs-mysql2/entrypoint.sh">
<violation number="1" location="src/instrumentation/libraries/mysql2/e2e-tests/cjs-mysql2/entrypoint.sh:42">
P2: Add a trap to clean up the background server on exit so failures don’t leave a stray process running.</violation>
<violation number="2" location="src/instrumentation/libraries/mysql2/e2e-tests/cjs-mysql2/entrypoint.sh:92">
P2: Use `curl -f` (or `--fail-with-body`) so HTTP error responses fail the test suite instead of being silently accepted.</violation>
</file>
<file name="src/instrumentation/libraries/grpc/e2e-tests/esm-grpc/docker-compose.yml">
<violation number="1" location="src/instrumentation/libraries/grpc/e2e-tests/esm-grpc/docker-compose.yml:19">
P2: The new bind mount only maps the config file read-only, so `/app/.tusk` output (traces) is no longer persisted to the host. If trace persistence is still required (per the comment), mount the directory instead or update the comment to avoid misleading behavior.</violation>
</file>
<file name="src/instrumentation/libraries/nextjs/e2e-tests/cjs-nextjs/entrypoint.sh">
<violation number="1" location="src/instrumentation/libraries/nextjs/e2e-tests/cjs-nextjs/entrypoint.sh:16">
P2: `pkill -f "node"` will terminate any Node.js process on the machine, not just the server started by this script. This can kill unrelated services or parallel test runners. Capture the server PID from `npm run dev &` and kill that PID instead.</violation>
</file>
<file name="src/instrumentation/libraries/fetch/e2e-tests/esm-fetch/entrypoint.sh">
<violation number="1" location="src/instrumentation/libraries/fetch/e2e-tests/esm-fetch/entrypoint.sh:16">
P2: `pkill -f "node"` is overly broad and can kill unrelated Node processes on the host. Capture the server PID when starting `npm run dev` and kill only that process (or the process group) to avoid disrupting other services.</violation>
<violation number="2" location="src/instrumentation/libraries/fetch/e2e-tests/esm-fetch/entrypoint.sh:67">
P2: Using a fixed `sleep 5` to wait for the server can make tests flaky if startup takes longer. Poll the health endpoint until it responds (with a timeout) before proceeding.</violation>
</file>
<file name="src/instrumentation/libraries/e2e-common/request-utils.sh">
<violation number="1" location="src/instrumentation/libraries/e2e-common/request-utils.sh:77">
P2: The request execution ignores the exit status, so failed HTTP calls are silently treated as success and E2E tests won’t fail when requests fail. Capture the exit code and return non‑zero on failure.</violation>
</file>
<file name="src/instrumentation/libraries/http/e2e-tests/cjs-http/entrypoint.sh">
<violation number="1" location="src/instrumentation/libraries/http/e2e-tests/cjs-http/entrypoint.sh:107">
P2: Test requests don't fail on HTTP error responses because curl is missing `-f`. This can allow the E2E test to pass even when endpoints are returning 4xx/5xx. Add `-f` so non-2xx responses fail the script.</violation>
</file>
<file name="src/instrumentation/libraries/grpc/e2e-tests/cjs-grpc/entrypoint.sh">
<violation number="1" location="src/instrumentation/libraries/grpc/e2e-tests/cjs-grpc/entrypoint.sh:16">
P1: Avoid `pkill -f "node"` because it can terminate unrelated Node.js processes on the host. Track the server PID when you background it and kill that PID instead.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
src/instrumentation/libraries/grpc/e2e-tests/cjs-grpc/entrypoint.sh
Outdated
Show resolved
Hide resolved
src/instrumentation/libraries/firestore/e2e-tests/cjs-firestore/entrypoint.sh
Outdated
Show resolved
Hide resolved
src/instrumentation/libraries/firestore/e2e-tests/esm-firestore/entrypoint.sh
Outdated
Show resolved
Hide resolved
src/instrumentation/libraries/mysql/e2e-tests/esm-mysql/entrypoint.sh
Outdated
Show resolved
Hide resolved
src/instrumentation/libraries/mysql/e2e-tests/cjs-mysql/entrypoint.sh
Outdated
Show resolved
Hide resolved
src/instrumentation/libraries/fetch/e2e-tests/esm-fetch/entrypoint.sh
Outdated
Show resolved
Hide resolved
src/instrumentation/libraries/fetch/e2e-tests/esm-fetch/entrypoint.sh
Outdated
Show resolved
Hide resolved
src/instrumentation/libraries/http/e2e-tests/cjs-http/entrypoint.sh
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5 issues found across 24 files (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="src/instrumentation/libraries/prisma/e2e-tests/cjs-prisma/entrypoint.sh">
<violation number="1" location="src/instrumentation/libraries/prisma/e2e-tests/cjs-prisma/entrypoint.sh:77">
P2: `curl -f` will treat the expected error response as a failure and, with `set -e`, abort the E2E run. For error-path endpoints, drop `-f` (or tolerate the non-zero status) so the test can proceed.</violation>
<violation number="2" location="src/instrumentation/libraries/prisma/e2e-tests/cjs-prisma/entrypoint.sh:78">
P2: `curl -f` will treat the expected 404 response as a failure and, with `set -e`, abort the E2E run. For the not-found error path, drop `-f` (or tolerate the non-zero status).</violation>
<violation number="3" location="src/instrumentation/libraries/prisma/e2e-tests/cjs-prisma/entrypoint.sh:79">
P2: `curl -f` will treat the expected validation error response as a failure and, with `set -e`, abort the E2E run. For this error-path endpoint, drop `-f` (or tolerate the non-zero status).</violation>
</file>
<file name="src/instrumentation/libraries/grpc/e2e-tests/cjs-grpc/entrypoint.sh">
<violation number="1" location="src/instrumentation/libraries/grpc/e2e-tests/cjs-grpc/entrypoint.sh:111">
P2: `curl -f` treats the expected 400 response from `/calc/divide-by-zero` as a failure. With `set -e`, this will abort the E2E run before traces/tests complete. Use a non-failing curl invocation for this endpoint.</violation>
<violation number="2" location="src/instrumentation/libraries/grpc/e2e-tests/cjs-grpc/entrypoint.sh:117">
P2: `curl -f` will exit non-zero for the expected 404 response from `/test/user-not-found`, and with `set -e` this stops the test run. Avoid `-f` for this endpoint or explicitly allow the error.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
src/instrumentation/libraries/prisma/e2e-tests/cjs-prisma/entrypoint.sh
Outdated
Show resolved
Hide resolved
src/instrumentation/libraries/prisma/e2e-tests/cjs-prisma/entrypoint.sh
Outdated
Show resolved
Hide resolved
src/instrumentation/libraries/prisma/e2e-tests/cjs-prisma/entrypoint.sh
Outdated
Show resolved
Hide resolved
src/instrumentation/libraries/grpc/e2e-tests/cjs-grpc/entrypoint.sh
Outdated
Show resolved
Hide resolved
src/instrumentation/libraries/grpc/e2e-tests/cjs-grpc/entrypoint.sh
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 issue found across 99 files (changes from recent commits).
Note: This PR contains a large number of files. cubic only reviews up to 75 files per PR, so some files may not have been reviewed.
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="src/instrumentation/libraries/e2e-common/test-utils.mjs">
<violation number="1" location="src/instrumentation/libraries/e2e-common/test-utils.mjs:48">
P2: Global `fetch` is used without a polyfill/guard, but the SDK declares support for Node >=16. Node 16 doesn’t provide global `fetch`, so these tests will crash with `ReferenceError: fetch is not defined` when run on supported runtimes.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| const warmupEnd = Date.now() + BENCHMARK_WARMUP * 1000; | ||
| while (Date.now() < warmupEnd) { | ||
| try { | ||
| const resp = await fetch(url, fetchOptions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Global fetch is used without a polyfill/guard, but the SDK declares support for Node >=16. Node 16 doesn’t provide global fetch, so these tests will crash with ReferenceError: fetch is not defined when run on supported runtimes.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/instrumentation/libraries/e2e-common/test-utils.mjs, line 48:
<comment>Global `fetch` is used without a polyfill/guard, but the SDK declares support for Node >=16. Node 16 doesn’t provide global `fetch`, so these tests will crash with `ReferenceError: fetch is not defined` when run on supported runtimes.</comment>
<file context>
@@ -0,0 +1,125 @@
+ const warmupEnd = Date.now() + BENCHMARK_WARMUP * 1000;
+ while (Date.now() < warmupEnd) {
+ try {
+ const resp = await fetch(url, fetchOptions);
+ await resp.text();
+ } catch {
</file context>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to note this down but I won't fix it because I don't see me running benchmarks for different versions of node anytime soon. I don't think it matters, what matters is not the raw numbers but the relative impact of our SDK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood — thanks for clarifying the benchmark context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 issues found across 39 files (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="src/instrumentation/libraries/e2e-common/base-entrypoint.sh">
<violation number="1" location="src/instrumentation/libraries/e2e-common/base-entrypoint.sh:97">
P2: Piping to `tee` masks the exit status of `node`, so failures in `test_requests.mjs` won't stop the benchmark run. Capture and check the `node` exit code (or enable pipefail) to avoid silently passing failed runs.</violation>
<violation number="2" location="src/instrumentation/libraries/e2e-common/base-entrypoint.sh:113">
P2: This pipeline hides failures from `node`, so a failed SDK benchmark run won't be caught. Capture `node`’s exit status (or enable pipefail) to ensure failures stop the script.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 issue found across 2 files (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="src/instrumentation/libraries/e2e-common/base-entrypoint.sh">
<violation number="1" location="src/instrumentation/libraries/e2e-common/base-entrypoint.sh:246">
P2: `grep` without `-P`/`-E` does not treat `\s` as whitespace, so these patterns won’t match JSON with spaces (e.g., `"passed": true`). That can make the test results appear empty even when tests ran.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Similar to Use-Tusk/drift-python-sdk#60
Comparison of baseline (SDK disabled) vs with SDK enabled (RECORD mode).
Negative diff = slower with SDK. Duration: 5s per endpoint, 3s warmup.
Below are the results, run on my laptop, took quite a long time to complete.
Note: The actual CLI output is not in markdown format, it's in a golang like format because I kind of like its simplicity and readability. This is also one complaint for the old benchmarks system, there's too much noise like QPS, latency, CPU, bla bla
Also a summary by claude:
fetch
grpc
http
ioredis
mysql
mysql2
nextjs
pg
postgres (postgres.js)
prisma
upstash-redis-js