callHead and codexCallLine asked of every rollout line, with a
bytes.Contains each, whether it held "type":"user_message",
"role":"user", "type":"function_call_output" and nine more: up to twelve
passes over the line in each, a line of megabytes of tool output
included. A CPU profile of a cold usage read on Windows (20,807 Codex
rollouts, 44GB, magpie web in a sandbox home on the Windows box) put 37%
of its 270s of samples in that bytes.Contains (indexbody).
cxMarksOf reads them all in one pass: it walks each `":"` that ends a key
(in a JSON string the quotes are escaped, so never one inside a string),
and records the "type" values and the user's role it finds. It finds
what each value's own pass found: the same line, anywhere in it.
Run:
- TestCxMarksAsContains: twelve lines (long escaped strings holding the
values, a nested value past a long string, "subtype"/"xtype" keys,
"role":"users", empty and cut lines) give the same marks as a
bytes.Contains of each. Red when the role is not recorded (3 lines).
- Every line of the owner's real ~/.codex/sessions, read only: 619
files, 20,059 lines, 4.3GB, 0 lines whose marks differ.
- BenchmarkCxMarks, a 1MB exec_command_end line: 0.36ms a line, from
11.2ms.
- Windows box, cold (.cache\magpie removed), magpie web, 3 rounds each,
alternating, origin/main 552e974f2 against this change:
CPU in the first 70s: 214.3 / 214.1 / 216.0s -> 127.2 / 123.4 / 124.5s
peak working set: 318 / 297 / 311MB -> 344 / 342 / 325MB
The peak is ~25MB higher: the same work is done in less time. Not
changed here.
- go test ./internal/sessions/ ./internal/usage/ ./internal/gui/: ok.
gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui
./internal/sessions/ clean.
Not changed: codexBody (codex.go) asks the same values with
bytes.Contains, but only of lines codexHead let through by their head
(1% of the profile's bytes.Contains was there, under 1s).