feat(io): add reader implementation for BufRead#196
feat(io): add reader implementation for BufRead#196kskalski wants to merge 3 commits intoanza-xyz:masterfrom
Conversation
75e8eec to
b4dd766
Compare
ca038d0 to
cfa77c8
Compare
|
The complexity and state management required for this implementation is a strong indication to me that we should actually deprecate With those removed, implementation can simply become: wincode/wincode/src/io/std_read_direct.rs Lines 1 to 27 in 00c64f1 There is a benchmark in this branch you can run: https://github.com/anza-xyz/wincode/blob/af1904c5d8f83c6c8fa44aa45fba09dae0ffd21f/wincode/benches/reader.rs The simple implementation without On x86, The simple solution, relative to the solution in this PR is:
The simple solution, relative to bincode is:
This isn't to say that we couldn't further optimize the solution proposed here to be closer to the performance of bincode or the solution without We only have two cases in My feeling is that we should merge the context system and deprecate
wincode/wincode/benches/reader.rs Lines 349 to 358 in af1904c And we'll only need to add one context implementation for |
|
I certainly agree that removing far-look-ahead functions is desirable and this PR I think demonstrated the reasons well. :) I will take a look at the benches too - thanks. Some quick thoughts:
|
I still think we should remove it. It's not strictly necessary functionality with the context system available.
After tinkering with benchmarks, it seems to me that
I still think |
Introduces
BufReadAdapter<R>inwincode::io::std_readmodule, a low-overhead wrapper over anystd::io::BufReadsource (e.g.BufReader<R>) implementingwincode::io::Reader.Mix of consuming and scoped borrowing operations supported by checking consume state on each operation and using one of:
peek_arrayandtake_scopedreturn a subslice directly with no allocation,copy_into_sliceusesreaddirectly into thedstbufferfill_bufis requested, bytes are assembled into anaux_buf: Vec<u8>. Subsequent operations can re-serve or extend from this buffer, but switch back to using internal reader once the bytes inaux_bufare consumed.