about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2016-12-03Add examples for exit functionGuillaume Gomez-0/+8
2016-12-03Rollup merge of #38141 - GuillaumeGomez:component_doc, r=frewsxcvCorey Farwell-1/+11
Add Component examples r? @frewsxcv
2016-12-03Rollup merge of #38077 - GuillaumeGomez:ipaddr_doc, r=frewsxcvCorey Farwell-0/+88
Add missing examples for IpAddr enum r? @frewsxcv
2016-12-03Rollup merge of #38020 - GuillaumeGomez:udp-socket-doc, r=frewsxcvCorey Farwell-11/+215
Add part of missing UdpSocket's urls and examples r? @frewsxcv
2016-12-03Rollup merge of #37859 - GuillaumeGomez:net_examples, r=nagisaCorey Farwell-0/+158
Add missing examples for Ipv6Addr r? @steveklabnik cc @frewsxcv
2016-12-03fix objc ABI in std::env::argsMathieu Poumeyrol-2/+15
2016-12-02Add Component examplesGuillaume Gomez-1/+11
2016-12-02Auto merge of #37936 - tedsta:fuchsia_std_process, r=alexcrichtonbors-238/+689
Fuchsia support for std::process via liblaunchpad. Now we can launch processes on Fuchsia via the Rust standard library! ... Mostly. Right now, ~5% of the time, reading the stdout/stderr off the pipes will fail. Some Magenta kernel people think it's probably a bug in Magenta's pipes. I wrote a unit test that demonstrates the issue in C, which I was told will expedite a fix. https://fuchsia-review.googlesource.com/#/c/15628/ Hopefully this can get merged once the issue is fixed :) @raphlinus
2016-12-01std::process fuchsia support cleanupTheodore DeRego-34/+26
2016-12-01Auto merge of #38018 - sourcefrog:doc, r=alexcrichtonbors-0/+8
Document that Process::command will search the PATH
2016-11-30Cleanup envJeremy Soller-4/+5
2016-12-01Auto merge of #37573 - ruuda:faster-cursor, r=alexcrichtonbors-2/+20
Add small-copy optimization for copy_from_slice ## Summary During benchmarking, I found that one of my programs spent between 5 and 10 percent of the time doing memmoves. Ultimately I tracked these down to single-byte slices being copied with a memcopy. Doing a manual copy if the slice contains only one element can speed things up significantly. For my program, this reduced the running time by 20%. ## Background I am optimizing a program that relies heavily on reading a single byte at a time. To avoid IO overhead, I read all data into a vector once, and then I use a `Cursor` around that vector to read from. During profiling, I noticed that `__memmove_avx_unaligned_erms` was hot, taking up 7.3% of the running time. It turns out that these were caused by calls to `Cursor::read()`, which calls `<&[u8] as Read>::read()`, which calls `&[T]::copy_from_slice()`, which calls `ptr::copy_nonoverlapping()`. This one is implemented as a memcopy. Copying a single byte with a memcopy is very wasteful, because (at least on my platform) it involves calling `memcpy` in libc. This is an indirect call when libc is linked dynamically, and furthermore `memcpy` is optimized for copying large amounts of data at the cost of a bit of overhead for small copies. ## Benchmarks Before I made this change, `perf` reported the following for my program. I only included the relevant functions, and how they rank. (This is on a different machine than where I ran the original benchmarks. It has an older CPU, so `__memmove_sse2_unaligned_erms` is called instead of `__memmove_avx_unaligned_erms`.) ``` #3 5.47% bench_decode libc-2.24.so [.] __memmove_sse2_unaligned_erms #5 1.67% bench_decode libc-2.24.so [.] memcpy@GLIBC_2.2.5 #6 1.51% bench_decode bench_decode [.] memcpy@plt ``` `memcpy` is eating up 8.65% of the total running time, and the overhead of dispatching to a specialized fast copy function (`memcpy@GLIBC` showing up) is clearly visible. The price of dynamic linking (`memcpy@plt` showing up) is visible too. After this change, this is what `perf` reports: ``` #5 0.33% bench_decode libc-2.24.so [.] __memmove_sse2_unaligned_erms #14 0.01% bench_decode libc-2.24.so [.] memcpy@GLIBC_2.2.5 ``` Now only 0.34% of the running time is spent on memcopies. The dynamic linking overhead is not significant at all any more. To add some more data, my program generates timing results for the operation in its main loop. These are the timings before and after the change: | Time before | Time after | After/Before | |---------------|---------------|--------------| | 29.8 ± 0.8 ns | 23.6 ± 0.5 ns | 0.79 ± 0.03 | The time is basically the total running time divided by a constant; the actual numbers are not important. This change reduced the total running time by 21% (much more than the original 9% spent on memmoves, likely because the CPU is stalling a lot less because data dependencies are more transparent). Of course YMMV and for most programs this will not matter at all. But when it does, the gains can be significant! ## Alternatives * At first I implemented this in `io::Cursor`. I moved it to `&[T]::copy_from_slice()` instead, but this might be too intrusive, especially because it applies to all `T`, not just `u8`. To restrict this to `io::Read`, `<&[u8] as Read>::read()` is probably the best place. * I tried copying bytes in a loop up to 64 or 8 bytes before calling `Read::read`, but both resulted in about a 20% slowdown instead of speedup.
2016-11-30just add one method named creation_flags, fix the tidy errorTed Mielczarek-19/+7
2016-11-30Document that Process::command will search the PATHMartin Pool-0/+8
2016-11-30Add std::os::windows::process::CommandExt, with set_creation_flags and ↵Ted Mielczarek-2/+96
add_creation_flags methods. Fixes #37827 This adds a CommandExt trait for Windows along with an implementation of it for std::process::Command with methods to set the process creation flags that are passed to CreateProcess.
2016-11-30Removed Option<ExitStatus> member from fuchsia Process struct. Destroy ↵Theodore DeRego-32/+45
launchpads and close handles in Drop impls rather than manually
2016-11-30Update the bootstrap compilerAlex Crichton-2/+0
Now that we've got a beta build, let's use it!
2016-11-30Move small-copy optimization into <&[u8] as Read>Ruud van Asseldonk-2/+20
Based on the discussion in https://github.com/rust-lang/rust/pull/37573, it is likely better to keep this limited to std::io, instead of modifying a function which users expect to be a memcpy.
2016-11-30Move small-copy optimization into copy_from_sliceRuud van Asseldonk-15/+3
Ultimately copy_from_slice is being a bottleneck, not io::Cursor::read. It might be worthwhile to move the check here, so more places can benefit from it.
2016-11-30Add small-copy optimization for io::CursorRuud van Asseldonk-3/+15
During benchmarking, I found that one of my programs spent between 5 and 10 percent of the time doing memmoves. Ultimately I tracked these down to single-byte slices being copied with a memcopy in io::Cursor::read(). Doing a manual copy if only one byte is requested can speed things up significantly. For my program, this reduced the running time by 20%. Why special-case only a single byte, and not a "small" slice in general? I tried doing this for slices of at most 64 bytes and of at most 8 bytes. In both cases my test program was significantly slower.
2016-11-30Rename 'librustc_unicode' crate to 'libstd_unicode'.Corey Farwell-4/+4
Fixes #26554.
2016-11-29Add missing examples for IpAddr enumGuillaume Gomez-0/+88
2016-11-28Commit to fix make tidyJeremy Soller-44/+157
2016-11-28Remove file path from std::fs::FileJeremy Soller-14/+2
2016-11-28Move stdout/err flush into sysJeremy Soller-9/+25
2016-11-28Switch to using Prefix::VerbatimJeremy Soller-6/+4
2016-11-28Switch to using syscall crate directly - without importJeremy Soller-188/+171
2016-11-28std: Fix partial writes in LineWriterAlex Crichton-13/+86
Previously the `LineWriter` could successfully write some bytes but then fail to report that it has done so. Additionally, an erroneous flush after a successful write was permanently ignored. This commit fixes these two issues by (a) maintaining a `need_flush` flag to indicate whether a flush should be the first operation in `LineWriter::write` and (b) avoiding returning an error once some bytes have been successfully written. Closes #37807
2016-11-27Auto merge of #38019 - sourcefrog:doc-separator, r=frewsxcvbors-1/+3
Clearer description of std::path::MAIN_SEPARATOR.
2016-11-27Auto merge of #38022 - arthurprs:micro-opt-hm, r=blussbors-18/+21
Use displacement instead of initial bucket in HashMap code Use displacement instead of initial bucket in HashMap code. It makes the code a bit cleaner and also saves a few instructions (handy since it'll be using some to do some sort of adaptive behavior soon).
2016-11-27Use displacement instead of initial bucket in HashMap codearthurprs-18/+21
2016-11-27Auto merge of #37983 - GuillaumeGomez:tcp_listener_doc, r=frewsxcvbors-3/+118
Add examples for TcpListener struct r? @frewsxcv
2016-11-27Add examples for TcpListener structGuillaume Gomez-3/+118
2016-11-26Auto merge of #38004 - GuillaumeGomez:tcp_stream_doc, r=frewsxcvbors-8/+185
Add missing urls and examples to TcpStream r? @frewsxcv
2016-11-26Add part of missing UdpSocket's urls and examplesGuillaume Gomez-11/+215
2016-11-26Clearer description of std::path::MAIN_SEPARATOR.Martin Pool-1/+3
2016-11-26Rollup merge of #38010 - frewsxcv:lock-creations, r=GuillaumeGomezSeo Sanghyeon-1/+22
Document how lock 'guard' structures are created.
2016-11-26Rollup merge of #38001 - vickenty:patch-1, r=steveklabnikSeo Sanghyeon-2/+2
Follow our own recommendations in the examples Remove exclamation marks from the the example error descriptions: > The description [...] should not contain newlines or sentence-ending punctuation
2016-11-26Rollup merge of #37985 - frewsxcv:completed-fixme, r=petrochenkovSeo Sanghyeon-1/+1
Remove completed FIXME. https://github.com/rust-lang/rust/issues/30530
2016-11-26Rollup merge of #37978 - fkjogu:master, r=sfacklerSeo Sanghyeon-5/+5
Define `bound` argument in std::sync::mpsc::sync_channel in the documentation The `bound` argument in `std::sync::mpsc::sync:channel(bound: usize)` was not defined in the documentation.
2016-11-26Rollup merge of #37962 - GuillaumeGomez:socket-v6, r=frewsxcvSeo Sanghyeon-0/+84
Add missing examples to SocketAddrV6 r? @steveklabnik cc @frewsxcv
2016-11-25Fix canonicalizeJeremy Soller-3/+2
2016-11-25Use O_DIRECTORYJeremy Soller-9/+12
2016-11-25Document how the `MutexGuard` structure is created.Corey Farwell-1/+8
Also, end sentence with a period.
2016-11-25Document how the `RwLockWriteGuard` structure is created.Corey Farwell-0/+7
2016-11-25Document how the `RwLockReadGuard` structure is created.Corey Farwell-0/+7
2016-11-25Add missing urls and examples to TcpStreamGuillaume Gomez-8/+185
2016-11-25Follow our own recommendations in the examplesVickenty Fesunov-2/+2
Remove exclamation marks from the the example error descriptions: > The description [...] should not contain newlines or sentence-ending punctuation
2016-11-24Remove completed FIXME.Corey Farwell-1/+1
https://github.com/rust-lang/rust/issues/30530
2016-11-24Define `bound` argument in std::sync::mpsc::sync_channelfkjogu-5/+5
The `bound` argument in `std::sync::mpsc::sync:channel(bound: usize)` was not defined in the documentation.