rust/src/libstd/io
kennytm 9b090a0261 Rollup merge of #46050 - sunfishcode:read_to_end, r=sfackler
Optimize `read_to_end`.

This patch makes `read_to_end` use Vec's memory-growth pattern rather
than using a custom pattern.

This has some interesting effects:

 - If memory is reserved up front, `read_to_end` can be faster, as it
   starts reading at the buffer size, rather than always starting at 32
   bytes. This speeds up file reading by 2x in one of my use cases.

 - It can reduce the number of syscalls when reading large files.
   Previously, `read_to_end` would settle into a sequence of 8192-byte
   reads. With this patch, the read size follows Vec's allocation
   pattern. For example, on a 16MiB file, it can do 21 read syscalls
   instead of 2057. In simple benchmarks of large files though, overall
   speed is still dominated by the actual I/O.

 - A downside is that Read implementations that don't implement
   `initializer()` may see increased memory zeroing overhead.

I benchmarked this on a variety of data sizes, with and without
preallocated buffers. Most benchmarks see no difference, but reading
a small/medium file with a pre-allocated buffer is faster.
2017-11-22 01:12:58 +08:00
..
buffered.rs Implement is_empty() for BufReader 2017-10-18 14:27:33 -04:00
cursor.rs Fix typo in doc 2017-08-17 00:46:30 +02:00
error.rs use field init shorthand EVERYWHERE 2017-08-15 15:29:17 -07:00
impls.rs Add read_to_end implementation to &[u8]'s Read impl 2017-10-07 22:19:51 +02:00
lazy.rs use field init shorthand EVERYWHERE 2017-08-15 15:29:17 -07:00
mod.rs Rollup merge of #46050 - sunfishcode:read_to_end, r=sfackler 2017-11-22 01:12:58 +08:00
prelude.rs std: Remove deprecated functionality from 1.5 2015-12-10 11:47:55 -08:00
stdio.rs std: Change how EBADF is handled in sys 2017-11-08 20:41:17 -08:00
util.rs Rollup merge of #44712 - oconnor663:copy_test, r=GuillaumeGomez 2017-09-23 00:29:13 -04:00