# Behavior traces — tokio-rs/tokio

> Canonical page: https://codevetter.com/unpack/tokio/behavior-traces

# Behavior traces — tokio-rs/tokio

Scanned commit 2746c3ae26f8ac0af6023843a7f23d419c334efe (2026-10-02). Generated by codevetter codevetter 1.15.0 on 2026-10-02.

Source inspection; upstream code and tests were not executed.

Three principal flows were followed through implementation: runtime startup, TCP connection handling, and filesystem writing. Startup selects an executor and creates its drivers before running user futures. Networking follows resolution, registration, readiness, and socket operations. Filesystem writing branches between blocking and experimental io-uring execution, with additional completion boundaries for buffered File writes.
- Startup: parse_knobs removes asyncness, chooses the configured Builder flavor, applies options, then emits enable_all → build/build_local → expect → block_on. — [tokio-macros/src/entry.rs#L440-L441](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio-macros/src/entry.rs#L440-L441) [tokio-macros/src/entry.rs#L468-L496](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio-macros/src/entry.rs#L468-L496) [tokio-macros/src/entry.rs#L509-L519](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio-macros/src/entry.rs#L509-L519)
- Multi-thread startup: build → build_threaded_runtime → Driver::new → create_blocking_pool → MultiThread::new → handle.enter → launch.launch → Runtime::from_parts. — [tokio/src/runtime/builder.rs#L1146-L1151](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio/src/runtime/builder.rs#L1146-L1151) [tokio/src/runtime/builder.rs#L2180-L2198](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio/src/runtime/builder.rs#L2180-L2198) [tokio/src/runtime/builder.rs#L2228-L2234](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio/src/runtime/builder.rs#L2228-L2234)
- Execution: Runtime::block_on → block_on_inner → enter → scheduler.block_on; MultiThread enters runtime context and drives the root future on the calling thread. — [tokio/src/runtime/runtime.rs#L343-L382](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio/src/runtime/runtime.rs#L343-L382) [tokio/src/runtime/scheduler/multi_thread/mod.rs#L81-L91](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio/src/runtime/scheduler/multi_thread/mod.rs#L81-L91)
- TCP bind: TcpListener::bind → to_socket_addrs → sequential bind_addr attempts → Mio bind → TcpListener::new → PollEvented registration; empty resolution returns InvalidInput. — [tokio/src/net/tcp/listener.rs#L102-L125](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio/src/net/tcp/listener.rs#L102-L125) [tokio/src/net/tcp/listener.rs#L303-L305](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio/src/net/tcp/listener.rs#L303-L305) [tokio/src/io/poll_evented.rs#L110-L124](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio/src/io/poll_evented.rs#L110-L124)
- TCP accept: accept → Registration::async_io(READABLE) → readiness and cooperative budget → Mio accept → new_accepted; WouldBlock clears readiness, and accepted streams initially assume read/write readiness. — [tokio/src/net/tcp/listener.rs#L162-L170](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio/src/net/tcp/listener.rs#L162-L170) [tokio/src/runtime/io/registration.rs#L225-L244](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio/src/runtime/io/registration.rs#L225-L244) [tokio/src/net/tcp/stream.rs#L171-L180](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio/src/net/tcp/stream.rs#L171-L180)
- Echo flow: echo_server binds loopback, spawns a client performing write_all/read_exact, accepts and splits the server stream, copies read-to-write, then checks byte count and completion. — [tokio/tests/tcp_echo.rs#L16-L51](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio/tests/tcp_echo.rs#L16-L51) [tokio/src/net/tcp/stream.rs#L1451-L1465](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio/src/net/tcp/stream.rs#L1451-L1465) [tokio/src/io/poll_evented.rs#L171-L180](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio/src/io/poll_evented.rs#L171-L180)
- Whole-file persistence: fs::write upgrades contents; eligible Linux builds probe io-uring Write support, otherwise write_spawn_blocking → asyncify → spawn_blocking → std::fs::write. — [tokio/src/fs/write.rs#L26-L50](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio/src/fs/write.rs#L26-L50) [tokio/src/fs/write.rs#L98-L100](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio/src/fs/write.rs#L98-L100) [tokio/src/fs/mod.rs#L320-L328](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio/src/fs/mod.rs#L320-L328)
- Buffered persistence: File::poll_write copies bytes and starts mandatory blocking work before returning; poll_flush joins Busy work, while sync_all first completes in-flight work and calls std.sync_all. — [tokio/src/fs/file.rs#L750-L796](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio/src/fs/file.rs#L750-L796) [tokio/src/fs/file.rs#L1146-L1169](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio/src/fs/file.rs#L1146-L1169) [tokio/src/fs/file.rs#L317-L322](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio/src/fs/file.rs#L317-L322)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
