Repository navigation
Replies: 3 comments
|
Your 15–19 ms stringify measurement is the right scale. Two things are true at once: the body is rebuilt for every attempt, and rebuilding it is not what costs 3.9 s. Rebuild: No prefix reuse: the Messages request carries the complete array every time. Prompt caching is provider-side; the client still uploads the whole body. There is no serialized-prefix cache in the host. Arithmetic: 10.9 MiB in 3.9 s is 2.9 MB/s, about 23 Mbit/s. That is an upload-shaped number. Your own benchmark puts JSON.stringify of a larger body near 1 GB/s, so a 10.9 MiB body is ~10–13 ms; even a rebuild 10× slower than that is ~100–200 ms, still a twentieth of the missing time, plus roughly 0.5 ms per 1.5 MB of image re-encode. That leaves the wire: TLS, 10.9 MiB of upload, and whatever the gateway does before the provider records the request. Measure it with an 11 MiB POST to the same If the upload is fast, the gap is on the host loop between The bili correlation you measured is proxy-side; a slow scan of turn N-1 there does not by itself prove the host loop was blocked. |
|
This is the correction I needed — accepted, and it changes the title's framing: the rebuild is real but it is not the 3.9 s. Your arithmetic is the decisive part: 10.9 MiB at 2.9 MB/s is upload-shaped, while Two things I can add from our side, both consistent with your reading:
If I can do one useful follow-up: I can time the client-side |
|
Yes, please measure the phase split — that settles it. Use the same route, model and roughly the same body as your 760-turn sample, on the version you reported, and record DNS / TLS / upload / first-byte per turn. Report p50/p90 for a handful of turns with the prompt cache warm, so the numbers are comparable with the 3.9 s figure. How to read the result: if upload time tracks the body size at roughly the observed 2.9 MB/s, the gap is the wire; if upload finishes quickly and first-byte carries the seconds, it is the provider/gateway queue and the body is incidental. The correction you accepted already changed the framing to "what the host does, not where the time goes"; the split would move it to a phase. Read-only on my side; I have no route to measure. Hand this to an AI assistant to build the timing script. If this answers it, marking it as the answer helps the next person chasing the same latency. |
Uh oh!
There was an error while loading. Please reload this page.
Observation, not a bug report. Using the harness with a long session (~6.8k messages, inbound request body ~10.9 MiB, prompt cache 100% hit), the time from
step/startto the model provider receiving the request is p50 ≈3.9 s (n=760, p90 ≈5.3 s) — on every turn, even when the cache is fully warm.Reading
@deepseek-ai/dsh-llm-deepseek@0.2.0-rc.2(host 0.2.0-rc.2, app 44.0.0), the request is rebuilt from scratch each turn:lib/index.js:2167→:1577(serialize):1599):1360(prepareRequestExtensions)JSON.stringifyof the whole ~10.9 MiB body:2188fetch(.../messages)Two questions:
dsh-session/lib/index.js:1554,deriveMessagesreturns a cached shared array), so in principle only the new tail needs serializing each turn.Buffer.from(version.data).toString("base64")runs over all historical images. Measured locally at ≈0.5 ms per 1.5 MB image, so a session with many screenshots pays O(total historical image bytes) per turn.What I explicitly ruled out:
JSON.stringifyitself. On the same machine, stringifying an equivalent 16.7 MiB / 6.8k-message body takes 15–19 ms (structuredClone22 ms) — two orders of magnitude below the 3.9 s. So the gap is in step 4 (rebuilding objects/images) and/or in writing 10.9 MiB downstream; I could not separate those two without a host-side profile.A second data point that may help profile it: bili (an HTTP proxy between host and provider) shows the host segment for turn N correlates with its own per-message scan time for turn N-1 at 0.97 — which would fit head-of-line blocking on its event loop, but that is proxy-side and unverified for the host.
Repro on my machine:
If the intended model is “rebuild is cheap and the time is elsewhere”, a rough expected-order-of-magnitude for step 4 per MiB of history would settle it.
All reactions