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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
//! Every tunable value of the transport, in one place.
//!
//! The table below mirrors section 4.5 of the `Readme.md`. Keeping the values
//! here, next to their justification, is what makes the memory budget of a
//! channel readable: a reader no longer has to grep half a dozen modules to
//! reconstruct it.
//!
//! | Setting | Value | Why |
//! |---|---|---|
//! | `SUBSCRIBER_BUFFER` | 1 024 | one term of the memory budget of a channel |
//! | `enable_safe_overflow` | **false** | enabled, a full subscriber buffer silently overwrites its oldest pending sample, losing a request that is never answered; disabled, `send()` reports `0` delivered and the publisher retries, turning the overflow into backpressure |
//! | `MAX_SLICE_LEN` | 256 | `slice` memory per sample; larger payloads grow the segment |
//! | `MAX_LOANED_SAMPLES` | 1 024 | sizes the data segment of a publisher: ~400 KB, against ~6.5 MB at the iceoryx2 default, untenable with dozens of services |
//! | `MAX_PUBLISHERS` / `MAX_SUBSCRIBERS` | 16 | a channel is shared: every consuming process publishes on it, every provider subscribes to it |
//! | `MAX_NODES` | 32 | processes that can open the same channel at once |
//! | `WAITSET_DEADLINE` | 1 ms | bounds the cost of a missed notification |
//! | `IDLE_SPINS` | 2 000 yields | the hot path stays at polling speed, the idle path blocks on the `WaitSet` |
use Duration;
/// Suffixes of the iceoryx2 services backing one channel.
pub const REQUEST_SUFFIX: &str = "_req";
pub const RESPONSE_SUFFIX: &str = "_resp";
pub const REQUEST_NOTIFY_SUFFIX: &str = "_req_notify";
pub const RESPONSE_NOTIFY_SUFFIX: &str = "_resp_notify";
/// Samples a subscriber can buffer before backpressure is reported.
pub const SUBSCRIBER_BUFFER: usize = 1024;
/// Publishers accepted on one channel: one per process that sends on it.
pub const MAX_PUBLISHERS: usize = 16;
/// Subscribers accepted on one channel: one per process and per channel.
pub const MAX_SUBSCRIBERS: usize = 16;
/// Processes that can open the same channel at once.
pub const MAX_NODES: usize = 32;
/// Samples a publisher can keep loaned at once; sizes its data segment.
pub const MAX_LOANED_SAMPLES: usize = 1024;
/// Initial slice length of a sample; large payloads grow the segment on demand.
pub const MAX_SLICE_LEN: usize = 256;
/// Payload alignment requested from iceoryx2, the alignment `rkyv::to_bytes`
/// produces, so a sample is decodable in place.
pub const PAYLOAD_ALIGNMENT: usize = 16;
/// How long a call waits for the provider to be connected before failing.
///
/// Overridable with `ICE_RPC_PROVIDER_WAIT_MS`.
pub const PROVIDER_WAIT_DEFAULT: Duration = from_secs;
/// How long a response waits for the consumer to be connected.
pub const CONSUMER_WAIT_TIMEOUT: Duration = from_millis;
/// Sleep between two delivery attempts, once the spin budget is exhausted.
pub const PUBLISH_RETRY_SLEEP: Duration = from_millis;
/// Consecutive delivery attempts spent yielding before the retry loop sleeps.
///
/// A full channel is the normal case of a burst; a sleep costs the system timer.
pub const PUBLISH_SPIN_ATTEMPTS: u32 = 4_096;
/// Upper bound on how long a dispatch thread blocks before it drains again.
///
/// The wait itself is event-driven; this deadline is the safety net that bounds
/// the cost of a missed notification.
pub const WAITSET_DEADLINE: Duration = from_millis;
/// Attempts made to open the ports of a channel before giving up on it.
///
/// iceoryx2 answers `SystemInFlux` when another process is creating or removing
/// that exact service at this instant — a race the next attempt wins. Without a
/// retry, one such blip left the channel dead for the rest of the process
/// lifetime, although the error is classified as retryable.
pub const OPEN_RETRY_ATTEMPTS: u32 = 20;
/// Delay between two attempts at opening the ports of a channel.
///
/// 20 × 50 ms is a one-second budget: wider than a process teardown, and the
/// price is paid only by a channel that recovers. A non-retryable failure (a
/// service left by another build) returns immediately instead of waiting.
pub const OPEN_RETRY_SLEEP: Duration = from_millis;
/// Processed samples between two termination checks on the busy path.
///
/// `SignalHandler::termination_requested()` takes a process-wide mutex.
pub const SIGNAL_CHECK_SAMPLES: u32 = 256;
/// Consecutive empty polls spent spinning before a thread blocks on its
/// `WaitSet`.
pub const IDLE_SPINS: u32 = 2_000;