Compile Meilisearch or run the dedicated binary file

This commit is contained in:
Kerollmops 2024-12-11 14:57:07 +01:00
parent f8ba112f66
commit 04a62d2b97
No known key found for this signature in database
GPG Key ID: F250A4C4E3AE5F5F
3 changed files with 28 additions and 13 deletions

View File

@ -37,17 +37,8 @@ pub async fn start(
master_key: Option<&str>,
workload: &Workload,
asset_folder: &str,
mut command: tokio::process::Command,
) -> anyhow::Result<tokio::process::Child> {
let mut command = tokio::process::Command::new("cargo");
command
.arg("run")
.arg("--release")
.arg("-p")
.arg("meilisearch")
.arg("--bin")
.arg("meilisearch")
.arg("--");
command.arg("--db-path").arg("./_xtask_benchmark.ms");
if let Some(master_key) = master_key {
command.arg("--master-key").arg(master_key);

View File

@ -86,6 +86,10 @@ pub struct BenchDeriveArgs {
/// The maximum time in seconds we allow for fetching the task queue before timing out.
#[arg(long, default_value_t = 60)]
tasks_queue_timeout_secs: u64,
/// The path to the binary to run. By default it compiles the binary with cargo.
#[arg(long)]
binary_path: Option<PathBuf>,
}
pub fn run(args: BenchDeriveArgs) -> anyhow::Result<()> {
@ -170,6 +174,7 @@ pub fn run(args: BenchDeriveArgs) -> anyhow::Result<()> {
args.master_key.as_deref(),
workload,
&args,
args.binary_path.as_deref(),
)
.await?;

View File

@ -1,6 +1,7 @@
use std::collections::BTreeMap;
use std::fs::File;
use std::io::{Seek as _, Write as _};
use std::path::Path;
use anyhow::{bail, Context as _};
use futures_util::TryStreamExt as _;
@ -85,14 +86,30 @@ pub async fn execute(
master_key: Option<&str>,
workload: Workload,
args: &BenchDeriveArgs,
binary_path: Option<&Path>,
) -> anyhow::Result<()> {
assets::fetch_assets(assets_client, &workload.assets, &args.asset_folder).await?;
let workload_uuid = dashboard_client.create_workload(invocation_uuid, &workload).await?;
let mut tasks = Vec::new();
for i in 0..workload.run_count {
let run_command = match binary_path {
Some(binary_path) => tokio::process::Command::new(binary_path),
None => {
let mut command = tokio::process::Command::new("cargo");
command
.arg("run")
.arg("--release")
.arg("-p")
.arg("meilisearch")
.arg("--bin")
.arg("meilisearch")
.arg("--");
command
}
};
tasks.push(
execute_run(
dashboard_client,
@ -102,6 +119,7 @@ pub async fn execute(
master_key,
&workload,
args,
run_command,
i,
)
.await?,
@ -109,7 +127,6 @@ pub async fn execute(
}
let mut reports = Vec::with_capacity(workload.run_count as usize);
for task in tasks {
reports.push(
task.await
@ -133,13 +150,15 @@ async fn execute_run(
master_key: Option<&str>,
workload: &Workload,
args: &BenchDeriveArgs,
run_command: tokio::process::Command,
run_number: u16,
) -> anyhow::Result<tokio::task::JoinHandle<anyhow::Result<std::fs::File>>> {
meili_process::delete_db();
meili_process::build().await?;
let meilisearch =
meili_process::start(meili_client, master_key, workload, &args.asset_folder).await?;
meili_process::start(meili_client, master_key, workload, &args.asset_folder, run_command)
.await?;
let processor = run_commands(
dashboard_client,