From f2c632cf4182cf63531e7459887f1e9695f862e3 Mon Sep 17 00:00:00 2001 From: Juniper Tyree Date: Sat, 1 Jun 2024 08:08:57 +0000 Subject: [PATCH] Some more event log recorder improvements --- necsim/impls/std/src/event_log/recorder.rs | 22 ++-------------------- necsim/partitioning/mpi/src/lib.rs | 8 ++++---- necsim/partitioning/threads/src/lib.rs | 4 ++-- 3 files changed, 8 insertions(+), 26 deletions(-) diff --git a/necsim/impls/std/src/event_log/recorder.rs b/necsim/impls/std/src/event_log/recorder.rs index a498432d8..828bfdbec 100644 --- a/necsim/impls/std/src/event_log/recorder.rs +++ b/necsim/impls/std/src/event_log/recorder.rs @@ -100,27 +100,9 @@ impl EventLogRecorder { /// # Errors /// /// Fails to construct iff - /// - `suffix` is not a valid single-component path + /// - `child` is not a valid single-component path /// - newly creating a writable child directory fails - pub fn into_sublog(mut self, child: &str) -> Result { - Self::check_valid_component(child)?; - - if !self.buffer.is_empty() { - self.sort_and_write_segment()?; - } - - self.directory.push(child); - self.segment_index = 0; - - self.create_valid_directory() - } - - /// # Errors - /// - /// Fails to construct iff - /// - `suffix` is not a valid single-component path - /// - newly creating a writable child directory fails - pub fn sublog(&mut self, child: &str) -> Result { + pub fn new_child_log(&self, child: &str) -> Result { Self::check_valid_component(child)?; Self { diff --git a/necsim/partitioning/mpi/src/lib.rs b/necsim/partitioning/mpi/src/lib.rs index 0ba9a10bc..d4a4259e1 100644 --- a/necsim/partitioning/mpi/src/lib.rs +++ b/necsim/partitioning/mpi/src/lib.rs @@ -190,8 +190,8 @@ impl Partitioning for MpiPartitioning { anyhow::bail!(MpiLocalPartitionError::MissingEventLog) }; - let event_log = event_log - .into_sublog(&self.world.rank().to_string()) + let partition_event_log = event_log + .new_child_log(&self.world.rank().to_string()) .context(MpiLocalPartitionError::InvalidEventSubLog)?; let mut mpi_local_global_wait = (false, false); @@ -220,7 +220,7 @@ impl Partitioning for MpiPartitioning { mpi_local_global_wait, mpi_emigration_buffers, reporter_context.try_build()?, - event_log, + partition_event_log, self.migration_interval, self.progress_interval, ))) @@ -230,7 +230,7 @@ impl Partitioning for MpiPartitioning { mpi_local_global_wait, mpi_local_remaining, mpi_emigration_buffers, - event_log, + partition_event_log, self.migration_interval, self.progress_interval, ))) diff --git a/necsim/partitioning/threads/src/lib.rs b/necsim/partitioning/threads/src/lib.rs index 2f9bc9ef0..c5bd442a2 100644 --- a/necsim/partitioning/threads/src/lib.rs +++ b/necsim/partitioning/threads/src/lib.rs @@ -149,7 +149,7 @@ impl Partitioning for ThreadsPartitioning { fold: fn(Q, Q) -> Q, ) -> anyhow::Result { // TODO: add support for multithread live reporting - let Some(mut event_log) = event_log else { + let Some(event_log) = event_log else { anyhow::bail!(ThreadsLocalPartitionError::MissingEventLog) }; @@ -180,7 +180,7 @@ impl Partitioning for ThreadsPartitioning { .partitions() .map(|partition| { event_log - .sublog(&partition.rank().to_string()) + .new_child_log(&partition.rank().to_string()) .context(ThreadsLocalPartitionError::InvalidEventSubLog) }) .collect::, _>>()?;