mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-01-12 14:27:28 +01:00
Compile Meilisearch or run the dedicated binary file
This commit is contained in:
parent
f8ba112f66
commit
04a62d2b97
@ -37,17 +37,8 @@ pub async fn start(
|
|||||||
master_key: Option<&str>,
|
master_key: Option<&str>,
|
||||||
workload: &Workload,
|
workload: &Workload,
|
||||||
asset_folder: &str,
|
asset_folder: &str,
|
||||||
|
mut command: tokio::process::Command,
|
||||||
) -> anyhow::Result<tokio::process::Child> {
|
) -> 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");
|
command.arg("--db-path").arg("./_xtask_benchmark.ms");
|
||||||
if let Some(master_key) = master_key {
|
if let Some(master_key) = master_key {
|
||||||
command.arg("--master-key").arg(master_key);
|
command.arg("--master-key").arg(master_key);
|
||||||
|
@ -86,6 +86,10 @@ pub struct BenchDeriveArgs {
|
|||||||
/// The maximum time in seconds we allow for fetching the task queue before timing out.
|
/// The maximum time in seconds we allow for fetching the task queue before timing out.
|
||||||
#[arg(long, default_value_t = 60)]
|
#[arg(long, default_value_t = 60)]
|
||||||
tasks_queue_timeout_secs: u64,
|
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<()> {
|
pub fn run(args: BenchDeriveArgs) -> anyhow::Result<()> {
|
||||||
@ -170,6 +174,7 @@ pub fn run(args: BenchDeriveArgs) -> anyhow::Result<()> {
|
|||||||
args.master_key.as_deref(),
|
args.master_key.as_deref(),
|
||||||
workload,
|
workload,
|
||||||
&args,
|
&args,
|
||||||
|
args.binary_path.as_deref(),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{Seek as _, Write as _};
|
use std::io::{Seek as _, Write as _};
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
use anyhow::{bail, Context as _};
|
use anyhow::{bail, Context as _};
|
||||||
use futures_util::TryStreamExt as _;
|
use futures_util::TryStreamExt as _;
|
||||||
@ -85,14 +86,30 @@ pub async fn execute(
|
|||||||
master_key: Option<&str>,
|
master_key: Option<&str>,
|
||||||
workload: Workload,
|
workload: Workload,
|
||||||
args: &BenchDeriveArgs,
|
args: &BenchDeriveArgs,
|
||||||
|
binary_path: Option<&Path>,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
assets::fetch_assets(assets_client, &workload.assets, &args.asset_folder).await?;
|
assets::fetch_assets(assets_client, &workload.assets, &args.asset_folder).await?;
|
||||||
|
|
||||||
let workload_uuid = dashboard_client.create_workload(invocation_uuid, &workload).await?;
|
let workload_uuid = dashboard_client.create_workload(invocation_uuid, &workload).await?;
|
||||||
|
|
||||||
let mut tasks = Vec::new();
|
let mut tasks = Vec::new();
|
||||||
|
|
||||||
for i in 0..workload.run_count {
|
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(
|
tasks.push(
|
||||||
execute_run(
|
execute_run(
|
||||||
dashboard_client,
|
dashboard_client,
|
||||||
@ -102,6 +119,7 @@ pub async fn execute(
|
|||||||
master_key,
|
master_key,
|
||||||
&workload,
|
&workload,
|
||||||
args,
|
args,
|
||||||
|
run_command,
|
||||||
i,
|
i,
|
||||||
)
|
)
|
||||||
.await?,
|
.await?,
|
||||||
@ -109,7 +127,6 @@ pub async fn execute(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut reports = Vec::with_capacity(workload.run_count as usize);
|
let mut reports = Vec::with_capacity(workload.run_count as usize);
|
||||||
|
|
||||||
for task in tasks {
|
for task in tasks {
|
||||||
reports.push(
|
reports.push(
|
||||||
task.await
|
task.await
|
||||||
@ -133,13 +150,15 @@ async fn execute_run(
|
|||||||
master_key: Option<&str>,
|
master_key: Option<&str>,
|
||||||
workload: &Workload,
|
workload: &Workload,
|
||||||
args: &BenchDeriveArgs,
|
args: &BenchDeriveArgs,
|
||||||
|
run_command: tokio::process::Command,
|
||||||
run_number: u16,
|
run_number: u16,
|
||||||
) -> anyhow::Result<tokio::task::JoinHandle<anyhow::Result<std::fs::File>>> {
|
) -> anyhow::Result<tokio::task::JoinHandle<anyhow::Result<std::fs::File>>> {
|
||||||
meili_process::delete_db();
|
meili_process::delete_db();
|
||||||
|
|
||||||
meili_process::build().await?;
|
meili_process::build().await?;
|
||||||
let meilisearch =
|
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(
|
let processor = run_commands(
|
||||||
dashboard_client,
|
dashboard_client,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user