Geethapranay1 commented on PR #3580: URL: https://github.com/apache/fory/pull/3580#issuecomment-4276090868
@chaokunyang as i gone through some internals of rust compiler, the existing rust path uses Vec::extend_from_slice which llvm inlines pretty aggressively and the capacity check becomes a single well-predicted branch, so pre-reserving only saves ~1 predicted branch per field. With 8 fields that's maybe 3-4ns on a 115ns op. and when compared with the C++ buffer.h and the difference is clear. C++ uses a raw data_ pointer with separate writer_index_ and grow() bt rust Vec wraps len/capacity/ptr into one abstraction that llvm already optimizes well, so there's less room to gain. so to get real gains I think we'd need to either: replace the rust Writer's Vec<u8> with a raw pointer + writer_index layout like C++ buffer.h or find a different view on increasing gains should i want to go through option 1 or close this? -- 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]
