RFC 016 Chunk 2b: per-actor messages-received counter
Tally each dequeued message against the receiving actor, surfaced as
ActorInfo.messages_received (the 'is this actor draining slower than its
mailbox fills' signal).
- messages-received, not sent (D4): the receiver counts on its own
thread, so it's a single-writer Relaxed load+store on a hot Slot
AtomicU64, no atomic RMW (D5); reuses the stashed *const Slot from 2a.
- Incremented at all six channel dequeue-success sites (recv,
recv_timeout x2, recv_match, try_recv_match, try_recv) via
preempt::note_message_received; no-op outside an actor (null slot).
- Resets with overruns in reset_counters across the three lifecycle
sites (D7).
Matrix: debug default + rq-mpmc + rq-striped + release green; loom
slot_state/run_queue models pass (the 3 send_after_to loom failures are
pre-existing at fc014c4 — plain #[test]s under --cfg loom, not Chunk 2).
This commit is contained in:
@@ -235,6 +235,7 @@ fn tree_from_nests_children_and_reroots_orphans() {
|
||||
joiners: 0,
|
||||
mailbox_depth: 0,
|
||||
overruns: 0,
|
||||
messages_received: 0,
|
||||
};
|
||||
|
||||
let snap = RuntimeSnapshot {
|
||||
@@ -286,3 +287,37 @@ fn overrun_count_increments_on_forced_preemption() {
|
||||
h.join().unwrap();
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn messages_received_counts_dequeues() {
|
||||
const MQ: Name<u64> = Name::new("mq");
|
||||
const N: u64 = 5;
|
||||
run(|| {
|
||||
let (ready_tx, ready_rx) = channel::<()>();
|
||||
let (done_tx, done_rx) = channel::<()>();
|
||||
let (gate_tx, gate_rx) = channel::<()>();
|
||||
let (cmd_tx, cmd_rx) = channel::<u64>();
|
||||
|
||||
let h = spawn(move || {
|
||||
register(MQ, cmd_tx).unwrap();
|
||||
ready_tx.send(()).unwrap(); // sends don't count toward received
|
||||
for _ in 0..N {
|
||||
cmd_rx.recv().unwrap(); // each dequeue tallies one
|
||||
}
|
||||
done_tx.send(()).unwrap();
|
||||
gate_rx.recv().unwrap(); // happens only after we've checked
|
||||
});
|
||||
ready_rx.recv().unwrap();
|
||||
|
||||
for i in 0..N {
|
||||
send(MQ, i).unwrap();
|
||||
}
|
||||
done_rx.recv().unwrap(); // worker has drained all N
|
||||
|
||||
let info = actor_info(h.pid()).expect("worker present");
|
||||
assert_eq!(info.messages_received, N, "one tally per dequeued message");
|
||||
|
||||
gate_tx.send(()).unwrap();
|
||||
h.join().unwrap();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user