Skip to content

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

Merged
gballet merged 2 commits into
blockblaz:masterfrom
omerfirmak:deserialize-fastpath
Jul 16, 2026
Merged

bulk-copy fast path for List(u8, _) deserialize#66
gballet merged 2 commits 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 Outdated
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?

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.

so the problem was really that there is an allocation site that is optional, and because the array list has its own allocator, it was really redundant. But if you look at it, the "fast path" is to just call the @memcopy function. Might as well save a lot of clutter and just do the copy directly here. LMK what you think

@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
@gballet
gballet merged commit d50b031 into blockblaz:master Jul 16, 2026
3 checks passed
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