diff --git a/crates/coremem/src/driver.rs b/crates/coremem/src/driver.rs index e0e72da..92ab114 100644 --- a/crates/coremem/src/driver.rs +++ b/crates/coremem/src/driver.rs @@ -277,7 +277,7 @@ where trace!("step begin"); self.diag.instrument_step(steps_this_time as u64, || { - self.state.step_multiple(steps_this_time, &stim); + self.state.step_multiple(steps_this_time, &*stim); }); trace!("step end"); @@ -451,9 +451,11 @@ struct StimAccess { /// A.K.A. "can i safely do a blocking recv on response_channel". outstanding: Cell, /// data sent from worker thread back to the Driver side. + /// XXX: Boxing isn't necessary, but doing so means much less memcopy'ing over the channel + /// (just one pointer, instead of N^3 bytes). better for perf. response_channel: ( - SyncSender<(SimMeta, u64, RenderedStimulus)>, - Receiver<(SimMeta, u64, RenderedStimulus)>, + SyncSender<(SimMeta, u64, Box>)>, + Receiver<(SimMeta, u64, Box>)>, ), worker: ThreadPool, } @@ -483,7 +485,7 @@ impl StimAccess { /// waits for an outstanding job (if any). /// if the response matches the request, return the response, /// else discard the response. - fn maybe_wait_for_job(&self, meta: SimMeta, step: u64) -> Option> { + fn maybe_wait_for_job(&self, meta: SimMeta, step: u64) -> Option>> { if !self.outstanding.get() { return None; } @@ -501,7 +503,7 @@ impl StimAccess { } impl + Send + 'static> StimAccess { - fn get_for(&self, meta: SimMeta, step: u64) -> RenderedStimulus { + fn get_for(&self, meta: SimMeta, step: u64) -> Box> { // either claim the outstanding job (if it exists and matches)... self.maybe_wait_for_job(meta, step).unwrap_or_else(|| { // or start a job and wait for it to complete inline @@ -525,13 +527,13 @@ impl + Send + 'static> StimAccess { let rendered = diag.instrument_stimuli(|| { let stim = stim.lock().unwrap(); let opt = stim.optimized_for(meta, step); - opt.as_ref().rendered( + Box::new(opt.as_ref().rendered( meta.time_step().cast(), // TODO: convert this to an integer meta.time_step().cast::() * R::from_primitive(step), meta.feature_size().cast(), meta.dim() - ).into_owned() + ).into_owned()) //^ this 'into_owned' ought to be a no-op. //^ it would only ever be borrowed if we accidentally called `rendered` twice. });