Repository navigation
Description
Summary
Issue #502 established that full 500-image builds regressed badly after 2bfcc6c / PR #456. That change bundled two things:
- a useful
benchmarksrefactor for auto-detecting local Docker images - an SDK submodule bump from
b498a699tobde715c1
The observed regression is severe:
- historical fast run:
20806796288built 500 images in about 52 minutes and ended around 55 GiB BuildKit usage - historical slow run:
22694639473reached about 599 GiB BuildKit usage by batch 19 and ran for ~5h49m before cancellation - PR fix: Reuse pre-built SDK sdist to speed up image builds #499 (
22929182421) reused a prebuilt sdist but was still slow and still grew past 550 GiB, so per-image sdist creation is real but not the dominant issue
Current working hypothesis:
- The primary regression is in the SDK build path introduced by the submodule bump, not in the
benchmarkshelper refactor itself. - The slowdown is amplified by BuildKit prune/rebuild cycles once cold-cache runs blow past the runner disk budget.
- The Rich/fork logger issue is a real correctness bug, but it does not match the observed symptom of continuous, very slow progress.
This issue is to track a clean isolation plan and the fix strategy.
Related:
- Revert commit 2bfcc6c to speed up image builds #502
- Revert "feat: auto-detect pre-built Docker images across all benchmarks (#456)" #503
Why the previous fixes were only partial
#486addressed fork/spawn behavior, but not the cache-footprint regression.#487addressed SDK logger initialization behavior, but not the cache-footprint regression.#499addressed repeateduv build --sdist, but evidence suggests that only removes a secondary cost.#503is the correct short-term operational rollback, but it does not isolate the root cause.
Plan
Phase 0: unblock builds
- Merge
#503to restore known-good behavior while the regression is investigated.
Phase 1: add lightweight instrumentation
Add temporary env-gated timing and disk-usage logging around the hot path so we stop inferring from noisy historical runs alone:
- SDK
_make_build_context()duration - SDK
docker buildx buildduration - prune duration and pre/post
docker buildx duin thebenchmarksbatch loop
This should go into the exact historical branches / SHAs under test so the numbers are comparable.
Phase 2: run a reduced isolation matrix
Use isolated image namespaces for every run so cache-from / cache-to state does not bleed between experiments.
Run these cells:
- A. pre-
2bfcc6cbenchmarks+ old SDKb498a699(cold only) - B.
2bfcc6ccode path + old SDKb498a699(cold only) - C. pre-
2bfcc6cbenchmarks+ new SDKbde715c1(cold + warm) - D. full
2bfcc6c+ new SDKbde715c1(cold + warm)
Why this trimmed matrix:
- historical evidence already shows the old SDK can warm successfully, so we should not spend two extra 500-image runs proving A/B warm again
- the key open question is whether the new SDK can warm successfully at all, or whether prune pressure keeps it effectively cold between batches
These first runs are independent and should be dispatched in parallel once isolated namespaces are in place.
Phase 3: bisect the SDK hot path with real historical checkpoints
If Phase 2 points to the SDK bump, test these exact SDK refs against the same benchmarks commit and workflow inputs:
b498a699(baseline)35d75e3a(cache-tag truncation change in_base_slug())97731fe5(Python 3.12 change)5d65f389(--extra boto3)bde715c1(final bundled SDK ref)
Why include 35d75e3a:
_base_slug()changed from splitting on the first_tag_to the last_tag_- for some long SWE-bench image names, that changes the actual
buildcache-*tag values - this can create partial cache misses independently of the Python 3.12 /
boto3changes
This phase should tell us whether the main jump comes from:
- cache tag mismatch for a subset of images
- Python 3.12 base-image / layer changes
--extra boto3layer growth- or the combination
Phase 4: fix the real regression and the correctness bug
- Reintroduce the
benchmarkshelper refactor separately from any SDK bump. - Replace early
from openhands.sdk import get_loggerimports inbenchmarksutility modules with stdlib logging so workers do not inherit SDK/Rich logger state beforeProcessPoolExecutorforks. - If the SDK Dockerfile / dependency profile is confirmed as the main regression, fix that in the SDK build path rather than only tuning prune settings. Likely directions:
- make benchmark-oriented
source-minimalbuilds use a lighter dependency profile - avoid installing extras such as
boto3unless they are required for that target - scope Python-version workarounds to the targets that actually need them
- Keep the useful sdist-reuse optimization from
#499, but treat it as a follow-up optimization after the primary regression is fixed.
Phase 5: make cold-cache runs survivable
Cold-cache events will happen again whenever the SDK Dockerfile changes materially. Even if the SDK build profile is improved, the infrastructure should tolerate those transitions.
Treat this as co-equal with reducing SDK layer footprint, not as a minor operational footnote.
Candidate changes:
- use a larger-disk runner or higher
BUILDKIT_PRUNE_KEEP_GB(for example 150-200) for the first seed run after major SDK Dockerfile changes - reduce
max-workersfor intentionally cold-cache runs to limit concurrent disk pressure - optionally run a smaller warm-up build before the full 500-image build after an SDK Dockerfile change
- add
timeout-minutesand explicit prune timing logs so pathological runs fail faster and are easier to diagnose
Suggested execution order
- Confirm
#503restores build health. - Dispatch the reduced Phase 2 matrix with isolated namespaces.
- If the SDK bump is implicated, run the five-checkpoint SDK bisection.
- Land the low-risk correctness fix for stdlib logging in
benchmarksutilities. - Land the helper refactor without the SDK bump.
- Land the SDK-side fix for the benchmark build profile and/or cold-cache seed strategy.
Exit criteria
We should consider this fixed when we can show, with pinned refs and isolated namespaces, that:
- a 500-image cold-cache run completes without pathological prune/rebuild behavior
- a corresponding warm-cache run stays fast and within a stable disk envelope
- the
benchmarksrefactor can be carried without reintroducing the regression - SDK logger initialization is no longer happening in utility modules before process fork
Activity
fix: revert SDK to known-good baseline and fix build regression (#504)
fix: pin SDK to proven-working SHA and fix build regression (#504)
fix: pin SDK to proven-working SHA and fix build regression (#504)
fix: pin SDK to proven-working SHA and fix build regression (#504)
fix: pre-build SDK sdist once to eliminate 2h build overhead
simonrosenberg commentedon Mar 12, 2026
Update: Root Cause Identified and Fix Implemented
Root Cause
The primary regression is
uv build --sdistrunning once per image (~15s × 500 = ~2 hours of pure overhead). The SDK's_make_build_context()creates an identical sdist for every image build — same SDK code, just different base images/tags. This was introduced in the SDK build path betweenb498a699andbde715c1.The secondary issue (stdlib logging to prevent Rich/fork deadlocks) was already fixed in PR #505.
Fix: Pre-build SDK sdist Once (PR #505, commit ff70858)
The fix adds three things to
benchmarks/utils/build_utils.py:_pre_build_sdist()— builds the SDK sdist once before the batch loop starts (~15s total instead of ~2h)_build_with_cached_sdist()— extracts the pre-built sdist and runsdocker buildx builddirectly, bypassing the SDK's per-imageuv build --sdistOPENHANDS_CACHED_SDISTenv var — set bybuild_all_images()and inherited by forked worker processesWhy This Works for Any Future SDK Version
The fix operates entirely in the benchmarks repo. It does not depend on a specific SDK SHA:
build()logic (same tags, same cache strategy, same build args)build()function (per-image sdist)The fix can also be complemented by SDK-side changes (e.g., adding native
OPENHANDS_CACHED_SDISTsupport to_make_build_context()), but it doesn't require them.Key Requirement
Any solution must support evaluating any future version of the SDK. We regularly bump the SDK submodule to test new versions, and the image build pipeline must handle this without multi-hour regressions. Pinning to a specific SDK SHA is not acceptable as a long-term fix — it's only useful as a temporary workaround.
Current Status
fix/504-build-regression-sdk-revert-and-logging)simonrosenberg commentedon Mar 12, 2026
Results: Sdist Caching Fix Verified
Both 500-image builds completed successfully with the sdist caching fix (commit
ff70858):Comparison with previous runs
30819566Evidence from CI logs
The sdist was built once in 3.5 seconds and reused across all 500 images, eliminating the ~2 hour overhead of running
uv build --sdistper image.Summary
The sdist caching fix reduces build times below even the pre-regression baseline. The fix works for any SDK version since it builds from whatever submodule SHA is checked out.
simonrosenberg commentedon Mar 12, 2026
Summary from the latest investigation and full-run attempts on March 12, 2026.
What is fixed:
uv build --sdistregression is fixed. We now prebuild one SDK sdist and reuse it through a real SDK API (prebuilt_sdist) instead of rebuilding an sdist per image.What we validated in the latest runs:
3d93862f394ba608f2547062f16287a96efcd741and SDKfc962c4c8d7fd6eb0e91db06a5ec9911b29589ac.--max-workers 32 --build-batch-size 50--max-workers 16 --build-batch-size 50Reusing pre-built sdistshared=buildcache-shared-source-minimalImportant observation about the GitHub Actions logs:
Measured throughput from the latest log snapshots:
50/500at1:34:18after image builds started, which is about0.53 images/min.40/433at1:27:20, which is about0.46 images/min.already exists. Skipping build.lines, so its later progress is partially inflated by skips; the cleanest cold-build signal is still the first 50 images in ~94 minutes.Current conclusion:
uv build --sdist.docker buildx build --pushfor cold images.base-image-minimalstage that still has to run uniquely for each distinct base image.Most likely next fixes:
cache-fromfor the rest of the builds, but do not have every parallel build also writecache-tofor that same shared ref.So at this point we have fixed the original SDK packaging regression, but we have not yet achieved acceptable end-to-end cold-build throughput for 500-image runs. The next work should focus on cache warm-up / cache-write strategy and then, if needed, Dockerfile restructuring.
simonrosenberg commentedon Mar 12, 2026
Correction to my previous report: the “latest local logs” I referred to there were from newer runs on different refs, not from the actual feature-branch runs.
This corrected report is based only on the two runs that used the intended fix path:
Those runs used:
3d93862f394ba608f2547062f16287a96efcd741(fix/issue-504-cached-sdist)fc962c4c8d7fd6eb0e91db06a5ec9911b29589ac(fix/prebuilt-sdist-api/ SDK PR #2399)What actually happened in the feature-branch runs
The fix path was definitely active
In both runs:
$ uv build --sdistcalls in the main logsReusing pre-built sdistshared=buildcache-shared-source-minimal)Counts from the run logs:
SWE run
23017371628:Reusing pre-built sdist:69$ uv build --sdist:0$ docker buildx build:6958210SWT run
23017371689:Reusing pre-built sdist:60$ uv build --sdist:0$ docker buildx build:6071270So the feature worked exactly as intended on packaging: the repeated SDK sdist build regression was gone.
What did not improve
Despite that, end-to-end throughput was still poor.
SWE:
1h04m53s50/500completed at1h34m18s58/500completed by cancellation13of the first50were skips37real builds completed in the first94.3minutes0.39 real builds/minSWT:
25m04s50/433completed at2h00m52s71/433completed by cancellation8of the first50were skips42real builds completed in the first120.9minutes0.35 real builds/minImportant observations from the feature-branch runs
0failures up to cancellation13.10%BuildKit usage, no prune needed13.37%BuildKit usage, no prune needed/var/lib/buildkitusage stayed under20%64m53sjust to get the first completion25m04sjust to get the first completionHistorical apples-to-apples comparison
SWE-Bench
Recent successful full
500/500SWE runs fall into two groups:Warm/no-op runs:
22985173176:33m17s,500skips22989697696:36m46s,501skips23000725941:27m34s,500skips22921613845:29m57s,500skipsThese are not valid cold-build baselines.
Partially-cold runs:
22906744352:2h55m26s,328skips, about172real builds22967520137:4h02m23s,369skips, about131real buildsI still do not have a recent successful SWE
500/500run with low skip count that qualifies as a clean cold full-build baseline.So the honest SWE conclusion is:
SWT-Bench
SWT has much better true cold historical baselines.
Warm/no-op runs:
22985173172:21m42s,433skips22989698608:25m06s,435skips23000734281:17m36s,433skipsCold / mostly-cold full runs:
21870877504(Feb 10):66m06s,0skips50/433at18m29s100/433at40m52s22120331118(Feb 18):2h03m36s,4skips50/433at47m39s100/433at1h09m41s22328944424(Feb 23):2h20m06s,23skips50/433at29m11s100/433at53m30sFeature-branch run
23017371689:50/433at2h00m52s42of those first50were real buildsThat is still dramatically worse than historical SWT cold performance.
Updated conclusion
My corrected view is:
uv build --sdistbehavior.prebuilt_sdistAPI from PR #2399 was actually being used.The remaining bottleneck is not the Python packaging step anymore. It is still in the actual Docker/buildx/cache path.
juanmichelini commentedon Mar 13, 2026
Notice https://github.com/OpenHands/benchmarks/actions/runs/23043936501/job/66928367859 succeeded because it relied on build
https://github.com/OpenHands/benchmarks/actions/runs/23033839708 both built the same sdk 8e8223b24dfd041875fe845b13326b0a1238b793
so the one that succeed started with a 203 head start
✅ Done: 47%|████▋ | 203/433 [00:20<00:09, 24.25it/s, ✅ 203 ❌ 0 🏃 47
...
✅ Done: 100%|██████████| 433/433 [4:10:33<00:00, 17.59s/it, ✅ 433 ❌ 0 🏃 0]
fix(ci): restore SWT-Bench build parallelism and disable cache export
simonrosenberg commentedon Mar 18, 2026
Closing in favor of #531, which supersedes this as the master tracker for the image build regression.
This issue's 5-phase isolation plan was partially executed: Phase 0 (sdist fix, PR #515) is merged, but Phases 2-5 (the controlled isolation matrix and SDK bisection) were not formally run. The empirical data collected since then — especially the rigorous warm/cold accounting in #530 and the March 17 A/B test (cache mode=min vs mode=off) — have answered most of the questions the matrix was designed to address.
Key findings carried forward to #531:
Historical data: #530.