refactor(stream): Bytes is Buffer<UInt8> #383
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/300-buffer-list-bytes"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #300
Second half of #300 (the first half,
feat(collections): Buffer is a List, merged as #382):public type Bytes = Buffer<UInt8>, the sweep ofList<UInt8>andArrayList<UInt8>that meet aBytes, the docs.All numbers below are from forge CI on head
3bde36d0, run #1186 (tier A, tier B, bootstrap, gates, pdisc all green).Raised
.allocationsbudgetstests/conformance/standard-streamsLinesAccumulator.addinstd/stream/src/bytes.trb:165-166(pending[0..at],pending[(at + 1)..]): the program reads 3 lines from stdin, so 6 slices of aBytes, each now aBuffer.slicewith a storage block of its own instead of a range sharing the whole's storagetests/conformance/list-slice-overridewindow(bytes, ...)/bytes.part(...), thebytes[from..to]slices of aBytesthe program pins; same reasonAttribution is by reading the two programs and the slice sites on their path, not by a per-site allocation count: CI reports the total of
allocated blocks at exitonly. No other existing budget moves. #300 asks for each raised budget to be listed with its site, which this is; aBuffer-aware call site inLinesAccumulatorcould take it back if the reviewer wants that.New, not raised:
tests/conformance/buffer-field-derived.allocations= 44 (see below).Performance (tier B, same run, fastest of 9)
bytes-pass(Buffer<UInt8>) 0.038392 s vsbytes-pass-list(List<UInt8>) 0.044122 s: ratio 0.870, bound 1.10.0f63b4ac0.521126 s, this head 0.526047 s: 1.009, bound 1.10.Both pass, nothing to fix or split. Worth knowing: in the one-shot split of
bytes-pass, the 1000 slices take 0.00433 s asBuffer<UInt8>against 0.00046 s asList<UInt8>(the copy; the fill and the CRC loop make it up), which is the "a range of aBytesis a copy" of #300 Notes.The compiler change (
compiler/src/ir)#300 assumed no
compiler/src/irchange:Bufferas aListwould go through the witness tables likeRingList. That held for the trait itself, but not for three places where aBufferis the IR type of anArrayListand yet has members of its own:ir/instances.trb: aListdefault (appendAll, ...) instantiated for aBuffer<UInt8>and for anArrayList<UInt8>was one instance, so the body of whichever was asked for first served both.Bufferarguments now count like literal types (needsOwnInstance): an instance of their own.ir/witness.trb(boxedReceiverOf): the derivedequalsof a type with aBufferfield (Digest,Result<Bytes, E>) boxed the receiver but notother, whichEqualsofListalso takes as the trait. EverySelf-typed parameter is boxed now; the wrapper is keyed perBufferas well.ir/lower/collection.trb:const b: Bytes = [1, 2]is aCollectionLiteral.FromIterate;lowerDirectBufferwrites the items into theBufferitself (same storage asArrayList) instead ofBuffer.fromof a fresh list, which would copy into a second block. An empty literal no longer asks for theappendwrapper it never calls.Seed: no two-commit rule applies. No syntax change, no new native, no driver flag, no renamed std name; the compiler already looked
Bufferup by name (tableNameOfinir/witness.trb, merged with #382). Evidence: thebootstrap (linux-x64)job built this head's compiler with the published seedde7812a3c040, which is older than #382, and the fixpoint holds (steps 2 and 3 emitted the same C);every host emits the same Cis green. Tier B ran (it was needed because of these three files), and is green.New conformance program
tests/conformance/buffer-field-derivedpins (2) above:==,hashandshowover a type with aBytesfield, anArrayList<UInt8>field and aResult<Bytes, String>field, equal and unequal, plus[first, other].contains(same).Task
Reviewer findings 1-3 of argus on
3bde36d0are answered above by this description; no code changed, so the head stays3bde36d0.c366014a992fee4fad422fee4fad426a617b5bfa6a617b5bfa8bbf6450c18bbf6450c172f06d73f572f06d73f518b3b6588418b3b65884e4205afaece4205afaec3bde36d0bdChanges requested on
3bde36d. CI is green (tier A and B, pdisc, gates) and the sweep itself looks consistent; what is missing is the evidence #300 asks for in the PR description..allocationsbudget in the description with old/new number and the causing slice site. The diff raisestests/conformance/standard-streams.allocations207 -> 212 andtests/conformance/list-slice-override.allocations164 -> 165 and addsbuffer-field-derived.allocations(44). The body lists none of them and does not say whichBytesslice site causes the +5 / +1.bytes-passwithin 10 % ofbytes-pass-list(fastest of 9, same run) and the 4 MiB deflate+inflate round trip no more than 10 % slower than at commit 1, both in the description. If either fails, name the site and fix or split a follow-up, as the issue says.compiler/src/irand tier B is not needed. This diff changescompiler/src/ir/instances.trb,ir/lower/collection.trbandir/witness.trb(own instance forBufferarguments, directBufferliteral lowering, boxing ofSelf-typed parameters). It may well be necessary, and the code comments explain the how, but the description must say it, say why the issue's assumption no longer holds, and confirm no seed or two-commit rule applies (CLAUDE.md, "Seed and breaking changes").Non-blocking:
buffer-field-derived; one line on what it pins would help.Please update the PR description with 1-3 and request review again; no code change needed unless a performance number fails.
Buffer<Item>joins theListfamily andBytesbecomesBuffer<UInt8>#300Addressed review 308 (argus,
3bde36d0): description updated with the raised allocation budgets and their sites, the two measured tier B numbers (bytes-pass 0.870, round trip 1.009, both within the 1.10 bound), the compiler change with the seed statement, and the new conformance program. No code change; head stays3bde36d0. Re-requesting review.Approved on
3bde36d. Earlier findings 1-3 are answered in the description (checked against the diff):buffer-field-derivedconformance program pins the derived==/hash/showoverBytesfields.buffer-field-derivedis new; no other budget moves; no existing.expectedchanged.ir/instances,ir/witness,ir/lower/collection): stated and justified, seed rule addressed (fixpoint holds with the older seed, all hosts emit the same C); logic reads correct.Non-blocking: none.