36a017ac9e151dbe215033d2e48efee49d9bbe16
3
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
95fa76126d |
workbuddy 0.1.44: a huge chat's ids are hashed in pieces, and it is read once on every path (#461)
0.1.42 brought jihuayu's 45 MiB repro from 7 parses a request to 2, and
0.1.43 keeps that: one full parse and one full stringify a request. What
was left of the peak was attendChat: the conversation and turn ids were
made from template strings holding the whole user message (`first:${sig}`,
`u1:${sig}`, `${conv}|${turn}`, then `${SALT}|kind|${key}`), each a fresh
45 MB string, ~160 MiB of peak a request. The keys are now lists of
pieces fed to one sha256 each, whole (Bun hashes a one-byte string in
place; 1 MiB slices cost a copy and were worse), with a high surrogate
split between pieces held for the next one, so every id is the hash of
the same string as before.
Also read once on paths the repro doesn't take:
- "Free models only" parsed the body again for its model; it reads the
chat prepared already parsed.
- A model known to want a reply after tools (11153) had the body parsed
and stringified again on every request; the reply goes into the one
parsed chat before the one stringify.
- The prepared result no longer holds the parsed tree past the send.
Every byte WorkBuddy sees is unchanged: sent.test.mjs runs 12 chats
(OpenCode tools, default effort, developer turn, after-tools refusal and
known, system refusal and known, both, Messages, bytes, not JSON),
switch off and on, and holds the gunzipped body's sha256, url, encoding
and which requests share an id to testdata/sent-0.1.43.json, made by
running the same harness on npm's 0.1.43 index.mjs (sha 9213db6d...).
Run on mote (Bun 1.4.2), the issue's benchmark.mjs as written but for
the import, 45.3 MiB body, 4 requests, concurrency 1, /usr/bin/time -l,
3 runs each:
direct (no plugin) 336 MiB
0.1.41 981-1117 MiB, 28 parses (1087.5 MiB), 24 stringifies
0.1.43 717-760 MiB, 8 parses (181.3 MiB), 20 stringifies
0.1.44 583 MiB all 3 runs, same counts, ~370-420 ms wall
(0.1.43 ~400-530 ms)
One request: direct 134, 0.1.41 569, 0.1.43 390, 0.1.44 275 MiB (with
id derivation stubbed out entirely: 229).
- HOME=$(mktemp -d) bun test in packages/workbuddy at this head:
201 pass, 0 fail. bun scripts/check.mjs workbuddy: ok.
- Broken by hand, each red: free-only parsing again -> the free-only
parse-count test; reply after tools put in by re-parsing -> the
after-tools parse-count test; no surrogate hold -> the idFor pieces
test; the reply put in before the system move -> sent.test.mjs.
gzip was measured too: Buffer.from before gzipSync made no difference
to the peak, so it is unchanged.
Not tried: a live WorkBuddy request; the reporter's Linux and Bun
1.4.4 (mote has 1.4.2); concurrency 4; a huge body that isn't ASCII
(Bun keeps it two-byte, so hashing it may copy); a huge Messages body
(its own path, not changed here).
|
||
|
|
f4d48ac3ee |
workbuddy 0.1.43: a chat names the model's default effort as WorkBuddy's client does, and goes gzipped
troilus1011 on X: WorkBuddy's DeepSeek in OpenCode through magpie thought at low and high, never at the default. OpenCode's default variant names no reasoning_effort, and WorkBuddy doesn't think without one: measured on www.workbuddy.ai with 0.1.42, deepseek-v4.1-flash gave 0 reasoning tokens with no effort (2 of 2), 0 at none, 16/37 at low, 34/56 at high. WorkBuddy's own client (CLI 2.165.0 in WorkBuddy 5.9.3, configureThinkingSettings) sends the session's effort, else the reasoningEffort setting, else the model's reasoning.defaultEffort from /v3/config, which is "high" for this model on both builds. A chat that names no effort now gets the model's own defaultEffort when its listed levels hold it, read from the same cached /v3/config list (one read per minute; a failed read leaves the chat as it came and is not retried on every chat). An effort the client names, none included, is untouched and the list isn't read for it. Models with no reasoning config get nothing. runmiNeverstop on X: 2.89 GB up to copilot.tencent.com through magpie. WorkBuddy's client gzips a model request's body (GzipRequestProcessor, on with productFeatures.RequestBodyGzip, true in both builds' product.json and not turned off by the remote config); the plugin sent it as plain JSON. Agent chat JSON (the whole history each turn, tool schemas) compresses several-fold, so the upload was several times what the official client sends for the same turns. A chat-completions body now goes gzipped with Content-Encoding: gzip on both builds; unanswered() weighs the gzipped size against the front door's 2 MiB. Claude's Messages route goes as it came (not tried gzipped live). Run (on mote, HOME=$(mktemp -d) bun test in packages/workbuddy): 197 pass, 0 fail. bun scripts/check.mjs: exit 0. Fakes that parse the sent body gunzip it (testdata/unz.mjs); reset.test.mjs's 2 MiB bodies are random base64 so they stay over 2 MiB on the wire. Live (www.workbuddy.ai, a real account in a sandbox HOME): with 0.1.43 the default sent reasoning_effort high gzipped and thought (34 and 51 reasoning tokens), none stayed 0, low and high as before, all 200. A gzipped chat answered 200 the same as a plain one. Broken by hand: origin/main's index.mjs with the new default-effort.test.mjs: 5 of 8 red (default effort, failed-read reuse, both gzip tests, defaultEffortOf); the 3 that pass guard what must not change (named efforts, models without a default, Messages). Not tried: a live chat on the China build (copilot.tencent.com answered 401 to every token available here, its /v3/config read fine); Messages gzipped; the reporters' own OpenCode sessions end to end. |
||
|
|
f2b0dacdb7 |
workbuddy 0.1.42: a chat is parsed once on its way, and goes as it came when nothing changed (#461)
jihuayu measured a 45 MiB chat going through 0.1.41's fetch: each step (withSystem, fitted, normalizeToolChoice, attend, the model, systemKey) parsed the whole body again, 6 parses a request, and normalizeToolChoice wrote it out whole even for an unchanged "auto". Bun's RSS reached 618-751 MiB for 4 serial requests where passing the body through took 270. prepared parses a request once. Each step makes its own change to that one object, in the same order (systemOn, fitTools, toolChoiceOn; unsignedOn for Messages). attend, the model and the system key read the same object, and a refused system prompt moves on it (systemAsUserOn). The body is written out once, only when a step changed it. The parsed chat is let go before the request is sent. A body a step throws on goes through the steps one by one, as before. The string-level helpers stay as wrappers. What was run, on this tree: - mote, the reporter's benchmark (no network, fetch stubbed, 4 x 45.3 MiB, peak RSS sampled every 5ms): 0.1.41 7 parses/request, 1087.5 MiB parsed, peak RSS 1096 / 979 MiB. This change: 2 parses/request (the request and the stub's SSE reply), 181.3 MiB parsed, peak 682 / 680 MiB. The bodies sent have the same SHA-256 in both. - HOME=$(mktemp -d) bun test packages/workbuddy on mote: 189 pass, 0 fail. bun scripts/check.mjs workbuddy: ok. - oneparse.test.mjs (new): 17 chat shapes, invalid JSON and bytes come out the same as the steps one by one made them, with the same tool names; an unchanged chat goes byte for byte; the loader parses a 2 MiB chat once. Broken by hand: every request sent through the step-by-step fallback, the loader test FAILs (5 parses, want 1). An unchanged "auto" counted as a change, the byte-for-byte test FAILs. - Real account (WorkBuddy AI, free-only on, sandbox HOME, this Mac): deepseek-v4.1-flash, a 373-byte chat and a 205,595-byte chat with a developer message, max_completion_tokens and a dotted tool name, through 0.1.41 and this change: 200 "OK" on all four; no sign-in refreshed. npm has 0.1.41, so 0.1.42 is free. Reported-by: jihuayu |