Skip to content

Conversation

@pull
Copy link

@pull pull bot commented Jan 25, 2026

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

### What

Pass a shared buffer to use as scratch space for encoding TaskStorage values.

Also reduce the size of the `CollectorEntryValue` enum (32->24 bytes), our use of a `SmallVec` was inefficient, instead we can store more inline data by doing it ourselves (22 bytes instead of 16)

### Why

Currently whenever we encode `TaskStorage` we allocate a new `TurboBincodeBuffer` (aka `SmallVec<[u8;16>`) only the very smallest TaskStorage values fit in that space, so we are always allocating and resizing a buffer for every `TaskStorage` we encode.   Using a shared scratch buffer we avoid resizes and allocations during encoding but now always need to copy our data out of the shared buffer.

This should reduce temporary allocations and buffer copies from the resizes in the common case. As well as ensure that the buffers we pass through to the collectors are exactly sized

I presized it as 4096 bytes since this covers ~98% of tasks we encode, and it is a nice magic number


A future optimization could be to accumulate all writes for every SnapshotShard in a single buffer that we pass down to the `Collector`.
@pull pull bot locked and limited conversation to collaborators Jan 25, 2026
@pull pull bot added the ⤵️ pull label Jan 25, 2026
@pull pull bot merged commit 1637d61 into code:canary Jan 25, 2026
4 of 7 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants