Serde using 19.8KB (file size) to deserialise 29 f64s - are any optimisations possible
⚓ Rust 📅 2025-10-24 👤 surdeus 👁️ 2I have a struct which consists of 29 f64 fields, all but 2 of which are Optional. Serde works great, but it produces a lot of code, all up 19.5KB for this struct. Is that expected? It seems like a lot for what is a very simple and repetitive struct.
I made a manual deserialiser based on the example. And while it doesn't quite have all the same error protections (I'm not doing anything if the two non-optional fields are missing, leaving them as default values instead) it's a lot smaller, only 5.9KB.
My manual deserialiser (click for more details)I'm guessing it can't automatically recognise and optimise that all the fields are the same type? Would it be reasonable to have better optimisations for structs like this in the future, or does this really necessitate a manual deserialiser?
20KB filesize is normally nothing to care much about, but I'm compiling to WASM and there are a lot of large Serde functions, this just was the most straightforward to try a manual approach with.
2 posts - 2 participants
🏷️ Rust_feed