Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
csv: add SingleFieldWriter for progressive (== faster) serialization
This struct is an implementation detail that allows for progressive writing of a field into a writer's internal buffer, which means it can be used as a fmt::Write-r (i.e. with write!), and thus avoid more temporary allocations with integers and arbitrary user structures (if they serialize themselves through `Serializer::collect_seq`). This improves the benchmarks: name before.txt ns/iter after.txt ns/iter diff ns/iter diff % speedup count_game_serialize_owned_bytes 14,281,542 (154 MB/s) 13,410,592 (164 MB/s) -870,950 -6.10% x 1.06 count_game_serialize_owned_str 14,325,692 (153 MB/s) 13,572,390 (162 MB/s) -753,302 -5.26% x 1.06 count_mbta_serialize_owned_bytes 3,238,056 (192 MB/s) 2,645,566 (235 MB/s) -592,490 -18.30% x 1.22 count_mbta_serialize_owned_str 3,251,586 (191 MB/s) 2,648,981 (235 MB/s) -602,605 -18.53% x 1.23 count_nfl_serialize_owned_bytes 6,635,845 (205 MB/s) 5,045,906 (270 MB/s) -1,589,939 -23.96% x 1.32 count_nfl_serialize_owned_str 6,662,848 (204 MB/s) 5,341,465 (255 MB/s) -1,321,383 -19.83% x 1.25 count_pop_serialize_owned_bytes 10,289,241 (92 MB/s) 7,750,243 (123 MB/s) -2,538,998 -24.68% x 1.33 count_pop_serialize_owned_str 10,146,352 (94 MB/s) 7,587,681 (125 MB/s) -2,558,671 -25.22% x 1.34 Notably the improvement is smaller for the 'game' benchmarks, where the serialized values are mostly strings, and much larger for the others which have mostly integers/floats.
- Loading branch information