djkoloski / rust_serialization_benchmark

Benchmarks for rust serialization frameworks
527 stars 48 forks source link

This is approximately the same size as used by rkyv. #14

Closed ahmedcharles closed 3 years ago

djkoloski commented 3 years ago

Did some retimings of my own, increasing the scratch size buffer looks like it considerably increases serialize performance on some benches. Not sure what the "optimal" amount of scratch space is, since I don't really understand how it's being used. I was worried that too much would slow it down by requiring zeroing, but that doesn't seem to be the case. 1M was faster than 125k so I'll use that.

ahmedcharles commented 3 years ago

The rkyv benchmark allocated 10_000_000 u8's, which is technically, 1_250_000 u64's.

As for how it's used, it uses this buffer first before doing an initial allocation. The default allocation size is 1024 bytes and the default strategy is to double the block size with each allocation. There's still the potential for some improvement here, given that with this, the second allocation is still only 1024 and it could be 1_000_000 instead. Calling second_segment_words(1_000_000) on the ScratchSpaceHeapAllocator would do that.

djkoloski commented 3 years ago

Ah right, I thought I bumped that down to 1M since it doesn't really use more than that. Memory use isn't the point of these benchmarks, so I don't have any objections to giving capnp some more memory with second_segment_words as well.