Geethapranay1 commented on issue #3569: URL: https://github.com/apache/fory/issues/3569#issuecomment-4248810213
hi @chaokunyang I tried optimizing struct field serialization by reserving buffer space upfront. At proc macro expansion time, I compute a rough max size for primitive fields. For example, varint32 as 5 bytes, f64 as 8, bool as 1, etc. Then before writing anything, I call context.writer.reserve(total) once. For fixed size types like bool, i16, f32, f64, I switched to write_*_unchecked() to avoid repeated capacity checks. For variable length ones like varint32, varint64, tagged_u64, I kept the checked writes since their size depends on values. This is similar to how struct_serializer.h does it in C++. Precompute size, grow buffer, then write. Wire fmt stays unchanged and tests are passing. is this makes sense? can i do pr? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
