Prepare bench repo implementation

This commit is contained in:
Joscha 2024-05-13 20:43:22 +02:00
parent 5d28a2f04a
commit 85aef26340
5 changed files with 32 additions and 23 deletions

View file

@ -89,7 +89,7 @@ impl Worker {
let Some(run) = self.request_run(server).await else { let Some(run) = self.request_run(server).await else {
return false; return false;
}; };
let run = RunInProgress::new(server.name.clone(), server.server_config, run); let run = RunInProgress::new(server.name.clone(), run);
*server.current_run.lock().unwrap() = Some(run.clone()); *server.current_run.lock().unwrap() = Some(run.clone());
drop(guard); drop(guard);

View file

@ -1,4 +1,5 @@
mod internal; mod internal;
mod repo;
use std::{ use std::{
collections::HashMap, collections::HashMap,
@ -9,9 +10,9 @@ use log::{error, warn};
use tokio::{select, sync::Notify}; use tokio::{select, sync::Notify};
use crate::{ use crate::{
config::WorkerServerConfig,
primitive::Source, primitive::Source,
shared::{BenchMethod, FinishedRun, Measurement, Run, UnfinishedRun}, shared::{BenchMethod, FinishedRun, Measurement, Run, UnfinishedRun},
somehow,
}; };
use super::server::Server; use super::server::Server;
@ -26,17 +27,15 @@ const SCROLLBACK: usize = 50;
#[derive(Clone)] #[derive(Clone)]
pub struct RunInProgress { pub struct RunInProgress {
server_name: String, server_name: String,
server_config: &'static WorkerServerConfig,
run: Run, run: Run,
output: Arc<Mutex<Vec<(Source, String)>>>, output: Arc<Mutex<Vec<(Source, String)>>>,
abort: Arc<Notify>, abort: Arc<Notify>,
} }
impl RunInProgress { impl RunInProgress {
pub fn new(server_name: String, server_config: &'static WorkerServerConfig, run: Run) -> Self { pub fn new(server_name: String, run: Run) -> Self {
Self { Self {
server_name, server_name,
server_config,
run, run,
output: Arc::new(Mutex::new(vec![])), output: Arc::new(Mutex::new(vec![])),
abort: Arc::new(Notify::new()), abort: Arc::new(Notify::new()),
@ -80,16 +79,18 @@ impl RunInProgress {
self.output.lock().unwrap().push((Source::Stderr, line)); self.output.lock().unwrap().push((Source::Stderr, line));
} }
async fn execute_bench_method(&self, server: &Server) -> somehow::Result<Option<Finished>> {
match &self.run.bench_method {
BenchMethod::Internal => self.execute_internal(server).await,
BenchMethod::Repo { hash } => self.execute_repo(server, hash).await,
}
}
pub async fn perform(&self, server: &Server) -> Option<FinishedRun> { pub async fn perform(&self, server: &Server) -> Option<FinishedRun> {
// TODO Log system info // TODO Log system info
let run_future = match &self.run.bench_method {
BenchMethod::Internal => self.perform_internal(server),
BenchMethod::Repo { hash } => todo!(),
};
let result = select! { let result = select! {
result = run_future => result, result = self.execute_bench_method(server) => result,
_ = self.abort.notified() => { _ = self.abort.notified() => {
warn!("Run for {} was aborted", server.name); warn!("Run for {} was aborted", server.name);
Ok(None) Ok(None)

View file

@ -153,7 +153,7 @@ fn measurements(counts: Counts) -> HashMap<String, Measurement> {
} }
impl RunInProgress { impl RunInProgress {
pub(super) async fn perform_internal( pub(super) async fn execute_internal(
&self, &self,
server: &Server, server: &Server,
) -> somehow::Result<Option<Finished>> { ) -> somehow::Result<Option<Finished>> {

View file

@ -1,15 +1,19 @@
use std::sync::{Arc, Mutex}; use crate::{somehow, worker::server::Server};
use tokio::sync::mpsc; use super::{Finished, RunInProgress};
use crate::somehow; impl RunInProgress {
pub(super) async fn execute_repo(
&self,
server: &Server,
hash: &str,
) -> somehow::Result<Option<Finished>> {
// TODO Design bench repo specification (benchmark, compare)
// TODO Decide on better name? "benchmark repo", "bench repo", "eval repo"?
// TODO Implement specification
let repo_dir = server.download_repo(&self.run.hash).await?;
let bench_repo_dir = server.download_bench_repo(hash).await?;
use super::{Run, RunStatus}; todo!()
}
pub async fn run(
run: Arc<Mutex<Run>>,
hash: String,
abort_rx: mpsc::UnboundedReceiver<()>,
) -> somehow::Result<RunStatus> {
todo!()
} }

View file

@ -98,6 +98,8 @@ impl Server {
}, },
); );
debug!("Downloading repo from {url}");
let response = self let response = self
.client .client
.get(url) .get(url)
@ -117,6 +119,8 @@ impl Server {
}, },
); );
debug!("Downloading bench repo from {url}");
let response = self let response = self
.client .client
.get(url) .get(url)