Repository navigation
fix(benchmark): avoid negative curl/cargo cases that fail the benchmark job - #3430
Conversation
|
Hey @ousamabenyounes , thanks for this, actually @KuSh already opened an issue on mockhttp repo and this should be solved now that it is merged , jaredwray/mockhttp#181 , so apparently we should get a stable /json/1 |
|
Still missing a release on mockhttp side for the stable endpoint to be available though |
74e8221 to
6c7df92
Compare
|
Rebased this PR onto the latest Validation: upstream local benchmark RED with the two affected negatives; focused cargo regressions GREEN (2/2); full local replay GREEN with 2,593 unit tests plus integrations, fmt, clippy, test-presence, benchmark (0 negatives), and changed-line coverage. Remote CI passes every check except the pre-existing unrelated Force-pushed the rebased branch ( |
|
mockhttp responses still aren't stable as there wasn't any release since the fix was merged |
KuSh
left a comment
There was a problem hiding this comment.
Two things:
-
The
mockhttppart should not be needed even if frustrating atm. I hope they’ll release a newmockhttpversion soon. But if not,benchmark.shshould be made fully offline, not just for JSON, and preserve everything that was tested before. -
The cargo part looks OK to me but:
- You should apply the same guards elsewhere in the file (CargoTestHandler for example)
- It would also be great to fix the fact that we don’t compact tiny cargo success build output; that doesn’t seem too difficult.
6c7df92 to
a59a37d
Compare
|
Pushed a follow-up addressing both review points: Fully offline & deterministic — dropped the remaining Exercises JSON minification — the fixture is pretty-printed and served with a real Local replay against The 56% good line is a non-fatal WARNING; the job only fails on negatives or empty output, both now 0. Also applied the same |
KuSh
left a comment
There was a problem hiding this comment.
Hi, this is going in the right direction, but it needs a bit more work
….org The remaining online calls (curl robots.txt + wget /json on mockhttp.org) were both a network dependency and non-deterministic. Serve fixed local fixtures over a loopback http.server so curl and wget get real Content-Type headers (exercising JSON minification), fully offline. curl falls back to file:// when python3 is unavailable. Clean up the server, temp fixtures, and the ./data.json download on exit.
CargoTestHandler.format_summary could emit a compacted summary larger than the raw output on tiny runs, same failure mode CargoBuildHandler already guards. Wrap all return paths with never_worse so the raw output wins when the summary would be bigger.
…et -e safe Review follow-up on rtk-ai#3430: - Bind `python3 -m http.server 0` so the kernel picks a free port and read the chosen one from the (unbuffered) server log, instead of hardcoding 8899 which fails needlessly when that port is already in use. - Make `cleanup_net_fixtures` failure-tolerant: it runs from an EXIT trap under `set -e`, so `[ -n "$PID" ] && kill ...` aborted the whole handler whenever `kill` failed (server already dead), leaking the fixture dir and downloads. - Give the wget case an explicit skip line instead of silently disappearing. wget rejects `file://` ("Unsupported scheme"), so there is no offline URL to fall back to when the loopback server is unavailable. RED (PR HEAD): fixture dir NOT removed when kill fails; server unusable with 8899 taken. GREEN: fixture dir removed; server up on an ephemeral port.
…se guard Review follow-up on rtk-ai#3430: - Replace the IIFE closure in `CargoTestHandler::format_summary` with a private `compute_test_summary` on the existing `impl CargoTestHandler`, and apply `never_worse` at the call site, as suggested. - Add `test_cargo_test_summary_uses_raw_when_summary_is_larger`: a one-line compile failure whose "cargo test: N errors, ..." header is larger than the raw output, so the guard must return the raw output. RED→GREEN: the new test fails on upstream develop (returns the 105-byte header form instead of the 62-byte raw), passes here. Full suite: 2612 unit + 78 integration tests pass; benchmark 0 negative (develop baseline: 1).
c4ac631 to
d003920
Compare
|
Thanks for the detailed review @KuSh — all five points are addressed in
Validation RED (before), on the shell asks: RED (before), on the cargo ask, run on upstream GREEN (after), full local CI replay: Remote CI on Unrelated heads-up while I was in there: |
KuSh
left a comment
There was a problem hiding this comment.
LGTM, thanks! Don’t hesitate to push a follow-up PR to fix the broken BENCH_DIR cleanup
…arness `BENCH_DIR="$(pwd)/scripts/benchmark"` is a tracked directory: besides the gitignored `unix/`, `rtk/` and `diff/` output dirs it holds the TypeScript VM-benchmark harness (`run.ts`, `cleanup.ts`, `rebuild.ts`, `lib/*.ts`, `cloud-init.yaml`). `rm -rf "$BENCH_DIR"` therefore wiped all 7 tracked files from the working tree on every local run (`$CI` unset), which is exactly when a contributor runs the benchmark before pushing. Wipe only the three gitignored output subdirectories instead. Stale output is still cleared between runs; the harness survives. Follow-up to #3430 (#3430 review).
rtk 0.46.0 Created-by: HarmonybrewBot Commit-by: HarmonybrewBot Merged-by: HarmonybrewBot Description: Created by `brew bump` --- Created with `brew bump-formula-pr`.<details> <summary>release notes</summary> <pre>## [0.46.0](rtk-ai/rtk@v0.45.0...v0.46.0) (2026-08-26) ### Features - find: dispatch on find's grammar; compress find output for unmodeled predicates ([#3603](rtk-ai/rtk#3603)) - find: tee tail hint when rtk imposes the result cap ([#3603](rtk-ai/rtk#3603)) ### Bug Fixes - find: never-worse guard, recovery hint, and dispatch on find's grammar ([#3603](rtk-ai/rtk#3603)) - git: don't misdetect a value-taking option's argument as a patch flag ([#3575](rtk-ai/rtk#3575)) - cicd: stop benchmark.sh deleting the tracked scripts/benchmark harness ([#3595](rtk-ai/rtk#3595)) - tee: hash long recovery-file slugs to prevent collisions and shorten hints ([#3266](rtk-ai/rtk#3266)) - benchmark: avoid negative curl/cargo cases that fail the benchmark job ([#3430](rtk-ai/rtk#3430)) - test: accept both Ask and Allow verdicts in rewrite tests ([#3147](rtk-ai/rtk#3147)) — Closes [#3146](rtk-ai/rtk#3146) - core: decode process output using Windows console code page ([#2717](rtk-ai/rtk#2717)) — Closes [#2452](rtk-ai/rtk#2452) - git: preserve patch output from log commands ([#2951](rtk-ai/rtk#2951)) — Closes [#2944](rtk-ai/rtk#2944) - discover: sanitize drive-letter colon so Windows discover finds sessions ([#2952](rtk-ai/rtk#2952)) — Closes [#2919](rtk-ai/rtk#2919) - stream: decode lossily instead of dropping lines on invalid UTF-8 ([#2997](rtk-ai/rtk#2997)) — Closes [#2994](rtk-ai/rtk#2994) ### Other - test(find): use the platform temp dir instead of /tmp ([#3717](https://github.com/rtk-ai/rtk/pull/3717))</pre> <p>View the full release notes at <a href="https://github.com/rtk-ai/rtk/releases/tag/v0.46.0">https://github.com/rtk-ai/rtk/releases/tag/v0.46.0</a>.</p> </details> <hr> See merge request: Harmonybrew/homebrew-core!17826
Problem
The shared
benchmarkCI job (scripts/benchmark.sh) fails withBENCHMARK FAILED: N filter(s) produced more tokens than raw outputondevelop:cargo build:18 → 25tokens for an already-small successful build.curl json: negative on and off againsthttps://mockhttp.org/json/1— the endpoint is a network dependency and its payload varies, so the result is not reproducible.Because this lives in the shared benchmark script, every branch based on
developinherits the red job regardless of its own diff.Fix
scripts/benchmark.sh: serve deterministic local fixtures from a loopbackpython3 -m http.serverfor both curl and wget — fully offline, and the JSON is pretty-printed and served with a realContent-Type: application/jsonsortk wgetactually exercises JSON minification (47 → 12, +74%).http.server 0(kernel-picked port) and reads the chosen port back from the server log, so a busy port cannot fail the run.cleanup_net_fixturesis failure-tolerant: it runs from an EXIT trap underset -e, where[ -n "$PID" ] && kill …aborted the handler wheneverkillfailed and leaked the fixture dir and downloads.wgetrejectsfile://, so there is no offline fallback URL).src/cmds/rust/cargo_cmd.rs: guard the streamed and non-streamed cargo build success summaries, and thecargo testsummary, withcore::guard::never_worse(raw, summary). The test-summary path extracts a privatecompute_test_summaryand applies the guard at the call site.Test plan
cargo fmt --all && cargo clippy --all-targets -- -D warnings && cargo test --all./scripts/benchmark.shTest verification (RED → GREEN)
RED — new cargo guard test on upstream
develop(32c83cc):RED — benchmark script asks, driven against the pre-fix script:
RED — benchmark job on upstream
develop(32c83cc, run 31976715084):GREEN — this branch:
Remote CI on this branch matches the
developbaseline except that the two negatives this PR targets are gone. The single remaining benchmark negative (find --max 10,40 → 48) is pre-existing and reproduces identically ondevelop's own run for the same base commit.