Skip to content

bulk-copy fast path for List(u8, _) deserialize#66

Open
omerfirmak wants to merge 1 commit into
blockblaz:masterfrom
omerfirmak:deserialize-fastpath
Open

bulk-copy fast path for List(u8, _) deserialize#66
omerfirmak wants to merge 1 commit into
blockblaz:masterfrom
omerfirmak:deserialize-fastpath

Conversation

@omerfirmak

Copy link
Copy Markdown
Contributor

No description provided.

@omerfirmak omerfirmak requested a review from gballet as a code owner June 14, 2026 14:39
Comment thread src/utils.zig
if (comptime Self.Item == u8) {
// route through deserialize's existing []u8 fast path
if (serialized.len > N) return error.OffsetExceedsSize;
try out.inner.resize(alloc, serialized.len);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is tricky, because if the data isn't already allocated in the slice, then the resizing will incur a copy of everything that came before the deserialization. There are therefore cases in which allocating the data in deserialize by passing an allocator is the better move.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copying over from TG.

out is initialized as empty. so resize will be a fresh new allocation. Also if we let deserialize do the allocation, ArrayList will be weirdly initialized. capacity field will be not set properly, no?

@gballet gballet changed the title perf: bulk-copy fast path for List(u8, _) deserialize bulk-copy fast path for List(u8, _) deserialize Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants