Compute heartbeat interval with ±100ms jitter. Returns a Duration in the range [900ms, 1100ms]. The jitter spreads heartbeat emissions across cores so they don't all fire in the same poll iteration when the system goes idle. Uses a fast splitmix64-style hash of the current timestamp nanos to produce pseudo-random jitter without requiring the `rand` crate in production code (it's dev-only).
()
| 414 | /// produce pseudo-random jitter without requiring the `rand` crate in |
| 415 | /// production code (it's dev-only). |
| 416 | fn heartbeat_interval_with_jitter() -> std::time::Duration { |
| 417 | let seed = std::time::SystemTime::now() |
| 418 | .duration_since(std::time::UNIX_EPOCH) |
| 419 | .unwrap_or_default() |
| 420 | .as_nanos() as u64; |
| 421 | // splitmix64 |
| 422 | let mut x = seed; |
| 423 | x ^= x >> 30; |
| 424 | x = x.wrapping_mul(0xbf58476d1ce4e5b9); |
| 425 | x ^= x >> 27; |
| 426 | // Map to [0, 200] → offset by -100 → [-100, +100] ms. |
| 427 | let jitter_ms = (x % 201) as i64 - 100; |
| 428 | std::time::Duration::from_millis((1000 + jitter_ms) as u64) |
| 429 | } |
| 430 | |
| 431 | /// Extract a human-readable message from a panic payload. |
| 432 | fn panic_message(payload: &Box<dyn std::any::Any + Send>) -> String { |
no test coverage detected