Repository navigation
feat:support benchmark - #28
Merged
Merged
Conversation
Add a top-level `benchmark` (alias `bench`) command group that measures sandbox service latency through the SDK: - `benchmark lifecycle` times create, first exec and kill per iteration - `benchmark create` times create alone and leaves sandboxes to time out Each phase reports avg/min/P50/P95/P99/max, split into connection setup (DNS, dial, TLS via httptrace) and service time. The SDK's 429 retry is disabled so rate limiting surfaces as errors instead of latency. Sandboxes are tagged with a unique run ID and the sandbox-bench manage-by marker, and the output prints the command that cleans them up. Also let config.NewClient take option modifiers and add table.RenderPlain for tables without the pagination header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add `benchmark health`, which puts every sandbox through a series of checks between create and kill and reports each as its own phase: - exec: run a command - filesystem: write a random token through envd and read it back - internet: curl each --url and require HTTP 200 (default: Apple's connectivity probe, reachable from every region) - intranet: sudo ping the region's internal US3 endpoint (internal.s3-<region>.ufileos.com, cn-sh uses cn-sh2) - public-url: serve a token inside the sandbox and fetch it through the sandbox's public URL - pause: pause, resume and run a command again --skip and --only select checks. A failing check does not stop the ones after it. To support it, the runner now takes a list of steps run on each sandbox, so lifecycle, create and health share one implementation. Also rename the JSON field throughput_per_sec to rate_per_sec, print the run header one item per line, and add config.ResolveRegion. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Describe the Command() group and <name>Operation pattern the commands actually use, in place of the outdated New<CommandName>Cmd() rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add `benchmark snapshot`, which times each step of snapshotting a
sandbox and booting copies of it, checking the copies keep its files:
create, write, snapshot, restore, restore-verify, fork, fork-verify,
snapshot-delete, kill
Snapshots are named bench-<runID>-<sandbox-id> and deleted by that
name: DELETE /templates/{id} answers 404 for the "<team>/<name>:<tag>"
ID the snapshot is created with. A 404 on delete counts as a leak,
since a snapshot never expires. The copies are killed, untimed, before
the snapshot is deleted. Snapshots that cannot be deleted are listed
with the command that deletes them, and copies that cannot be killed
are listed with a kill-by-ID command, since forks may lack the run tag.
The runner gains untimed steps and LeakedError, so any step can report
sandboxes it failed to kill and fail the iteration.
Tables now show each phase's service time, excluding connection setup,
by default; --breakdown shows the full latency with its connect and
service rows, as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add an iterations array to the JSON report of every benchmark command,
one entry per iteration that ran, ordered by seq:
seq, sandbox_id, start_offset_ms, succeeded, leaked,
phases: [{phase, duration_ms, connect_ms} | {phase, error}]
Phases are listed in the order they ran. A failed phase carries only
its error, with the sandbox ID kept; a phase never reached is left out;
an untimed step shows up only when it fails; total only when every
phase succeeded. start_offset_ms places each iteration on the run's
timeline, so latency drift over a run can be seen. The pretty output
is unchanged.
To support it, IterationResult replaces its Durations and Connects
maps and Errors list with one ordered Phases list, and gains Seq and
Start; Run hands out sequence numbers and Report keeps the results.
Also note in forkSandbox that the service copies the source's metadata
to its forks, so the tag-based cleanup command reaches them too.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace the health benchmark's intranet ping with a curl probe. Any HTTP response counts as reaching the service, since the region's US3 endpoint answers an anonymous request with 400; the check then measures what sandboxes actually do, needs neither sudo nor ping, and reports how far a failed request got (resolved, connected, first byte), so a slow name lookup can be told from a connection that never came. --intranet-url replaces --intranet-host and defaults to https://internal.s3-<region>.ufileos.com/. ResolveRegion reads the region from a "<region>.sandbox.ucloudai.com" domain, which the API prefers over the region, and reports when it cannot tell: the intranet check then asks for --intranet-url instead of probing another region's endpoint. A custom domain names no region, and the flag is not needed when the check is skipped. health's scratch file paths are fixed rather than random, so the same failure groups into one report row, and a step that never ran is marked with the new errNotAttempted sentinel, so it is not taken for a request that failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
-o/--output writes the JSON report to a file whatever --format prints, so one run can show its table and keep its samples; previously the two were mutually exclusive, and running twice to get both compared two different runs. The path is checked before the run starts and the file is written after the report is printed, so a wrong path costs neither the run nor its results. Grouped error messages drop the request URL net/http puts in front of the cause for any verb, kill's DELETE included, so long URLs no longer push the cause off the end of the message column. Untimed steps' connection setup now counts toward total's connect rather than its service time. A run that finishes in the same instant its context is cancelled no longer prints the interrupted banner: the watcher checks whether the run already finished before announcing anything. Tables say whether they show service or full latency, restore and fork failures that never sent a request no longer claim a sandbox may have been started, and checkResume uses the notAttempted sentinel. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Piwriw
force-pushed
the
feat/benchmark
branch
from
November 27, 2026 09:51
79c7156 to
3af2f81
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat:support benchmark