Box to save memory
13 points by wezm
13 points by wezm
Clippy has a large_enum_variant which flags enums with a large difference between cases, sadly it only looks at the definition so does not flag generic structs (like Option) at use site.
Although to be fair that would probably be annoying in cases where the option (/ result) is the top-level type, so should probably be restricted to within other structs.
Anyway https://github.com/rust-lang/clippy/issues/9983
An other minor thing to consider is the use of Box<str> and Box<[T]> in stead of String and Vec, they also trade CPU for memory (on deser) as they go through the mutable type, but the conversion to a box will trim the backing buffer and drop the capacity (so reduces the stack size from 24 to 16 bytes).
Very neat little insight.
Interesting how this is about AWS model definition stuff... I'm not 1000% sure it's the same problem but at work we have very annoying struggles due to boto3 pulling in a bunch of model definition stuff leading to client session objects being huge. I'm hopeful that we can get a bit of pressure to make this stuff a bit more compact because I'm not a superfan of needing this much memory to push some item to s3.