Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions crates/runner-shared/src/artifacts/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use std::io::BufReader;

use libc::pid_t;
use log::debug;
use serde::Serialize;
use serde::{Deserialize, Serialize};

mod execution_timestamps;
mod memtrack;
Expand All @@ -10,7 +12,7 @@ pub use memtrack::*;

pub trait ArtifactExt
where
Self: Sized + Serialize,
Self: Sized + Serialize + for<'de> Deserialize<'de>,
{
/// WARNING: This doesn't support generic types
fn name() -> &'static str {
Expand All @@ -25,6 +27,11 @@ where
}
}

fn decode_from_reader<R: std::io::Read>(reader: R) -> anyhow::Result<Self> {
let reader = BufReader::new(reader);
rmp_serde::from_read(reader).map_err(anyhow::Error::from)
}

fn encode_to_writer<W: std::io::Write>(&self, mut writer: W) -> anyhow::Result<()> {
let encoded = rmp_serde::to_vec_named(self)?;
writer.write_all(&encoded)?;
Expand Down
27 changes: 13 additions & 14 deletions src/executor/memory/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use async_trait::async_trait;
use ipc_channel::ipc;
use memtrack::MemtrackIpcClient;
use memtrack::MemtrackIpcServer;
use runner_shared::artifacts::{ArtifactExt, ExecutionTimestamps, MemtrackArtifact};
use runner_shared::artifacts::{ArtifactExt, ExecutionTimestamps};
use runner_shared::fifo::Command as FifoCommand;
use runner_shared::fifo::IntegrationMode;
use semver::Version;
Expand Down Expand Up @@ -121,28 +121,27 @@ impl Executor for MemoryExecutor {
}

async fn teardown(&self, execution_context: &ExecutionContext) -> Result<()> {
let files: Vec<_> = std::fs::read_dir(execution_context.profile_folder.join("results"))?
let results_dir = execution_context.profile_folder.join("results");
let has_benchmarks = std::fs::read_dir(&results_dir)?
.filter_map(Result::ok)
// Filter out non-memtrack files:
// Filter out non-ExecutionTimestamps files:
.filter(|entry| {
entry
.file_name()
.to_string_lossy()
.contains(MemtrackArtifact::name())
.contains(ExecutionTimestamps::name())
})
.flat_map(|f| std::fs::File::open(f.path()))
.filter(|file| !MemtrackArtifact::is_empty(file))
.collect();
.filter_map(|entry| {
let file = std::fs::File::open(entry.path()).ok()?;
ExecutionTimestamps::decode_from_reader(file).ok()
})
.any(|artifact| !artifact.uri_by_ts.is_empty());

if files.is_empty() {
if !has_benchmarks {
if !execution_context.config.allow_empty {
bail!(
"No memtrack artifact files found. Does the integration support memory profiling?"
);
bail!("No memory results found in profile folder: {results_dir:?}.");
} else {
info!(
"No memtrack artifact files found. Does the integration support memory profiling?"
);
info!("No memory results found in profile folder: {results_dir:?}.");
}
}

Expand Down
Loading