about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2015-07-16 14:13:38 +0530
committerManish Goregaokar <manishsmail@gmail.com>2015-07-16 14:13:38 +0530
commit12899e73a08ba86ff65c0e64eea489203446b58d (patch)
tree53d2565a123c5e64c0c3ef67eb23e58b99d71909 /src/rustllvm/RustWrapper.cpp
parent1da1a46d563135233dec770abbe67fccc70bd434 (diff)
parent98f287240ff9518c1ea5519c5cd03dc2ba6d4452 (diff)
downloadrust-12899e73a08ba86ff65c0e64eea489203446b58d.tar.gz
rust-12899e73a08ba86ff65c0e64eea489203446b58d.zip
Rollup merge of #26950 - AlisdairO:memset, r=alexcrichton
 In general, it's undesirable to have read_to_end use a buffer with uninitialized memory, as that could lead to undefined behaviour in the event of a bad Read implementation.  Since we control the implementations of Read for Stdin and File, however, it should be okay for us to specialise them to improve performance.  This PR is to do that!

Adds some unsafe code to deal with creating the buffers.  Since the read_to_end function needed to be used from the io and fs crates, I moved it into a newly-created sys::common::io module.  Alternatively we could expose the new read_to_end functions to allow people to create their own read_to_end implementations for code they trust.

Benchmarks:

Read a 2.5MB file:
sys_common::io::tests::bench_init_file      ... bench:  27,473,317 ns/iter (+/- 2,490,767)
sys_common::io::tests::bench_uninit_file    ... bench:  25,611,793 ns/iter (+/- 2,137,387)

Read a buffer full of constant values
sys_common::io::tests::bench_uninitialized  ... bench:  12,877,645 ns/iter (+/- 931,025)
sys_common::io::tests::bench_zeroed         ... bench:  18,581,082 ns/iter (+/- 1,541,108)

So, approx a 7% speedup for file reading, which I think is worthwhile.
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions