3970 Commits

Author SHA1 Message Date
tiif
161b8c80d5
ci: test more things with miri (#6885) 2024-10-11 09:44:50 +02:00
Sören Meier
9cc4a81678
sync: add watch::Sender::sender_count (#6836)
This makes it possible to check if other senders exist. For example
If you are using a Sender as a subscriber to get a Receiver and might want
to know if the real sender is still running.
2024-10-11 04:31:11 +02:00
Name
679d7657dc
io: document cancel safety of AsyncFd methods (#6890) 2024-10-09 01:08:41 +09:00
Hayden Stainsby
c3a935541d
task: add task size to tracing instrumentation (#6881)
In Tokio, the futures for tasks are stored on the stack unless they are
explicitly boxed, either by the user or auto-boxed by Tokio when they
are especially large. Auto-boxing now also occurs in release mode
(since #6826).

Having very large futures can be problematic as it can cause a stack
overflow. In some cases it might be desireable to have smaller futures,
even if they are placed on the heap.

This change adds the size of the future driving an async task or the
function driving a blocking task to the tracing instrumentation. In the
case of a future that is auto-boxed by Tokio, both the final size as well
the original size before boxing is included.

To do this, a new struct `SpawnMeta` gets passed down from where a
future might get boxed to where the instrumentation is added. This
contains the task name (optionally) and the original future or function
size. If the `tokio_unstable` cfg flag and the `tracing` feature aren't both
enabled, then this struct will be zero sized, which is a small improvement
on the previous behavior of unconditionally passing down an `Option<&str>`
for the name.

This will make this information immediately available in Tokio Console,
and will enable new lints which will warn users if they have large futures
(just for async tasks).

We have some tests under the `tracing-instrumentation` crate which test
that the `size.bytes` and `original_size.bytes` fields are set correctly.

The minimal version of `tracing` required for Tokio has been bumped from
0.1.25 to 0.1.29 to get the `Value` impl on `Option<T>`. Given that the current
version is 0.1.40, this seems reasonable, especially given that Tracing's MSRV
is still lower than Tokio's in the latest version.
2024-10-08 10:51:03 +02:00
Nur
29cd6ec1ec
time: import Future trait from std instead of futures_core (#6884) 2024-10-07 14:13:09 +02:00
Evan Rittenhouse
b68f5c7f38
task: stabilize task ids (#6793)
Co-authored-by: Alice Ryhl <aliceryhl@google.com>
2024-10-06 08:50:21 +00:00
Motoyuki Kimura
6c5dbfa08c
readme: update miri test command (#6883) 2024-10-05 17:22:20 +02:00
oxalica
2c14f88c90
macros: suppress clippy::needless_return in #[tokio::main] (#6874) 2024-09-28 12:33:51 +02:00
shray sharma
e2e1e8e71d
sync: fix Stream link in broadcast docs (#6873) 2024-09-27 13:49:06 +02:00
Timo
21df16d759
sync: apply cooperative scheduling to sync::broadcast::Receiver (#6870) 2024-09-26 16:52:46 +02:00
Timo
c8af499990
sync: apply cooperative scheduling to sync::watch (#6846) 2024-09-26 12:36:22 +00:00
Nick Mathewson
623928e371
net: add conversions for unix SocketAddr (#6868) 2024-09-25 13:56:52 +00:00
Motoyuki Kimura
09bc9a05e4
chore: use boxed slice if possible (#6858) 2024-09-25 19:45:28 +09:00
Alice Ryhl
82628b8a78
metrics: don't hang in injection_queue_depth_multi_thread test (#6862) 2024-09-24 08:34:17 +02:00
Alice Ryhl
21cf5a5469
runtime: avoid pointer casts in IO driver on miri (#6859)
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
2024-09-23 20:32:37 +02:00
vxzyfx's github
8ef5163df8
stream: fix link on Peekable (#6861) 2024-09-23 14:56:42 +00:00
Owen Leung
542197cdb9
metrics: stabilize injection_queue_depth metric (#6854) 2024-09-22 18:38:37 +02:00
vxzyfx's github
a302367b8f
net: change quotes in docs (#6852) 2024-09-21 13:53:34 +02:00
Maximilian Hils
b5de84d19b
runtime: box futures larger than 16k on release mode (#6826) 2024-09-16 22:15:44 +02:00
Jonas Fassbender
02aaea28b9
sync: document runtime compatibility (#6833) 2024-09-16 21:58:24 +02:00
Rustin
83e922f051
macros: render more comprehensible documentation for try_join! (#6841)
Signed-off-by: Rustin170506 <29879298+Rustin170506@users.noreply.github.com>
2024-09-14 11:34:45 +02:00
Benjamin Richner
a2496548d1
net: fix examples for TcpSocket::{set_nodelay,nodelay} (#6840) 2024-09-12 15:07:16 +02:00
Motoyuki Kimura
0cea36fa3d
net: fix handling of leading zero byte in from_abstract_name (#6838) 2024-09-11 20:15:12 +02:00
Nam Se Hyun
d6213594ca
fs: make available to wasm under tokio_unstable (#6822) 2024-09-11 12:55:07 +00:00
Alice Ryhl
91169992b2
io: recommend OwnedFd with AsyncFd (#6821)
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
2024-09-06 09:52:08 +02:00
Rustin
8046a87a99
macros: render more comprehensible documentation for join! (#6814)
Signed-off-by: Rustin170506 <29879298+Rustin170506@users.noreply.github.com>
2024-09-06 09:36:25 +02:00
Sylwester Rąpała
5dcc848fc8
sync: add #[must_use] to Notified (#6828) 2024-09-06 09:03:27 +02:00
Timo
bd4ccae184
time: add abstraction for RwLock to remove poisoning aspect (#6807)
With #6779 we removed unnecessary allocations from the timerwheel by
wrapping it in an `std::sync::RwLock`. Since the `Mutex` used in this
part of the project uses an abstraction in `loom::sync::Mutex` to get
rid of the poisoning aspects of `std::sync::Mutex` the same should
probably be done for the used read-write lock struct.

This commit introduces an abstraction to get rid of the poisoning
aspects of `std::sync::RwLock` by introducing a wrapper to the
`loom::sync` module similar to `loom::sync::Mutex`.

Refs: #6779
2024-09-05 23:48:05 +09:00
Dirkjan Ochtman
4ed0fa21e4
chore: prepare tokio-stream v0.1.16 (#6825) tokio-stream-0.1.16 2024-09-05 12:42:22 +02:00
Eduardo Sánchez Muñoz
12b2567b95
chore: use poll_fn from std (#6810) 2024-09-05 09:54:06 +02:00
Timo
35f244ad09
chore: prepare tokio-util v0.7.12 (#6823) tokio-util-0.7.12 2024-09-05 00:22:11 +02:00
Sarek Høverstad Skotåm
1166ecc2ac
config: enable full for tokio-util in the playground (#6818) 2024-09-03 20:34:20 +00:00
Antonio de la Vega
27539ae3bd
runtime: fix race in yield_defers_until_park test (#6809) 2024-08-31 21:34:22 +02:00
Motoyuki Kimura
ea6d652a10
chore: prepare Tokio v1.40.0 (#6806) tokio-1.40.0 2024-08-30 10:03:16 +02:00
Havish Maka
11f66f43a0
chore: replace ready! with std::task::ready! (#6804) 2024-08-29 22:02:56 +02:00
Timo
479a56a010
time: eliminate timer wheel allocations (#6779) 2024-08-27 22:18:29 +02:00
Noah Kennedy
b37f0de28a
runtime: implement initial set of task hooks (#6742) 2024-08-27 15:27:58 +02:00
Yotam Ofek
c9fad08466
codec: fix typo in the docs for Encoder::Error (#6800) 2024-08-27 09:08:22 +02:00
Havish Maka
cc70a211ad
task: add join_all method to JoinSet (#6784)
Adds join_all method to JoinSet. join_all consumes JoinSet and awaits
the completion of all tasks on it, returning the results of the tasks in
a vec. An error or panic in the task will cause join_all to panic,
canceling all other tasks.

Fixes: #6664
2024-08-27 01:06:52 +09:00
Rafael Bachmann
1ac8dff213
task: add AbortOnDropHandle type (#6786) 2024-08-20 10:58:04 +02:00
Daniel Sedlak
ff3f2a8878
io: add SimplexStream (#6589) 2024-08-19 15:47:57 +02:00
rosscanning
5b9a290acd
io: clarify zero remaining capacity case (#6790) 2024-08-19 09:09:24 +09:00
dpl
70569bd009
task: fix typo in TaskTracker docs (#6792) 2024-08-18 15:09:19 +02:00
Tobias Bucher
9bd6702a3f
sync: mark mpsc types as UnwindSafe (#6783) 2024-08-18 13:36:51 +02:00
mox692
365269adaf Merge 'tokio-1.39.x' into master (#6788) 2024-08-17 19:35:28 +09:00
Motoyuki Kimura
3d439ab711
chore: prepare Tokio v1.39.3 (#6782) tokio-1.39.3 2024-08-17 10:26:43 +02:00
Motoyuki Kimura
b2ea40bb54
net: add handling for abstract socket name (#6772) 2024-08-16 23:50:34 +09:00
Rafael Bachmann
5ea3c63d7e
sync: document mpsc channel allocation behavior (#6773) 2024-08-16 12:31:03 +02:00
Eliza Weisman
56f3f40c15
tests: handle ECONNREFUSED in uds_stream::epollhup (#6778)
## Motivation

Currently, the test `uds_stream::epollhup` expects that a
`UdsStream::connect` future to a Unix socket which is closed by the
accept side to always fail with `io::ErrorKind::ConnectionReset`. On
illumos, and potentially other systems, it instead fails with
`io::ErrorKind::ConnectionRefused`.

This was discovered whilst adding an illumos CI job in PR #6769. See:
https://github.com/tokio-rs/tokio/pull/6769#issuecomment-2284753794

## Solution

This commit changes the test to accept either `ConenctionReset` or
`ConnectionRefused`. This way, we are more tolerant of different
operating systems which may decide to return slightly different errnos
here. Both ECONNREFUSED and ECONNRESET seem reasonable to expect in this
situation, although arguably, ECONNREFUSED is actually more correct: the
acceptor did not accept the connection at all, which seems like
"refusing" it to me...
2024-08-16 10:55:32 +02:00
Eliza Weisman
2d697fc92b
tests: handle spurious EWOULDBLOCK in io_async_fd (#6776)
* tests: handle spurious EWOULDBLOCK in io_async_fd

## Motivation

The `io_async_fd.rs` tests contain a `drain()` function, which
currently performs synchronous reads from a UDS socket until it returns
`io::ErrorKind::WouldBlock` (i.e., errno `EWOULDBLOCK`/`EAGAIN`). The
*intent* behind this function is to ensure that all data has been
drained from the UDS socket's buffer...which is what it appears to
do...on Linux. On other systems, it appears that an `EWOULDBLOCK` or
`EAGAIN` may be returned before enough data has been read from the UDS
socket to result in the other end being notified that the socket is now
writable. In particular, this appears to be the case on illumos, where
the tests using this function hang forever (see [this comment][1] on PR
#6769).

To my knowledge, this behavior is still POSIX-compliant --- the
reader will still be notified that the socket is readable, and if it
were actually doing non-blocking IO, it would continue reading upon
receipt of that notification. So, relying on `EWOULDBLOCK` to indicate
that the socket has been sufficiently drained appears to rely on
Linux/FreeBSD behavior that isn't necessarily portable to other Unices.

## Solution

This commit changes the `drain()` function to take an argument for the
number of bytes *written* to the socket previously, and continue looping
until it has read that many bytes, regardless of whether `EWOULDBLOCK`
is returned. This should ensure that the socket is drained on all
POSIX-compliant systems, and indeed, the `io_async_fd::reset_writable`
and `io_async_fd::poll_fns` tests no longer hang forever on illumos.

I think making this change is an appropriate solution to the
test failure here, as the `drain()` function is part of the test, rather
than the code in Tokio *being* tested, and (as I mentioned above) the
use of blocking reads on a non-blocking socket without a mechanism to
continue reading when the socket becomes readable again is not really
something a real life program seems likely to do. Ensuring that all the
written bytes have been read by passing in a byte count seems more
faithful to what the test is actually *trying* to do here, anyway.

Thanks to @jclulow for debugging what was going on here!

This change was cherry-picked from commit
f18d6ed7d4e0724bbe14db5519d7c80b3227a1a9 from PR #6769, so that the fix
can be merged separately.

[1]: https://github.com/tokio-rs/tokio/pull/6769#issuecomment-2284753794

Signed-off-by: Eliza Weisman <eliza@elizas.website>
2024-08-15 15:44:36 +00:00