LedgerMath

View as Markdown

s3_throughput

Written entirely by AI

Sustained aggregate HTTPS GET streaming throughput from S3 across concurrency parallel worker threads (1 to 128), each holding a kept TLS 1.2/1.3 connection via statically linked AWS-LC and incrementally verifying every 2xx response body against the Fixture SHA-256 through a fixed 64 KiB buffer per thread.

What a figure means

Each sample runs all concurrency worker threads in parallel for at least duration_ms (and until each worker has run at least one request, or the hard deadline below). Workers repeatedly issue signed (or unsigned) HTTP/1.1 GET requests for key, stream the body through a 64 KiB buffer into an incremental SHA-256 digest, and verify every 2xx body matches object_bytes of the Fixture pattern. No request starts after duration_ms; one in flight then has until the sample's hard deadline, duration_ms + timeout_ms (drain_limit_ms) after its start, to finish: every read of a response is bounded by it, and a response still arriving at the deadline is cut off, its connection closed, and counted as a failed request (failure timeout, requests_cut in its throughput_sample). A server trickling a response cannot stretch a sample past the deadline. Nor can a reconnect: once duration_ms has passed, a worker that has run a request opens no new connection, a connection opened later in the sample gets only the time left before the hard deadline for its DNS, connect and handshake, and at the deadline a per-worker timer interrupts whatever call the worker is still blocked in.

Because the opening observed event sets bytes_per_repetition to object_bytes and each sample_started sets repetitions to the number of verified requests completed in that sample, Method runs v1 directly derives aggregate throughput (bytes_per_second) across counted samples. Each sample also emits a throughput_sample event (bytes, requests_ok, requests_failed, requests_cut, duration_ns, throughput_bps), and the Run emits one op_histogram (metric get_latency, in methods/requests v1's bins, the harness's lm_hist.h) of every verified request completed in a counted sample, from just before its request is written to its body's last byte.

What a figure does not show

  • Initial DNS/TCP/TLS setup happens before sample 0, so sustained figures reflect kept connections rather than per-request handshakes (though connections closed by the server are reopened inside the window).
  • Every byte is hashed with SHA-256 on the client CPU; on small instances, TLS decryption plus SHA-256 verification can become CPU-bound before NIC saturation.
  • Single-request phase breakdowns (DNS, TCP, TLS, TTFB) are measured by http_get, not here.

Parameters

The benchmark's Series and their figures are listed at https://api.ledgermath.com/v1/benchmarks/s3_throughput.json.

In us-east-2c, the schedule runs 16 MiB throughput sweeps (concurrency 1, 4, 16, 64) against s3_fixtures (c6i.8xlarge, i4i.2xlarge, c8g.2xlarge, c8i.2xlarge) and s3_express (c6i.8xlarge, c8g.2xlarge, directory bucket in us-east-2b). Across all seven AWS Regions (us-east-2c, us-east-1a, us-west-2a, eu-west-1a, eu-central-1a, ap-northeast-1a, ap-southeast-1a), c8i.2xlarge boxes (plus c6i.8xlarge from us-east-2c) run a 7 × 7 S3 mesh of 16 MiB sweeps against s3_fixtures (us-east-2) and the six remote-region fixture Services (s3_fixtures_us_east_1, s3_fixtures_us_west_2, s3_fixtures_eu_west_1, s3_fixtures_eu_central_1, s3_fixtures_ap_northeast_1, s3_fixtures_ap_southeast_1). Match target.availability_zone_id for the source Region and service for the destination S3 Region.

VariableQuick defaultMeaning
LM_PARAM_OBJECT_BYTES65536Fixture object size in bytes (1 to 1,073,741,824)
LM_PARAM_KEYhttp_get/v1/65536Object key (1 to 1024 bytes, no leading /)
LM_PARAM_CONCURRENCY2Parallel worker threads and TLS connections (1..128)
LM_PARAM_DURATION_MS200Minimum duration per sample window in ms (capped to 200 ms under --quick)
LM_PARAM_TIMEOUT_MS5000Socket read/write/connect timeout in milliseconds
LM_PARAM_CA_FILE/etc/pki/tls/certs/ca-bundle.crtPEM CA bundle for TLS certificate verification
LM_PARAM_RESOLV_CONF/etc/resolv.confResolver file (first IPv4 nameserver, optional :port)
LM_PARAM_AUTHsigv4sigv4 (service s3), s3express (service s3express, x-amz-s3session-token), or none

Under --quick, LM_SAMPLES defaults to 2 counted samples (after 1 warmup sample) and duration_ms is capped at 200 ms. Service inputs are LM_SERVICE_ENDPOINT, and for signed modes LM_SERVICE_REGION, LM_SERVICE_AWS_ACCESS_KEY_ID, LM_SERVICE_AWS_SECRET_ACCESS_KEY, and optional LM_SERVICE_AWS_SESSION_TOKEN.

Observed values

Opening observed: bytes_per_repetition, concurrency, duration_ms, drain_limit_ms, tls_library, tls_library_source_sha256, tls_offer, client_hello, ca_file_sha256, ca_certificates_loaded, ca_certificates_rejected, resolver, fixture_sha256, and stream_buffer_bytes.

Closing observed: requests_ok, requests_failed, requests_cut_at_deadline, total_bytes, body_mismatch, connections_opened, statuses, failures, fields_withheld, and lines_withheld.

Findings

Streaming directly into a 64 KiB buffer per thread keeps peak memory constant (~8 MiB at 128 workers) regardless of object_bytes, allowing 16 MiB+ objects at high concurrency without allocating gigabytes of RAM while still cryptographically verifying every byte received.

On high-RTT intercontinental links at concurrency 64, individual 16 MiB streams can hit the sample's hard deadline (duration_ms + drain_limit_ms) or server EOF, causing the binary to exit 4. Method runs v1 requires exit 0, while Method ops v1 accepts exit 4 when the stream is valid and get_latency has at least one counted GET — tallying verified GETs in get_latency and taking bytes_per_second as the median rate across counted samples; check derivations.ops_v1 alongside derivations.runs_v1.

How it works

  1. Memory dumps are disabled and credentials are registered with lm_lines on the main thread before spawning workers; all stdout event emission stays on the main thread.

  2. Workers pre-open kept TLS connections, then synchronize on start/end pthread_barrier_t barriers for sample 0 (warmup) and samples 1..LM_SAMPLES.

  3. Each worker signs requests locally, parses response headers with lm_http_feed, streams Content-Length, chunked, or close-delimited bodies through its 64 KiB buffer with incremental SHA256_Update, and verifies the digest against fixture_sha256.

  4. After all samples complete, per-worker histograms are merged into op_histogram, and per-worker digest accumulators are hashed into verified.

  5. Exit codes: 0 all requests verified 2xx, 1 body mismatch or fatal setup error, 2 usage error, 3 stdout error, 4 any failed request or empty sample.

  6. With object_bytes of 1 MiB or more, some requests of each sample are traced: each worker among the first 16 traces its first 16 / min(concurrency, 16) requests of the sample (rounded down) that reach their body, so at most 16 per sample (16 requests of one worker at concurrency 1, 4 of each of 4 workers, one each of workers 0 to 15 at 16 and 64). A request reaches its body when its header block announces one: a response that ends at its headers (a 503 with Content-Length: 0, a 204) or fails before them takes no slot, so a burst of them does not use up the sample's traces. Past that the choice does not depend on how a request goes: a body that stalls, is cut off or fails keeps its slot and the points it reached. Each traced request is a transfer_progress event inside its sample, after sample_started, in the order the requests started:

    {"event":"transfer_progress","t":…,"sample":1,"worker":3,"status":200,"outcome":"verified",
     "bytes":16777216,"head_ns":…,"end_ns":…,"step_bytes":1048576,"anchor":"request_start",
     "points":[[ns,1048576],[ns,2097152],…]}

    t is the request's start, the same clock read that starts its get_latency time, and every *_ns counts from it (anchor request_start): head_ns when its header block was parsed, end_ns the read that ends get_latency (its body complete, or its failure). points (benchmarks/harness/c/lm_progress.h) are [ns, bytes], one each time the body read reached the next whole step (1 MiB below 65 MiB; past that the least power of two times 1 MiB that keeps the points at 64 or fewer), bytes the count after that read, past the step by less than one read (64 KiB). bytes is the body received; outcome is verified or mismatch for a whole 2xx body, complete for a whole body of another status, cut for one cut off at the hard deadline, otherwise the failure's name (eof, reset, protocol, …). A failed or cut request keeps the points it reached. The points show the shape inside one stream: the ramp of TCP's slow start, a stall partway. Cost inside the sample: for a traced request one extra clock read at its header block and one at each step, into a fixed array of 64 points in the worker's own struct (allocated and touched before the first sample); for every other request one comparison per read; under 1 MiB, nothing. Size: about 230 B plus about 21 B a point, about 570 B per 16 MiB request, so at most about 9 KB per sample: about 55 KB for a scheduled Run of 5 counted samples and the warmup, however high concurrency is. Methods ops v1 and runs v1 read nothing of it.

Building and testing

make -C benchmarks/s3_throughput AWS_LC_ARCHIVE=/path/to/aws-lc.tar.gz

Produces benchmarks/s3_throughput/build/static/s3_throughput. Verified end-to-end against the local HTTPS stand-in in tests/s3-benchmarks.test.ts, including the traced requests of 2 MiB objects at concurrency 1, of 1 MiB objects at concurrency 20 (workers 0 to 15, one each), a traced request cut off at the hard deadline, a sample opened by 20 503s with Content-Length: 0 whose verified GETs after them are still traced, and no transfer_progress under 1 MiB.