Skip to main content

subetha_cxc/
sidecar_ops.rs

1//! Per-primitive op_kind constants for sidecar observations.
2//!
3//! Every subetha primitive carries a `HandshakeHeader` + `ObservationRing`
4//! and pushes a per-op `Observation` with the op_kind drawn from the
5//! constants below. The sidecar's drain folds these into
6//! `InstanceStats.op_kind_counts[op_kind]`, letting policies distinguish
7//! insert-heavy from get-heavy workloads, contention from idle, etc.
8//!
9//! `op_kind = 0` is reserved for "unspecified" by the sidecar; primitives
10//! start their op_kinds at 1. The sidecar's `N_OP_KINDS = 8` caps how
11//! many distinct op_kinds any one primitive can address; primitives with
12//! more than 7 distinguishable ops must collapse some into a shared
13//! bucket.
14
15/// Op kinds for [`SharedRing`](crate::SharedRing).
16pub mod ring {
17    pub const OP_PUSH: u16 = 1;
18    pub const OP_POP: u16 = 2;
19}
20
21/// Op kinds for [`SharedCell`](crate::SharedCell) and
22/// [`SharedOnceCell`](crate::SharedOnceCell).
23pub mod cell {
24    pub const OP_GET: u16 = 1;
25    pub const OP_SET: u16 = 2;
26}
27
28/// Op kinds for [`SharedHashMap`](crate::SharedHashMap).
29pub mod hash_map {
30    pub const OP_INSERT: u16 = 1;
31    pub const OP_GET: u16 = 2;
32    pub const OP_REMOVE: u16 = 3;
33    pub const OP_CONTAINS: u16 = 4;
34    pub const OP_CLEAR: u16 = 5;
35    pub const OP_COMPACT: u16 = 6;
36}
37
38/// Op kinds for [`SharedRegion`](crate::SharedRegion).
39pub mod region {
40    pub const OP_ALLOCATE: u16 = 1;
41    pub const OP_FREE: u16 = 2;
42    pub const OP_GET: u16 = 3;
43    pub const OP_SET: u16 = 4;
44}
45
46/// Op kinds for [`SharedBroadcastRing`](crate::SharedBroadcastRing).
47pub mod broadcast_ring {
48    pub const OP_PUSH: u16 = 1;
49    pub const OP_RECV: u16 = 2;
50    pub const OP_REGISTER: u16 = 3;
51    pub const OP_UNREGISTER: u16 = 4;
52}
53
54/// Op kinds for [`SharedAtomicU32`](crate::SharedAtomicU32),
55/// [`SharedAtomicU64`](crate::SharedAtomicU64), and
56/// [`SharedAtomicBool`](crate::SharedAtomicBool).
57pub mod atomic {
58    pub const OP_LOAD: u16 = 1;
59    pub const OP_STORE: u16 = 2;
60    pub const OP_FETCH_ADD: u16 = 3;
61    pub const OP_CAS: u16 = 4;
62}
63
64/// Op kinds for [`SharedBitVec`](crate::SharedBitVec).
65pub mod bit_vec {
66    pub const OP_SET: u16 = 1;
67    pub const OP_CLEAR: u16 = 2;
68    pub const OP_GET: u16 = 3;
69    pub const OP_TOGGLE: u16 = 4;
70    pub const OP_RANGE: u16 = 5;
71    pub const OP_COUNT_ONES: u16 = 6;
72}
73
74/// Op kinds for [`SharedBloomFilter`](crate::SharedBloomFilter),
75/// [`SharedCountMinSketch`](crate::SharedCountMinSketch),
76/// [`SharedHyperLogLog`](crate::SharedHyperLogLog).
77pub mod sketch {
78    pub const OP_INSERT: u16 = 1;
79    pub const OP_QUERY: u16 = 2;
80    pub const OP_CLEAR: u16 = 3;
81}
82
83/// Op kinds for [`SharedHistogram`](crate::SharedHistogram).
84pub mod histogram {
85    pub const OP_RECORD: u16 = 1;
86    pub const OP_COUNT: u16 = 2;
87    pub const OP_PERCENTILE: u16 = 3;
88}
89
90/// Op kinds for [`SharedLinkedList`](crate::SharedLinkedList).
91pub mod linked_list {
92    pub const OP_PUSH_BACK: u16 = 1;
93    pub const OP_PUSH_FRONT: u16 = 2;
94    pub const OP_POP_BACK: u16 = 3;
95    pub const OP_POP_FRONT: u16 = 4;
96    pub const OP_REMOVE: u16 = 5;
97    pub const OP_ITER: u16 = 6;
98}
99
100/// Op kinds for [`SharedLRUCache`](crate::SharedLRUCache).
101pub mod lru_cache {
102    pub const OP_GET: u16 = 1;
103    pub const OP_PUT: u16 = 2;
104    pub const OP_TOUCH: u16 = 3;
105    pub const OP_REMOVE: u16 = 4;
106    pub const OP_EVICT: u16 = 5;
107}
108
109/// Op kinds for [`SharedRWLock`](crate::SharedRWLock).
110pub mod rw_lock {
111    pub const OP_READ: u16 = 1;
112    pub const OP_WRITE: u16 = 2;
113    pub const OP_TRY_READ: u16 = 3;
114    pub const OP_TRY_WRITE: u16 = 4;
115}
116
117/// Op kinds for [`SharedSemaphore`](crate::SharedSemaphore).
118pub mod semaphore {
119    pub const OP_ACQUIRE: u16 = 1;
120    pub const OP_RELEASE: u16 = 2;
121    pub const OP_TRY_ACQUIRE: u16 = 3;
122}
123
124/// Op kinds for [`SharedRateLimiter`](crate::SharedRateLimiter).
125pub mod rate_limiter {
126    pub const OP_TRY_ACQUIRE: u16 = 1;
127    pub const OP_AVAILABLE: u16 = 2;
128}
129
130/// Op kinds for [`SharedBTreeMap`](crate::SharedBTreeMap) and
131/// [`SharedTreiberStack`](crate::SharedTreiberStack) and
132/// [`SharedVec`](crate::SharedVec).
133pub mod ordered {
134    pub const OP_INSERT: u16 = 1;
135    pub const OP_GET: u16 = 2;
136    pub const OP_REMOVE: u16 = 3;
137    pub const OP_ITER: u16 = 4;
138    pub const OP_POP: u16 = 5;
139}
140
141/// Op kinds for [`SharedStringArena`](crate::SharedStringArena).
142pub mod string_arena {
143    pub const OP_INTERN: u16 = 1;
144    pub const OP_GET_BYTES: u16 = 2;
145    pub const OP_CLEAR: u16 = 3;
146}
147
148/// Op kinds for [`SharedFenceClock`](crate::SharedFenceClock).
149pub mod fence_clock {
150    pub const OP_TICK: u16 = 1;
151    pub const OP_MERGE: u16 = 2;
152    pub const OP_GET_LOCAL: u16 = 3;
153    pub const OP_COMPUTE_FENCE: u16 = 4;
154}
155
156/// Op kinds for [`HeartbeatTable`](crate::HeartbeatTable) and
157/// [`EpochBarrier`](crate::EpochBarrier).
158pub mod liveness {
159    pub const OP_BEAT: u16 = 1;
160    pub const OP_REGISTER: u16 = 2;
161    pub const OP_WAIT: u16 = 3;
162    pub const OP_TICK_EPOCH: u16 = 4;
163    pub const OP_SCAN: u16 = 5;
164}
165
166/// Op kinds for [`SharedHandleTable`](crate::SharedHandleTable) and
167/// [`OwnerLease`](crate::OwnerLease) and
168/// [`SharedLeaderElection`](crate::SharedLeaderElection).
169pub mod ownership {
170    pub const OP_ACQUIRE: u16 = 1;
171    pub const OP_RELEASE: u16 = 2;
172    pub const OP_GET: u16 = 3;
173    pub const OP_BEAT: u16 = 4;
174    pub const OP_CLAIM: u16 = 5;
175}
176
177/// Op kinds for [`SharedReservoirSampler`](crate::SharedReservoirSampler).
178pub mod reservoir {
179    pub const OP_RECORD: u16 = 1;
180    pub const OP_SNAPSHOT: u16 = 2;
181}
182
183/// Op kinds for [`SharedVersionedChain`](crate::SharedVersionedChain) and
184/// [`SharedTimePointTile`](crate::SharedTimePointTile).
185pub mod versioned {
186    pub const OP_PUSH: u16 = 1;
187    pub const OP_READ_AT: u16 = 2;
188    pub const OP_CURRENT: u16 = 3;
189    pub const OP_VISIBLE_MASK: u16 = 4;
190}
191
192/// Op kinds for [`SharedUniversal`](crate::SharedUniversal).
193pub mod universal {
194    pub const OP_INSERT: u16 = 1;
195    pub const OP_CONTAINS: u16 = 2;
196    pub const OP_REMOVE: u16 = 3;
197    pub const OP_MIGRATE: u16 = 4;
198}
199
200/// Op kinds for [`SharedTopologyMap`](crate::SharedTopologyMap).
201pub mod topology {
202    pub const OP_RECORD: u16 = 1;
203    pub const OP_FAN_OUT: u16 = 2;
204    pub const OP_FAN_IN: u16 = 3;
205    pub const OP_RECOMMEND: u16 = 4;
206}
207
208/// Op kinds for [`SharedGraph`](crate::SharedGraph).
209pub mod graph {
210    pub const OP_ADD_NODE: u16 = 1;
211    pub const OP_ADD_EDGE: u16 = 2;
212    pub const OP_NEIGHBORS: u16 = 3;
213    pub const OP_REMOVE_EDGE: u16 = 4;
214}
215
216/// Op kinds for [`PriorityFanout`](crate::PriorityFanout).
217pub mod priority_fanout {
218    pub const OP_SUBMIT: u16 = 1;
219    pub const OP_DRAIN_HIGHEST: u16 = 2;
220    pub const OP_DRAIN_PRIORITY: u16 = 3;
221}
222
223/// Op kinds for [`EventStateLog`](crate::EventStateLog).
224pub mod event_log {
225    pub const OP_EMIT: u16 = 1;
226    pub const OP_DRAIN_FOLD: u16 = 2;
227    pub const OP_READ_CURRENT: u16 = 3;
228}
229
230/// Op kinds for [`ProgressTask`](crate::ProgressTask).
231pub mod progress {
232    pub const OP_ADVANCE: u16 = 1;
233    pub const OP_READ: u16 = 2;
234    pub const OP_COMPLETE: u16 = 3;
235}
236
237/// Op kinds for [`LazyConfig`](crate::LazyConfig).
238pub mod lazy_config {
239    pub const OP_GET: u16 = 1;
240    pub const OP_FETCH: u16 = 2;
241}
242
243/// Op kinds for [`BackgroundScheduler`](crate::BackgroundScheduler) and
244/// [`FailoverWatchdog`](crate::failover::FailoverWatchdog).
245pub mod scheduler {
246    pub const OP_SUBMIT: u16 = 1;
247    pub const OP_RECV: u16 = 2;
248    pub const OP_WATCHDOG_SCAN: u16 = 3;
249}
250
251/// Op kinds for [`SharedAsyncPointer`](crate::SharedAsyncPointer).
252pub mod async_pointer {
253    pub const OP_GET_OR_FETCH: u16 = 1;
254    pub const OP_TRY_GET: u16 = 2;
255}
256
257/// Op kinds for [`SharedUmbraPointer`](crate::SharedUmbraPointer).
258pub mod umbra_pointer {
259    pub const OP_PREFIX_EQ: u16 = 1;
260    pub const OP_RESOLVE: u16 = 2;
261}
262
263/// Op kinds for [`KTowerCascade`](crate::KTowerCascade) cascade resolvers.
264pub mod cascade {
265    pub const OP_INSERT: u16 = 1;
266    pub const OP_GET: u16 = 2;
267}
268
269/// Op kinds for the ordering layer of
270/// [`AdaptiveRing`](crate::AdaptiveRing): one observation per
271/// cross-producer inversion detected at pop. The sidecar's drain
272/// folds these into the per-instance op counts, giving policies the
273/// inversion rate that justifies (or kills) the stamped-merge mode
274/// with data.
275pub mod ordering {
276    pub const OP_ORDER_INVERSION: u16 = 1;
277}