Skip to content

Commit

Permalink
Some more event log recorder improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
juntyr committed Jun 1, 2024
1 parent e6e9654 commit f2c632c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 26 deletions.
22 changes: 2 additions & 20 deletions necsim/impls/std/src/event_log/recorder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
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<Self> {
pub fn new_child_log(&self, child: &str) -> Result<Self> {
Self::check_valid_component(child)?;

Self {
Expand Down
8 changes: 4 additions & 4 deletions necsim/partitioning/mpi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
)))
Expand All @@ -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,
)))
Expand Down
4 changes: 2 additions & 2 deletions necsim/partitioning/threads/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl Partitioning for ThreadsPartitioning {
fold: fn(Q, Q) -> Q,
) -> anyhow::Result<Q> {
// 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)
};

Expand Down Expand Up @@ -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::<Result<Vec<_>, _>>()?;
Expand Down

0 comments on commit f2c632c

Please sign in to comment.