http_put
How long an HTTPS PUT or conditional PUT compare-and-swap (CAS) write to S3 takes, from the
box to a scratch prefix on the endpoint its Service names, over a new connection per request or
one kept connection, one request at a time on one thread. Supports plain PUT (none),
create-if-absent (if_none_match), and ETag-checked CAS updates (if_match), with sigv4,
s3express, or none authentication.
What a figure means
HTTPS PUT requests uploading object_bytes of the deterministic Fixture pattern (lm_fixture_word)
with precomputed x-amz-content-sha256 and x-amz-checksum-sha256 headers and no
Expect: 100-continue round-trip. Each sample is one PUT (repetitions: 1). Sample 0 is a
warmup; counted samples 1..LM_SAMPLES follow.
Under Method runs v1, a counted Run (exit 0) yields one figure: the median total PUT
latency in nanoseconds (time_per_repetition_ns). Each request records full phase timestamps
(request_sent, first_byte, response_headers, http_op_ended or http_op_failed) with
status, etag, condition, bytes_sent, cpu_ns, and tcp_info.
What a figure does not show
- One thread writes one object at a time with pauses of mean
gap_mean_ms; it does not measure concurrent write throughput or CAS contention between multiple writers. - With
connectionreused, DNS, TCP, and TLS setup occur outside timed samples. - In
if_matchmode, the initial object creation (seed_put) happens outside any timed sample. - Method
runsv1 reports the per-Run median, not the request tail.
Parameters
The benchmark's Series and their figures are listed at https://api.ledgermath.com/v1/benchmarks/http_put.json.
The schedule runs it on c8i.2xlarge and c8g.2xlarge, over a reused connection, to the
scratch bucket (s3_scratch, S3 Standard) and the S3 Express One Zone bucket
(s3_express): 4 KiB objects under each condition (if_match on S3 Standard only), 50
counted requests each; and 16 MiB objects (object_bytes 16777216, condition none),
20 counted requests each, with timeout_ms 30000 and budget_seconds 90. A 16 MiB
request's time is mostly the upload itself, so its figure is close to the time to send
16 MiB to S3 on one connection; dividing 16 MiB by it gives one connection's upload rate.
A Run of 16 MiB uploads 21 objects (336 MiB) under scratch/, which a lifecycle rule
empties.
| Variable | Quick default | Meaning |
|---|---|---|
LM_PARAM_OBJECT_BYTES | 4096 | Payload size in bytes (1 to 1,073,741,824), filled with the Fixture pattern |
LM_PARAM_KEY_PREFIX | scratch/http_put/v1 | Scratch key prefix (1 to 512 bytes, no leading /) |
LM_PARAM_CONDITION | none | none (plain PUT), if_none_match (If-None-Match: *), or if_match (If-Match: <etag> CAS) |
LM_PARAM_CONNECTION | new | new (fresh DNS/TCP/TLS per request) or reused (single kept connection) |
LM_PARAM_GAP_MEAN_MS | 10 | Mean exponential inter-request pause in milliseconds (fixed seed) |
LM_PARAM_BUDGET_SECONDS | 60 | Wall-clock budget before ending the Run early |
LM_PARAM_TIMEOUT_MS | 5000 | Socket read/write/connect timeout in milliseconds, and each PUT's whole exchange (its write and its response) from its start: a receiver that takes the body a little at a time cannot hold it longer, and it fails as timeout |
LM_PARAM_CA_FILE | /etc/pki/tls/certs/ca-bundle.crt | PEM CA bundle for TLS certificate verification |
LM_PARAM_RESOLV_CONF | /etc/resolv.conf | Resolver file (first IPv4 nameserver, optional :port) |
LM_PARAM_AUTH | sigv4 | sigv4 (service s3), s3express (service s3express, x-amz-s3session-token), or none |
Service inputs: 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: tls_library, tls_library_source_sha256, tls_offer, client_hello,
ca_file_sha256, ca_certificates_loaded, ca_certificates_rejected, resolver,
fixture_sha256, run_nonce, condition, payload_variation (with payload_varied_bytes
under if_match), and cpu_clock_read_ns.
Closing observed: requests_made, requests_not_made, ended_early, connections_opened,
connection_setups_failed, responses, responses_2xx, requests_failed, bytes_sent_total,
statuses, failures, fields_withheld, and lines_withheld.
Findings
Precomputing the payload SHA-256 once at startup and combining headers with payloads up to
64 KiB into a single SSL_write avoids extra TLS records and 100-continue stalls. In
if_match mode, each 2xx response's ETag advances the precondition for the next sample,
verifying S3 conditional write semantics end to end.
How it works
- Memory dumps are disabled and credentials are registered with
lm_linesbefore any network I/O so secrets and signatures never leak to stdout. - Each Run draws a random 64-bit
run_nonce. Plain andif_none_matchwrites target distinct keys<key_prefix>/<run_nonce>/<sample>;if_matchwrites<key_prefix>/<run_nonce>/casafter an untimedseed_putestablishes the initial ETag. Underif_matcheachPUTcarries other bytes than the one before it, so each write is a new version with its own content-derived ETag (under SSE-S3, the MD5 of the bytes) and a stale ETag is refused with 412: the same bytes again would keep the same ETag, and the swap would compare nothing.PUTk (0 the seed, sample s is s + 1) is the Fixture with its last min(8,object_bytes) bytes XORed with k, little-endian, at the same length (openingobserved:payload_variationtail_xor_put_number,payload_varied_bytes;nonefor the other conditions, whose keys differ instead). Its SHA-256 is finished from the Fixture's hashed state before those bytes, outside the sample, and eachrequest_sentnames it. - Requests are signed before
sample_started, including anyIf-None-MatchorIf-Matchheader,x-amz-content-sha256, andx-amz-checksum-sha256. verifiedis the first 64 bits of SHA-256 over every 2xx response'sETag(or status plus request ID ifETagis absent) in order.- Exit codes:
0all 2xx,1fatal setup error,2usage error,3stdout error,4any non-2xx (including 412 Precondition Failed), failed request, seed failure, or early stop. - With
object_bytesof 1 MiB or more,http_op_endedandhttp_op_failedcarryprogress, the moments inside the Send phase at which the body had been written up to each whole step (benchmarks/harness/c/lm_progress.h):{"step_bytes": 1048576, "anchor": "sample_started", "points": [[ns, bytes], ...]}. The body is written 1 MiB at a time after the request's head, and after each piece whose bytes reach the next step the clock (CLOCK_MONOTONIC_RAW) is read once, so a 16 MiBPUThas 16 points at exactly 1 MiB, 2 MiB, … 16 MiB (step_bytesis 1 MiB below 65 MiB, then the least power of two times 1 MiB that keeps the points at 64 or fewer).nscounts from the boundary before the request was written, whichanchornames:connection_securedon a new connection,sample_startedon a kept one, soanchor.t + nsplaces a point on the stream's clock, at or beforerequest_sent.t. A point is the moment the TLS library returned from writing that piece: its bytes are in the kernel's send buffer, not yet acknowledged by S3, so the points lead the wire by at most the send buffer. The ramp of TCP's slow start and a stall while S3 stops reading still show, as the writes block. APUTthat fails after its head was written keeps the points it reached (http_op_failedwithphasesendanderrortimeout, after a receiver that stopped reading, shows how far the body got). The cost inside the sample is one comparison per piece and one clock read at each step, into a fixed array of 64 points in the request's own struct: nothing is allocated, the CPU clock is not read, and under 1 MiB nothing is done at all. About 75 B plus about 21 B a point, so about 410 B per 16 MiB request: about 9 KB more for the schedule's 16 MiB sets (20 counted requests and the warmup).
Building and testing
make -C benchmarks/http_put AWS_LC_ARCHIVE=/path/to/aws-lc.tar.gz
Produces benchmarks/http_put/build/static/http_put. Verified end-to-end against the local
HTTPS stand-in in tests/s3-benchmarks.test.ts, including progress for 16 MiB (kept
connection) and 2 MiB (new connections) bodies and its absence under 1 MiB, and in
tests/http-put.test.ts the points a 16 MiB PUT keeps when its receiver stops reading.