Skip to content

Commit 244eafa

Browse files
committed
[DESIGN] Resolve who owns retry, and name the quantities apart
The comparison table said option C keeps retry and concurrency inside the backend while the recommendation put a scheduler above the transport owning exactly those. One row cannot answer for both, so it is now two: admission and retry above, connection and stream scheduling below. max_concurrent_requests currently stands for a record rate, an attempt count and a connection count depending on who is reading it, so the document now names those apart before comparing anything. The reported workload is a record rate; "about four" is an attempt count. The byte bound, the separation of export operations from attempts, and exactly-once settlement move out of the open questions and into requirements, since no answer to the remaining questions makes them optional. The decision list splits into what #4448 has settled and what is still open, so a reviewer can object to one line rather than re-read the thread. Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
1 parent 06805b1 commit 244eafa

1 file changed

Lines changed: 55 additions & 3 deletions

File tree

‎docs/cpp-http-transport-design.md‎

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,22 +236,56 @@ This is a backend implementation choice. It does not have to appear in the
236236
public interface, and it should not: a native Windows or Apple transport has no
237237
multi handle to own.
238238

239+
## The words this needs, since one of them is doing too much work
240+
241+
`max_concurrent_requests` currently stands for several different quantities, and
242+
the sections above only make sense if they are named apart.
243+
244+
| term | what it counts |
245+
| --- | --- |
246+
| record rate | records the application produces per second |
247+
| export operation | one batch, from first attempt to final outcome |
248+
| attempt | one HTTP request; a retried operation has several |
249+
| admitted | attempts the governor has let start |
250+
| pending | attempts waiting for capacity rather than for the network |
251+
| running transfer | attempts libcurl is currently working on |
252+
| connection | one TCP or QUIC connection to an origin |
253+
| stream | one exchange on a connection; one at a time on HTTP/1.1 |
254+
| retained bytes | serialized request bytes held for attempts that have not settled |
255+
256+
The reported workload is a record rate. The "about four" is an attempt count.
257+
They are not the same number and a benchmark that reports one as the other
258+
cannot be compared with anything.
259+
239260
## Against the criteria in #4448
240261

241262
| | A: current model | B: one attempt operation | C: single owner loop |
242263
| --- | --- | --- | --- |
243264
| Throughput, connection reuse | keeps both | reuse yes, in-flight count owned above it | keeps both |
244265
| Cancellation | flag plus races | explicit, at a defined point | explicit, owner thread applies it |
245266
| Shutdown | four reports open | bounded by construction | bounded, one thread to drain |
246-
| Retry and concurrency owner | inside the transport | left open, above the transport | inside the backend |
267+
| Admission and retry owner | inside the transport | above the transport | above the transport |
268+
| Connection and stream scheduling | implicit, libcurl decides | backend policy | backend policy, one owner thread |
247269
| Installed interfaces | unchanged | new interface plus an adapter | unchanged, backend only |
248270
| Custom clients | must be re-entrant, undocumented | one method to implement | unaffected |
249271
| Native backends | awkward | natural | not applicable |
250272

251273
## What this needs decided
252274

253-
These are the questions a design cannot avoid. They are listed as decisions
254-
rather than answered here.
275+
Two lists rather than one. The first is what the discussion on #4448 has already
276+
settled, written down so a reviewer can disagree with a specific line instead of
277+
re-reading the thread. The second is what is genuinely still open.
278+
279+
**Settled, unless someone objects to a line here.** A backend neutral contract
280+
rather than a curl shaped one. Asynchronous submission of one attempt over a
281+
request that does not change after it is submitted. Exactly one settlement per
282+
export operation. Bounded resources, in bytes as well as in count. The existing
283+
interface kept working through an adapter rather than replaced. One owner thread
284+
per `CURLM`. The two existing options treated as curl compatibility controls
285+
rather than as requirements of the replacement.
286+
287+
**Open.** These are the questions a design cannot avoid, and they are listed
288+
rather than answered.
255289

256290
- [ ] Is a `Session` single use, reusable after completion, or a legacy adapter?
257291
- [ ] Does submitting a request snapshot it or take ownership of it?
@@ -275,6 +309,24 @@ while Bazel's `//ext:headers` still globs everything under `ext/include`. The
275309
two surfaces disagree today, and whichever direction is chosen has to say what
276310
happens to a Bazel consumer that includes a concrete header.
277311

312+
## What a replacement has to hold, whichever shape wins
313+
314+
These are requirements rather than questions, because no answer to the open
315+
decisions below makes any of them optional.
316+
317+
- Total bytes retained for attempts that have not settled is bounded. A count of
318+
requests does not bound it: 64 in flight at the 4 MB the reported workload was
319+
sending is 256 MB of request payload.
320+
- Compression working memory counts against that bound. Today the gzip step
321+
works in the caller's own buffer, so it is invisible to any request count.
322+
- A retry does not silently multiply retained payload. One export operation
323+
holds one serialized body however many attempts it makes.
324+
- An export operation and an attempt have separate identities. `ForceFlush`
325+
answers for operations accepted before its watermark, not for whichever
326+
attempts happen to be running.
327+
- Exactly one outcome is delivered per export operation, and it is the
328+
operation's, not the last attempt's.
329+
278330
## A recommendation
279331

280332
This part is an opinion and is meant to be argued with.

0 commit comments

Comments
 (0)