1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//! Real [`crate::runner::ProcessRunner`] over actual OS processes.
//!
//! Split by concern: `runner` holds `TokioRunner` and `TokioProc` and their
//! trait impls, `log_file` is the buffered per-stream log writer, `preflight`
//! judges a program before a spawn, and `pump` holds the tasks that drain a
//! child's stdout, stderr and shepherd channel.
use Duration;
/// Capacity of every channel a spawn wires up: enough that a bursty child
/// does not back-pressure a sheep task that is merely slow to poll, without
/// buffering unboundedly.
const CHANNEL_CAPACITY: usize = 32;
/// Bytes a log file buffers before the pump writes them through.
///
/// `tokio::fs::File` hands every `write` to the blocking pool: 32.8 us of
/// daemon CPU per line against 0.99 us for the `write(2)` under it. Batching
/// amortises one dispatch over a whole buffer.
const LOG_BUFFER: usize = 8 * 1024;
/// How long a line may sit in that buffer before the pump writes it out
/// anyway.
///
/// Timed from the oldest unflushed line, so a steady trickle cannot push the
/// deadline out indefinitely. It exists for the sheep that logs one line and
/// then goes quiet.
const IDLE_FLUSH: Duration = from_millis;
/// Bytes each stream's reader may hold ahead of the lines it has emitted.
///
/// Two bounds rest on it: the most a handover can strand in userspace, since
/// bytes taken off the pipe die with the image at the `execve`, and the most
/// [`pump::drain_ready`] can write.
const READ_BUFFER: usize = 8 * 1024;
/// How long the pump keeps reading after its sheep task has let go.
///
/// Without it [`pump::spawn_log_pump`]'s `select!` can take the
/// `logs_tx.closed()` branch with the child's last line still in the pipe:
/// `tokio::select!` picks between ready branches at random. The budget is
/// spent only when a lamb still holds a write end, and it does not bound the
/// lamb. 100ms against a worst case of 7 to 12ms for two full pipes.
const FINAL_DRAIN: Duration = from_millis;
pub use ;
pub use ;
pub use signal_group;
pub use signal_pid;