rate-limit UserStats + tolerate pending notifications for 1ms

This commit is contained in:
Alwin Berger 2024-11-10 10:21:36 +01:00
parent 280025b505
commit b7710c7d8a
2 changed files with 3 additions and 3 deletions

View File

@ -421,8 +421,8 @@ fn get_release_response_pairs(rel: &Vec<(u64, String)>, resp: &Vec<(u64, String)
} }
} else { } else {
if let Some(lr) = last_response.get(&next_resp.1) { if let Some(lr) = last_response.get(&next_resp.1) {
if u128::abs_diff(crate::time::clock::tick_to_time(next_resp.0).as_micros(), crate::time::clock::tick_to_time(*lr).as_micros()) > 500 { // tolerate pending notifications for 500us if u128::abs_diff(crate::time::clock::tick_to_time(next_resp.0).as_micros(), crate::time::clock::tick_to_time(*lr).as_micros()) > 1000 { // tolerate pending notifications for 1ms
maybe_error = true; // maybe_error = true;
// eprintln!("Task {} response at {:.1}ms not found in ready list. Fallback to last response at {:.1}ms.", next_resp.1, crate::time::clock::tick_to_time(next_resp.0).as_micros() as f32/1000.0, crate::time::clock::tick_to_time(*lr).as_micros() as f32/1000.0); // eprintln!("Task {} response at {:.1}ms not found in ready list. Fallback to last response at {:.1}ms.", next_resp.1, crate::time::clock::tick_to_time(next_resp.0).as_micros() as f32/1000.0, crate::time::clock::tick_to_time(*lr).as_micros() as f32/1000.0);
} }
// Sometimes a task is released immediately after a response (e.g. pending notification). This might not be detected. // Sometimes a task is released immediately after a response (e.g. pending notification). This might not be detected.

View File

@ -468,7 +468,7 @@ impl Monitor for RateLimitedMonitor {
fn display(&mut self, event_msg: &str, sender_id: ClientId) { fn display(&mut self, event_msg: &str, sender_id: ClientId) {
let now = Instant::now(); let now = Instant::now();
const RATE : Duration = Duration::from_secs(5); const RATE : Duration = Duration::from_secs(5);
if event_msg!="Testcase" || now.duration_since(self.last) > RATE { if (event_msg!="Testcase" && event_msg!="UserStats") || now.duration_since(self.last) > RATE {
self.inner.display(event_msg, sender_id); self.inner.display(event_msg, sender_id);
self.last = now; self.last = now;
} }