3530 Commits

Author SHA1 Message Date
M.Amin Rayej
84ed35ef70
process: document that Child::wait is cancel safe (#5977) 2023-09-04 10:24:55 +02:00
Jack Wrenn
95fb599664
tokio: render taskdump documentation on docs.rs (#5972)
Modifies `package.metadata.docs.r` so that `--cfg tokio_taskdump`
is used by docs.rs when building documentation.
2023-09-02 11:43:31 +02:00
ComplexSpaces
8b312ee571
macros: use ::core qualified imports instead of ::std inside tokio::test macro (#5973) 2023-09-02 03:44:08 +09:00
Colin Walters
fd7d0ad5e5
io: add SyncIOBridge::into_inner (#5971) 2023-09-01 13:01:22 +00:00
M.Amin Rayej
37bb47c4a2
fs: add vectored writes to tokio::fs::File (#5958) 2023-08-29 14:18:16 +02:00
Rain
cb1e10b745
sync: improve docs for watch channels (#5954)
## Motivation

I found the watch docs as written to be somewhat confusing.

* It wasn't clear to me whether values are marked seen or not at
  creation/subscribe time.
* The example also confused me a bit, suggesting a while loop when a
  do-while loop is generally more correct.
* I noticed a potential race with `borrow` that is no longer an issue
  with `borrow_and_update`.

## Solution

Update the documentation for the watch module to try and make all this
clearer.
2023-08-28 16:13:07 -07:00
Alice Ryhl
fb3028f3a2
test: fix testing category slug (#5953) 2023-08-26 17:09:49 +02:00
Alice Ryhl
b45f5831cf
tokio: remove stats feature (#5952) 2023-08-26 17:09:33 +02:00
Rain
0fe24fcffa
sync: improve cancel-safety documentation for mpsc::Sender::send (#5947)
This specific issue (data loss because a send got cancelled) has bitten
our team a couple of times over the last few months. We've switched to
recommending this kind of reserve pattern instead.
2023-08-25 22:03:23 +00:00
Eliza Weisman
d1dae25cd2
ci: drop MIPS targets from cross-check (#5951)
Currently, Tokio runs cross-compilation checks for the
`mips-unknown-linux-gnu` and `mipsel-unknown-linux-musl` target triples.
However, Rust has recently demoted these targets from Tier 2 support to
Tier 3 (see rust-lang/compiler-team#648). Therefore, MIPS toolchains may
not always be available, even in stable releases. This is currently
[breaking our CI builds][1], as Rust 1.72.0 does not contain a standard
library for `mips-unknown-linux-gnu`.

This branch removes these builds from the cross-compilation check's
build matrix. Tokio may still build successfully for MIPS targets, but
we can't easily guarantee support when the stable Rust release train may
or may not be able to build for MIPS targets.

[1]: https://github.com/tokio-rs/tokio/actions/runs/5970263562/job/16197657405?pr=5947#step:3:80
2023-08-25 14:40:32 -07:00
nicflower
59c9364689
io: pass through IO traits for StreamReader and SinkWriter (#5941) 2023-08-23 17:46:39 +00:00
Alice Ryhl
3b79be624d
chore: prepare tokio-test v0.4.3 (#5943) tokio-test-0.4.3 2023-08-23 12:38:11 +02:00
Jiahao XU
8955ed5f85
sync: add const fn OnceCell::from_value (#5903)
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-08-22 13:32:56 +02:00
Matilda Smeds
bc26934e3b
sync: add Semaphore example that limits open files (#5939) 2023-08-20 12:14:41 +02:00
Hamza Jadid
3d64a06600
docs: added trailing backticks (#5938) 2023-08-17 17:22:34 -05:00
Carl Lerche
a7d52c2fed
chore: prepare Tokio v1.32.0 release (#5937) tokio-1.32.0 2023-08-16 14:11:30 -07:00
Marek Kuskowski
f5f2b58b8d
rt: improve docs for Builder::max_blocking_threads (#5793)
Closes #5777
2023-08-16 12:12:53 -07:00
mahkoh
718dcc8dff
docs: BytesMut::with_capacity does not guarantee exact capacity (#5870) 2023-08-16 10:29:29 -07:00
Folkert de Vries
10e141d211
io: add Ready::ERROR and report error readiness (#5781)
Add `Ready::ERROR` enabling callers to specify interest in error readiness. Some platforms use error
readiness notifications to notify of other events. For example, Linux uses error to notify receipt of
messages on a UDP socket's error queue.

Using error readiness is platform specific.

Closes #5716
2023-08-16 10:28:19 -07:00
Carl Lerche
6e42c26c80
rt(alt): tweak some constants to improve scalability (#5935)
This patch aims to reduce the number of threads that get no-op wakeups.
2023-08-16 08:20:48 -07:00
Folkert de Vries
82bef00db4
io: minor tweaks to AsyncFd (#5932) 2023-08-14 19:13:14 +02:00
Alice Ryhl
40633fc678
readme: list previous LTS releases (#5931) 2023-08-14 19:10:24 +02:00
Aspen Smith
3dd5f7ae2e
sync: move broadcast waiters into separate list before waking (#5925)
Within `notify_rx`, looping while re-locking and re-reading from
`Shared.tail` as long as there are still available wakers causes a
quadratic slowdown as receivers which are looping receiving from the
channel are added. Instead of continually re-reading from the original
list, this commit modifies `notify_rx` to move the waiters into a
separate list immediately similar to how `Notify::notify_waiters` works,
using a new `WaitersList` struct modified after NotifyWaitersList.

Fixes #5923
2023-08-14 19:09:56 +02:00
Félix Saparelli
2c92cad9db
process: stabilize Command::raw_arg (#5930) 2023-08-13 10:03:11 +02:00
joe thomas
197757d440
streams: create StreamMock for testing Streams (#5915)
Introduce a new mock type to tests streams and eventually
sinks. Only includes next() and wait() for now. Fixes #4106
2023-08-12 19:18:23 +00:00
Carl Lerche
8b8005ebdd
chore: prepare Tokio v1.31.0 release (#5928) tokio-1.31.0 2023-08-12 09:37:49 -07:00
Carl Lerche
6cb106c353
rt: unstable EWMA poll time metric (#5927)
Because the runtime uses this value as a tuning heuristic, it can be
useful to get its value. This patch exposes the value as an unstable
metric.
2023-08-10 19:43:44 +00:00
Carl Lerche
dd23f08c3a
rt(alt): fix memory leak and increase max preemption when running Loom CI tests (#5911)
The memory leak was caused by a bug during shutdown where some state was leaked.
2023-08-10 09:18:10 -07:00
Jakub Kubík
5d29bdfb0c
io: delegate WriteHalf::poll_write_vectored (#5914) 2023-08-10 10:11:00 +02:00
Brian Cardarella
4c220af777
chore: prepare Tokio v1.30.0 release (#5917) tokio-1.30.0 2023-08-09 15:16:11 +00:00
Jiahao XU
0a631f88e8
process: add {ChildStd*}::into_owned_{fd, handle} (#5899) 2023-08-09 16:04:53 +02:00
Carl Lerche
ee44dc98d8
ci: fix MIRI tests (#5919)
A change to parking lot or miri resulted in CI breaking.
2023-08-08 12:34:19 -07:00
Consoli
51cffbb74f
time: mark Sleep as !Unpin in docs (#5916) 2023-08-06 13:34:08 +02:00
Carl Lerche
8832e936b1
rt(alt): fix a number of concurrency bugs (#5907)
Expands loom coverage and fixes a number of bugs.

Closes #5888
2023-08-04 11:59:38 -07:00
Victor Timofei
dbda2045f1
time: implement extra reset variants for Interval (#5878) 2023-08-04 19:12:51 +02:00
Carl Lerche
7c54fdce3e
rt: pop at least one task from inject queue (#5908)
When attempting to pull a batch of tasks from the injection queue,
ensure we set the cap to at least one.
2023-08-04 08:24:01 -07:00
wathen
38d1bcd9df
sync: avoid false sharing in mpsc channel (#5829) 2023-08-03 15:54:19 +02:00
Alice Ryhl
52e6510215
runtime: fix flaky test wake_while_rt_is_dropping (#5905) 2023-08-02 22:30:34 +02:00
Taiki Endo
e5e88551d2
Update CI config (#5893) 2023-08-02 01:04:11 +09:00
Jiahao XU
efe3ab679a
sync: make const_new methods always available (#5885)
Since MSRV is bumped to 1.63, `Mutex::new` is now usable in const context.

Also use `assert!` in const function to ensure correctness instead of
silently truncating the value and remove cfg `tokio_no_const_mutex_new`.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-07-28 13:46:21 +02:00
Jiahao XU
fb08591b43
tokio: removed unused tokio_* cfgs (#5890)
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-07-28 12:54:55 +02:00
kiron1
6aca07bee7
example: use copy_bidirectional in proxy.rs (#5856) 2023-07-28 12:06:44 +02:00
Jiahao XU
5128601898
ci: fix clippy warnings (#5891)
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-07-28 12:05:32 +02:00
Jiahao XU
c445e467ce
tokio: bump MSRV to 1.63 (#5887) 2023-07-27 10:57:19 +02:00
Carl Lerche
a58beb3aca
rt(alt): track which workers are idle. (#5886)
The scheduler uses this map to avoid trying to steal from idle workers.
2023-07-21 14:00:33 -07:00
Carl Lerche
4165601b1b
rt: initial implementation of new threaded runtime (#5823)
This patch includes an initial implementation of a new multi-threaded
runtime. The new runtime aims to increase the scheduler throughput by
speeding up how it dispatches work to peer worker threads. This
implementation improves most benchmarks by about ~10% when the number of
threads is below 16. As threads increase, mutex contention deteriorates
performance.

Because the new scheduler is not yet ready to replace the old one, the
patch introduces it as an unstable runtime flavor with a warning that it
isn't production ready. Work to improve the scalability of the runtime
will most likely require more intrusive changes across Tokio, so I am
opting to merge with master to avoid larger conflicts.
2023-07-21 11:56:34 -07:00
Hayden Stainsby
63577cd8d3
rt: add runtime ID (#5864)
There are a number of cases in which being able to identify a runtime is
useful.

When instrumenting an application, this is particularly true. For
example, we would like to be able to add traces for runtimes so that
tasks can be differentiated (#5792). It would also allow a way to
differentiate runtimes which are have their tasks dumped.

Outside of instrumentation, it may be useful to check whether 2 runtime
handles are pointing to the same runtime.

This change adds an opaque `runtime::Id` struct which serves this
purpose, initially behind the `tokio_unstable` cfg flag. 

The inner value of the ID is taken from the `OwnedTasks` or
`LocalOwnedTasks` struct which every runtime and local set already
has. This will mean that any use of the ID will align with the task
dump feature.

The ID is added within the scope of working towards closing #5545.
2023-07-19 12:53:40 +02:00
Josh Guilfoyle
02544540f1
net: implement UCred for espidf (#5868) 2023-07-19 11:24:13 +02:00
Josh Guilfoyle
d64c8e3ae0
poll: Do not clear readiness on short read/writes. (#5881)
The new mio_unsupported_force_poll_poll behaviour works the same as
Windows (using level-triggered APIs to mimic edge-triggered ones) and it
depends on intercepting an EAGAIN result to start polling the fd again.
2023-07-18 20:28:30 -05:00
Hayden Stainsby
f24b9824e6
rt: use optional non-zero value for task owner_id (#5876)
We switch to using a `NonZeroU64` for the `id` field for `OwnedTasks`
and `LocalOwnedTasks` lists. This allows the task header to contain an
`Option<NonZeroU64>` instead of a `u64` with a special meaning for 0.

The size in memory will be the same thanks to Rust's niche optimization,
but this solution is clearer in its intent.

Co-authored-by: Alice Ryhl <aliceryhl@google.com>
2023-07-18 09:43:25 +02:00