From 6cb75b7a9e3b060cb17a666d78c9529d43a68a9b Mon Sep 17 00:00:00 2001 From: ps-cd <45522676+ps-cd@users.noreply.github.com> Date: Mon, 31 Mar 2025 16:19:03 -0400 Subject: [PATCH 1/3] [In-stream loop] Padding to match run time between cards --- src/streamer.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/streamer.rs b/src/streamer.rs index 80d2e12..6287b0b 100644 --- a/src/streamer.rs +++ b/src/streamer.rs @@ -188,6 +188,29 @@ pub trait BaseStreamer { .unwrap() } + fn longest_dev_run_time(&self) -> f64 { + // Sanity checks: + /* @Backend developers: before trying to access compile cache + you should always ensure the streamer actually got some instructions + and that compile cache is valid (up-to-date with the current edit cache). + Compile cache typically gets invalid due to users forgetting to re-compile after adding pulses. + + Functions `got_instructions()` and `validate_compile_cache()` are meant to be the place + to do these checks gracefully. Other functions typically assume these checks have been done. + They likely still double check but may just panic if the tests fail like in the example below. + */ + if !self.got_instructions() { + panic!("Streamer did not get any instructions") + } + self.validate_compile_cache().unwrap(); + + self.active_devs() + .iter() + .map(|dev| dev.tag_compiled_stop_time()) + .reduce(|longest_so_far, this| f64::max(longest_so_far, this)) + .unwrap() + } + fn add_reset_instr(&mut self, reset_time: Option) -> Result<(), String> { let reset_time = match reset_time { Some(reset_time) => { From d1a95af6f0c47e35e5452883b204a4de00f1b9ff Mon Sep 17 00:00:00 2001 From: ps-cd <45522676+ps-cd@users.noreply.github.com> Date: Mon, 31 Mar 2025 16:30:04 -0400 Subject: [PATCH 2/3] [In-stream loop] `BaseStreamer`: Renamed `total_run_time` to `shortest_dev_run_time` --- src/streamer.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/streamer.rs b/src/streamer.rs index 6287b0b..2078118 100644 --- a/src/streamer.rs +++ b/src/streamer.rs @@ -119,7 +119,7 @@ pub trait BaseStreamer { dev.tag_compile(stop_time)?; } - Ok(self.total_run_time()) + Ok(self.shortest_dev_run_time()) } fn clear_compile_cache(&mut self) { @@ -165,7 +165,7 @@ pub trait BaseStreamer { Ok(()) } - fn total_run_time(&self) -> f64 { + fn shortest_dev_run_time(&self) -> f64 { // Sanity checks: /* @Backend developers: before trying to access compile cache you should always ensure the streamer actually got some instructions From dd58e0e73a69cac44c64ed52d8fa612f233bc1e4 Mon Sep 17 00:00:00 2001 From: ps-cd <45522676+ps-cd@users.noreply.github.com> Date: Mon, 14 Apr 2025 18:22:00 -0400 Subject: [PATCH 3/3] [In-stream loop] Manager thread draft - moved `chunksize_ms` to settings, moved enum match for `worker_loop` to `impl NIDev`, moved `active_dev_names` to `BaseStreamer` --- src/streamer.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/streamer.rs b/src/streamer.rs index 2078118..1a8839d 100644 --- a/src/streamer.rs +++ b/src/streamer.rs @@ -97,6 +97,13 @@ pub trait BaseStreamer { .collect() } + fn active_dev_names(&self) -> Vec { + self.active_devs() + .iter() + .map(|dev| dev.tag_name()) + .collect() + } + fn compile(&mut self, stop_time: Option) -> Result { if !self.got_instructions() { return Err(format!("Streamer did not get any instructions"))