summaryrefslogtreecommitdiffstats
path: root/tokio
AgeCommit message (Collapse)Author
2020-07-24chore: complete CI migration to Github Actions (#2680)Carl Lerche
2020-07-24net: ensure that unix sockets have both split and into_split (#2687)Alice Ryhl
The documentation build failed with errors such as error: `[read]` public documentation for `take` links to a private item --> tokio/src/io/util/async_read_ext.rs:1078:9 | 1078 | / /// Creates an adaptor which reads at most `limit` bytes from it. 1079 | | /// 1080 | | /// This function returns a new instance of `AsyncRead` which will read 1081 | | /// at most `limit` bytes, after which it will always return EOF ... | 1103 | | /// } 1104 | | /// ``` | |_______________^ | note: the lint level is defined here --> tokio/src/lib.rs:13:9 | 13 | #![deny(intra_doc_link_resolution_failure)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: the link appears in this line: bytes read and future calls to [`read()`][read] may succeed.
2020-07-24doc: feature flags in README (#2682)Blas Rodriguez Irizar
2020-07-23net: introduce split on UnixDatagram (#2557)cssivision
2020-07-23io: always re-export std::io (#2606)Taiki Endo
2020-07-22doc: fix links to new website (#2674)Alice Ryhl
2020-07-22io: add `io::duplex()` as bidirectional reader/writer (#2661)Sean McArthur
`duplex` returns a pair of connected `DuplexStream`s. `DuplexStream` is a bidirectional type that can be used to simulate IO, but over an in-process piece of memory.
2020-07-21chore: prepare to release 0.2.22 (#2672)Eliza Weisman
# 0.2.22 (July 2!, 2020) ### Fixes - docs: misc improvements (#2572, #2658, #2663, #2656, #2647, #2630, #2487, #2621, #2624, #2600, #2623, #2622, #2577, #2569, #2589, #2575, #2540, #2564, #2567, #2520, #2521, #2493) - rt: allow calls to `block_on` inside calls to `block_in_place` that are themselves inside `block_on` (#2645) - net: fix non-portable behavior when dropping `TcpStream` `OwnedWriteHalf` (#2597) - io: improve stack usage by allocating large buffers on directly on the heap (#2634) - io: fix unsound pin projection in `AsyncReadExt::read_buf` and `AsyncWriteExt::write_buf` (#2612) - io: fix unnecessary zeroing for `AsyncRead` implementors (#2525) - io: Fix `BufReader` not correctly forwarding `poll_write_buf` (#2654) - io: fix panic in `AsyncReadExt::read_line` (#2541) ### Changes - coop: returning `Poll::Pending` no longer decrements the task budget (#2549) ### Added - io: little-endian variants of `AsyncReadExt` and `AsyncWriteExt` methods (#1915) - task: add [`tracing`] instrumentation to spawned tasks (#2655) - sync: allow unsized types in `Mutex` and `RwLock` (via `default` constructors) (#2615) - net: add `ToSocketAddrs` implementation for `&[SocketAddr]` (#2604) - fs: add `OpenOptionsExt` for `OpenOptions` (#2515) - fs: add `DirBuilder` (#2524) [`tracing`]: https://crates.io/crates/tracing Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2020-07-21sync: support larger number of semaphore permits (#2607)Kornel
2020-07-21doc: update links in README.md and CONTRIBUTING.md (#2609)Alice Ryhl
2020-07-21provide a way to drop a runtime in an async context (#2646)bdonlan
Dropping a runtime normally involves waiting for any outstanding blocking tasks to complete. When this drop happens in an asynchronous context, we previously would issue a cryptic panic due to trying to block in an asynchronous context. This change improves the panic message, and adds a `shutdown_blocking()` function which can be used to shutdown a runtime without blocking at all, as an out for cases where this really is necessary. Co-authored-by: Bryan Donlan <bdonlan@amazon.com> Co-authored-by: Alice Ryhl <alice@ryhl.io>
2020-07-20Update doc comments (#2572)Mikail Bagishov
* Update doc comments * Remove trailing whitespace
2020-07-20io: Forward poll_write_buf on BufReader (#2654)Markus Westerlind
For some yet unknown reason using the default on a wrapped `Bufreader<TcpStream>` causes the hyper server to sometimes fail to send the entire body in the response. This fixes that problem for us and ensures that hyper has a chance to use vectored IO (making it a good change regardless of the mentioned bug)
2020-07-20sync: remove misleading comment (#2666)nicolaiunrein
We are not returning the old value. I suppose this was once indented and this is a leftover.
2020-07-20time: improve Entry field comment (#2671)Blas Rodriguez Irizar
Applying a suggestion from #2617 to make the sentence more clear.
2020-07-20dns: document that strings require the DNS feature (#2663)Alice Ryhl
2020-07-20sync: "which kind of mutex?" section added to doc (#2658)Alice Ryhl
2020-07-16io: add little endian variants for AsyncRead/WriteExt (#1915)Evan Cameron
2020-07-14rt: allow block_on inside block_in_place inside block_on (#2645)bdonlan
A fast path in block_on_place was failing to call exit() in the case where we were in a block_on call. Fixes: #2639 Co-authored-by: Bryan Donlan <bdonlan@amazon.com>
2020-07-13task: add Tracing instrumentation to spawned tasks (#2655)Eliza Weisman
## Motivation When debugging asynchronous systems, it can be very valuable to inspect what tasks are currently active (see #2510). The [`tracing` crate] and related libraries provide an interface for Rust libraries and applications to emit and consume structured, contextual, and async-aware diagnostic information. Because this diagnostic information is structured and machine-readable, it is a better fit for the task-tracking use case than textual logging — `tracing` spans can be consumed to generate metrics ranging from a simple counter of active tasks to histograms of poll durations, idle durations, and total task lifetimes. This information is potentially valuable to both Tokio users *and* to maintainers. Additionally, `tracing` is maintained by the Tokio project and is becoming widely adopted by other libraries in the "Tokio stack", such as [`hyper`], [`h2`], and [`tonic`] and in [other] [parts] of the broader Rust ecosystem. Therefore, it is suitable for use in Tokio itself. [`tracing` crate]: https://github.com/tokio-rs/tracing [`hyper`]: https://github.com/hyperium/hyper/pull/2204 [`h2`]: https://github.com/hyperium/h2/pull/475 [`tonic`]: https://github.com/hyperium/tonic/blob/570c606397e47406ec148fe1763586e87a8f5298/tonic/Cargo.toml#L48 [other]: https://github.com/rust-lang/chalk/pull/525 [parts]: https://github.com/rust-lang/compiler-team/issues/331 ## Solution This PR is an MVP for instrumenting Tokio with `tracing` spans. When the "tracing" optional dependency is enabled, every spawned future will be instrumented with a `tracing` span. The generated spans are at the `TRACE` verbosity level, and have the target "tokio::task", which may be used by consumers to filter whether they should be recorded. They include fields for the type name of the spawned future and for what kind of task the span corresponds to (a standard `spawn`ed task, a local task spawned by `spawn_local`, or a `blocking` task spawned by `spawn_blocking`). Because `tracing` has separate concepts of "opening/closing" and "entering/exiting" a span, we enter these spans every time the spawned task is polled. This allows collecting data such as: - the total lifetime of the task from `spawn` to `drop` - the number of times the task was polled before it completed - the duration of each individual time that the span was polled (and therefore, aggregated metrics like histograms or averages of poll durations) - the total time a span was actively being polled, and the total time it was alive but **not** being polled - the time between when the task was `spawn`ed and the first poll As an example, here is the output of a version of the `chat` example instrumented with `tracing`: ![image](https://user-images.githubusercontent.com/2796466/87231927-e50f6900-c36f-11ea-8a90-6da9b93b9601.png) And, with multiple connections actually sending messages: ![trace_example_1](https://user-images.githubusercontent.com/2796466/87231876-8d70fd80-c36f-11ea-91f1-0ad1a5b3112f.png) I haven't added any `tracing` spans in the example, only converted the existing `println!`s to `tracing::info` and `tracing::error` for consistency. The span durations in the above output are generated by `tracing-subscriber`. Of course, a Tokio-specific subscriber could generate even more detailed statistics, but that's follow-up work once basic tracing support has been added. Note that the `Instrumented` type from `tracing-futures`, which attaches a `tracing` span to a future, was reimplemented inside of Tokio to avoid a dependency on that crate. `tracing-futures` has a feature flag that enables an optional dependency on Tokio, and I believe that if another crate in a dependency graph enables that feature while Tokio's `tracing` support is also enabled, it would create a circular dependency that Cargo wouldn't be able to handle. Also, it avoids a dependency for a very small amount of code that is unlikely to ever change. There is, of course, room for plenty of future work here. This might include: - instrumenting other parts of `tokio`, such as I/O resources and channels (possibly via waker instrumentation) - instrumenting the threadpool so that the state of worker threads can be inspected - writing `tracing-subscriber` `Layer`s to collect and display Tokio-specific data from these traces - using `track_caller` (when it's stable) to record _where_ a task was `spawn`ed from However, this is intended as an MVP to get us started on that path. Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2020-07-13doc: fix typo from "Rust langague" to "Rust language" (#2656)Antoine Murat
* doc: fix typo in addr * doc: fix typo in stream * doc: fix typo in stream/collect
2020-07-12net: fix OwnedWriteHalf behavior on drop (#2597)Carl Lerche
Previously, dropping the Write handle would issue a `shutdown(Both)`. However, shutting down the read half is not portable and not the correct action to take. This changes the behavior of OwnedWriteHalf to only perform a `shutdown(Write)` on drop.
2020-07-10fix: Update the docs of "pause" to state that time will still advance (#2647)Markus Westerlind
* doc: Update the docs of "pause" to state that time will still advance This was changed in #2059. This had me extremely confused for some time as my timeouts fired immediately, without the wrapped future that were waiting on IO to actually run long enough. I am not sure about the exact wording here but this had me very confused for some time. Deprecating "pause" and giving it a more accurate name may be a good idea as well. ```rust async fn timeout_advances() { time::pause(); timeout(ms(1), async { // Change to 1 and the this future resolve, 2 or // more and the timeout resolves for _ in 0..2 { tokio::task::yield_now().await } }) .await .unwrap(); } ``` * Update tokio/src/time/clock.rs Co-authored-by: Alice Ryhl <alice@ryhl.io> Co-authored-by: Alice Ryhl <alice@ryhl.io>
2020-07-01io: allocate buffer directly on heap (#2634)htrefil
2020-06-25sync: update `oneshot::Receiver::close` doc link (#2630)Gokul
Co-authored-by: Alice Ryhl <alice@ryhl.io>
2020-06-25test: fix new clippy lint (#2631)João Oliveira
2020-06-18docs: BufWriter does not flush on drop (#2487)Artem Pyanykh
Fixes: #2484
2020-06-18docs: remove unneeded doc from AsyncReadExt::read_ext() (#2621)Jeb Rosen
This paragraph from `std::io::Read::read_ext()` applies to *implementors* of `Read`. Since `AsyncReadExt` can't and shouldn't be implemented outside of this crate, this documentation is unnecessary.
2020-06-18sync: channel doc grammar change (#2624)Alice Ryhl
2020-06-17sync: documentation for mpsc channels (#2600)Alice Ryhl
2020-06-16time: add example using `interval` to the time module (#2623)Craig Pastro
2020-06-15doc: fix typo on select macro (#2622)s0lst1ce
2020-06-13sync: allow unsized types in Mutex and RwLock (#2615)Taiki Endo
2020-06-12chore: reduce pin related unsafe code (#2613)Taiki Endo
2020-06-12io: fix unsound pin projection in read_buf and write_buf (#2612)Taiki Endo
2020-06-11net: impl ToSocketAddrs for &[SocketAddr] (#2604)Taiki Endo
2020-06-11docs: fix the link of contributing guide (#2577)johnnydai0
2020-06-10doc: add sleep alias to delay_for (#2589)Alice Ryhl
2020-06-07chore: fix ci failure on master (#2593)Taiki Endo
* Fix clippy warnings * Pin rustc version to 1.43.1 in macOS Refs: https://github.com/rust-lang/rust/issues/73030
2020-06-02io: fix typo on BufReader (#2569)‏‏Dave
2020-05-31docs: use intra-links in the docs (#2575)xliiv
2020-05-31test: fix all clippy lints in tests (#2573)Mikail Bagishov
2020-05-30chore: fix clippy errors (#2571)Mikail Bagishov
2020-05-30docs: replace method links with intra-links (#2540)xliiv
2020-05-29io: update AsyncBufRead documentation (#2564)Geoffry Song
2020-05-28net: add note about into_split's drop (#2567)Mathspy
This took me a bit to catch on to because I didn't really think there was any reason to investigate the individual documentation of each half. As someone dealing with TCP streams directly for first time (without previous experience from other languages) this caught me by surprise
2020-05-24io: fix panic in read_line (#2541)Alice Ryhl
Fixes: #2532
2020-05-21coop: Undo budget decrement on Pending (#2549)Jon Gjengset
This patch updates the coop logic so that the budget is only decremented if a future makes progress (that is, if it returns `Ready`). This is realized by restoring the budget to its former value after `poll_proceed` _unless_ the caller indicates that it made progress. The thinking here is that we always want tasks to make progress when we poll them. With the way things were, if a task polled 128 resources that could make no progress, and just returned `Pending`, then a 129th resource that _could_ make progress would not be polled. Worse yet, this could manifest as a deadlock, if the first 128 resources were all _waiting_ for the 129th resource, since it would _never_ be polled. The downside of this change is that `Pending` resources now do not take up any part of the budget, even though they _do_ take up time on the executor. If a task is particularly aggressive (or unoptimized), and polls a large number of resources that cannot make progress whenever it is polled, then coop will allow it to run potentially much longer before yielding than it could before. The impact of this should be relatively contained though, because tasks that behaved in this way in the past probably ignored `Pending` _anyway_, so whether a resource returned `Pending` due to coop or due to lack of progress may not make a difference to it.
2020-05-21io: remove zeroing for AsyncRead implementors (#2525)Mikail Bagishov
2020-05-21fs: implement OpenOptionsExt for OpenOptions (#2515)Charles Hovine
Trait OpenOptionsExt is now implemented for fs::OpenOption. In order to access the underlying std::fs::OpenOptions wrapped in tokio's OpenOption, an as_inner_mut method was added to OpenOption, only visible to the parent module. Fixes: #2366