Improve gateway scheduling and runtime admission

This commit is contained in:
elky
2026-06-24 01:53:45 +08:00
parent cf0af8fa1e
commit d336d1a7fa
87 changed files with 9671 additions and 804 deletions
+9
View File
@@ -1,5 +1,8 @@
use std::sync::atomic::{AtomicU64, Ordering};
use std::time::{SystemTime, UNIX_EPOCH};
static REQUEST_DISTRIBUTION_COUNTER: AtomicU64 = AtomicU64::new(0);
pub(crate) fn current_unix_secs() -> u64 {
SystemTime::now()
.duration_since(UNIX_EPOCH)
@@ -13,3 +16,9 @@ pub(crate) fn current_unix_ms() -> u64 {
.unwrap_or_default()
.as_millis() as u64
}
pub(crate) fn request_distribution_seed() -> u64 {
let now_ms = current_unix_ms();
let counter = REQUEST_DISTRIBUTION_COUNTER.fetch_add(1, Ordering::Relaxed);
now_ms.rotate_left(21) ^ counter
}