Skip to content

40% speedup with minor changes - #393

Open
infalmo wants to merge 2 commits into
3Hren:masterfrom
infalmo:perf
Open

infalmo wants to merge 2 commits into
3Hren:masterfrom
infalmo:perf

Conversation

@infalmo

@infalmo infalmo commented Nov 3, 2026

Copy link
Copy Markdown

No description provided.

Marker::to_u8 is a large match that LLVM was not inlining across the
crate boundary, so every marker write paid for an out-of-line call and
constant markers never folded. Forcing inlining cuts ~11% off
rmp_serde::to_vec on a struct-heavy payload.
FallibleWriter called Vec::try_reserve before every write, and most
writes are 1-9 bytes (markers, lengths, small ints). Plain
extend_from_slice already amortizes growth.

On a ~230 KB struct-heavy payload: to_vec 88us -> 63us,
to_vec_named 171us -> 99us. Output bytes are unchanged.

Tradeoff: allocation failure now aborts (standard Vec behaviour)
instead of surfacing as an io::ErrorKind::OutOfMemory error.
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.

1 participant