mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-25 03:25:06 +08:00
Add cargo xtask bench
This commit is contained in:
parent
b11df7ec34
commit
86ce843f3d
57
Cargo.lock
generated
57
Cargo.lock
generated
@ -440,6 +440,12 @@ dependencies = [
|
|||||||
"syn 2.0.48",
|
"syn 2.0.48",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "atomic"
|
||||||
|
version = "0.5.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c59bdb34bc650a32731b31bd8f0829cc15d24a708ee31559e0bb34f2bc320cba"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "atomic-polyfill"
|
name = "atomic-polyfill"
|
||||||
version = "0.1.11"
|
version = "0.1.11"
|
||||||
@ -3488,6 +3494,12 @@ dependencies = [
|
|||||||
"num-traits",
|
"num-traits",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-conv"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-integer"
|
name = "num-integer"
|
||||||
version = "0.1.45"
|
version = "0.1.45"
|
||||||
@ -4218,10 +4230,12 @@ dependencies = [
|
|||||||
"system-configuration",
|
"system-configuration",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-rustls 0.24.1",
|
"tokio-rustls 0.24.1",
|
||||||
|
"tokio-util",
|
||||||
"tower-service",
|
"tower-service",
|
||||||
"url",
|
"url",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
"wasm-bindgen-futures",
|
"wasm-bindgen-futures",
|
||||||
|
"wasm-streams",
|
||||||
"web-sys",
|
"web-sys",
|
||||||
"webpki-roots 0.25.3",
|
"webpki-roots 0.25.3",
|
||||||
"winreg",
|
"winreg",
|
||||||
@ -4934,12 +4948,13 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "time"
|
name = "time"
|
||||||
version = "0.3.31"
|
version = "0.3.32"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e"
|
checksum = "fe80ced77cbfb4cb91a94bf72b378b4b6791a0d9b7f09d0be747d1bdff4e68bd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"deranged",
|
"deranged",
|
||||||
"itoa",
|
"itoa",
|
||||||
|
"num-conv",
|
||||||
"powerfmt",
|
"powerfmt",
|
||||||
"serde",
|
"serde",
|
||||||
"time-core",
|
"time-core",
|
||||||
@ -4954,10 +4969,11 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "time-macros"
|
name = "time-macros"
|
||||||
version = "0.2.16"
|
version = "0.2.17"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "26197e33420244aeb70c3e8c78376ca46571bc4e701e4791c2cd9f57dcb3a43f"
|
checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"num-conv",
|
||||||
"time-core",
|
"time-core",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -5395,10 +5411,11 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uuid"
|
name = "uuid"
|
||||||
version = "1.6.1"
|
version = "1.7.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560"
|
checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"atomic",
|
||||||
"getrandom",
|
"getrandom",
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
@ -5539,6 +5556,19 @@ version = "0.2.87"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1"
|
checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-streams"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b4609d447824375f43e1ffbc051b50ad8f4b3ae8219680c94452ea05eb240ac7"
|
||||||
|
dependencies = [
|
||||||
|
"futures-util",
|
||||||
|
"js-sys",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"wasm-bindgen-futures",
|
||||||
|
"web-sys",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wav"
|
name = "wav"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
@ -5873,8 +5903,23 @@ dependencies = [
|
|||||||
name = "xtask"
|
name = "xtask"
|
||||||
version = "1.7.0"
|
version = "1.7.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
"cargo_metadata",
|
"cargo_metadata",
|
||||||
"clap",
|
"clap",
|
||||||
|
"futures-core",
|
||||||
|
"futures-util",
|
||||||
|
"git2",
|
||||||
|
"reqwest",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"sha2",
|
||||||
|
"sysinfo",
|
||||||
|
"time",
|
||||||
|
"tokio",
|
||||||
|
"tracing",
|
||||||
|
"tracing-subscriber",
|
||||||
|
"tracing-trace",
|
||||||
|
"uuid",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -11,5 +11,30 @@ license.workspace = true
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
anyhow = "1.0.79"
|
||||||
cargo_metadata = "0.18.1"
|
cargo_metadata = "0.18.1"
|
||||||
clap = { version = "4.4.14", features = ["derive"] }
|
clap = { version = "4.4.14", features = ["derive"] }
|
||||||
|
futures-core = "0.3.30"
|
||||||
|
futures-util = "0.3.30"
|
||||||
|
git2 = { version = "0.16", default_features = false }
|
||||||
|
reqwest = { version = "0.11.23", features = [
|
||||||
|
"stream",
|
||||||
|
"json",
|
||||||
|
"rustls-tls",
|
||||||
|
], default_features = false }
|
||||||
|
serde = { version = "1.0.195", features = ["derive"] }
|
||||||
|
serde_json = "1.0.111"
|
||||||
|
sha2 = "0.10.8"
|
||||||
|
sysinfo = "0.30.5"
|
||||||
|
time = { version = "0.3.32", features = ["serde", "serde-human-readable"] }
|
||||||
|
tokio = { version = "1.35.1", features = [
|
||||||
|
"rt",
|
||||||
|
"net",
|
||||||
|
"time",
|
||||||
|
"process",
|
||||||
|
"signal",
|
||||||
|
] }
|
||||||
|
tracing = "0.1.40"
|
||||||
|
tracing-subscriber = "0.3.18"
|
||||||
|
tracing-trace = { version = "0.1.0", path = "../tracing-trace" }
|
||||||
|
uuid = { version = "1.7.0", features = ["v7", "serde"] }
|
||||||
|
129
xtask/src/bench/env_info.rs
Normal file
129
xtask/src/bench/env_info.rs
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use time::OffsetDateTime;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct Source {
|
||||||
|
pub repo_url: Option<String>,
|
||||||
|
pub branch_or_tag: String,
|
||||||
|
pub commit_id: String,
|
||||||
|
pub commit_msg: String,
|
||||||
|
pub author_name: String,
|
||||||
|
pub author_email: String,
|
||||||
|
pub committer_name: String,
|
||||||
|
pub committer_email: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Source {
|
||||||
|
pub fn from_repo(
|
||||||
|
path: impl AsRef<std::path::Path>,
|
||||||
|
) -> Result<(Self, OffsetDateTime), git2::Error> {
|
||||||
|
use git2::Repository;
|
||||||
|
|
||||||
|
let repo = Repository::open(path)?;
|
||||||
|
let remote = repo.remotes()?;
|
||||||
|
let remote = remote.get(0).expect("No remote associated to the repo");
|
||||||
|
let remote = repo.find_remote(remote)?;
|
||||||
|
|
||||||
|
let head = repo.head()?;
|
||||||
|
|
||||||
|
let commit = head.peel_to_commit()?;
|
||||||
|
|
||||||
|
let time = OffsetDateTime::from_unix_timestamp(commit.time().seconds()).unwrap();
|
||||||
|
|
||||||
|
let author = commit.author();
|
||||||
|
let committer = commit.committer();
|
||||||
|
|
||||||
|
Ok((
|
||||||
|
Self {
|
||||||
|
repo_url: remote.url().map(|s| s.to_string()),
|
||||||
|
branch_or_tag: head.name().unwrap().to_string(),
|
||||||
|
commit_id: commit.id().to_string(),
|
||||||
|
commit_msg: String::from_utf8_lossy(commit.message_bytes())
|
||||||
|
.to_string()
|
||||||
|
.lines()
|
||||||
|
.next()
|
||||||
|
.map_or(String::new(), |s| s.to_string()),
|
||||||
|
author_name: author.name().unwrap().to_string(),
|
||||||
|
author_email: author.email().unwrap().to_string(),
|
||||||
|
committer_name: committer.name().unwrap().to_string(),
|
||||||
|
committer_email: committer.email().unwrap().to_string(),
|
||||||
|
},
|
||||||
|
time,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct Environment {
|
||||||
|
pub hostname: Option<String>,
|
||||||
|
pub cpu: String,
|
||||||
|
|
||||||
|
/// Advertised or nominal clock speed in Hertz.
|
||||||
|
pub clock_speed: u64,
|
||||||
|
|
||||||
|
/// Total number of bytes of memory provided by the system. */
|
||||||
|
pub memory: u64,
|
||||||
|
pub os_type: String,
|
||||||
|
pub software: Vec<VersionInfo>,
|
||||||
|
|
||||||
|
pub user_name: String,
|
||||||
|
|
||||||
|
/// Is set true when the data was gathered by a manual run,
|
||||||
|
/// possibly on a developer machine, instead of the usual benchmark server.
|
||||||
|
pub manual_run: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Environment {
|
||||||
|
pub fn generate_from_current_config() -> Self {
|
||||||
|
use sysinfo::System;
|
||||||
|
|
||||||
|
let unknown_string = String::from("Unknown");
|
||||||
|
let mut system = System::new();
|
||||||
|
system.refresh_cpu();
|
||||||
|
system.refresh_cpu_frequency();
|
||||||
|
system.refresh_memory();
|
||||||
|
|
||||||
|
let (cpu, frequency) = match system.cpus().first() {
|
||||||
|
Some(cpu) => (
|
||||||
|
format!("{} @ {:.2}GHz", cpu.brand(), cpu.frequency() as f64 / 1000.0),
|
||||||
|
cpu.frequency() * 1_000_000,
|
||||||
|
),
|
||||||
|
None => (unknown_string.clone(), 0),
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut software = Vec::new();
|
||||||
|
if let Some(distribution) = System::name() {
|
||||||
|
software
|
||||||
|
.push(VersionInfo { name: distribution, version: String::from("distribution") });
|
||||||
|
}
|
||||||
|
if let Some(kernel) = System::kernel_version() {
|
||||||
|
software.push(VersionInfo { name: kernel, version: String::from("kernel") });
|
||||||
|
}
|
||||||
|
if let Some(os) = System::os_version() {
|
||||||
|
software.push(VersionInfo { name: os, version: String::from("kernel-release") });
|
||||||
|
}
|
||||||
|
if let Some(arch) = System::cpu_arch() {
|
||||||
|
software.push(VersionInfo { name: arch, version: String::from("arch") });
|
||||||
|
}
|
||||||
|
|
||||||
|
Self {
|
||||||
|
hostname: System::host_name(),
|
||||||
|
cpu,
|
||||||
|
clock_speed: frequency,
|
||||||
|
memory: system.total_memory(),
|
||||||
|
os_type: System::long_os_version().unwrap_or(unknown_string.clone()),
|
||||||
|
user_name: System::name().unwrap_or(unknown_string.clone()),
|
||||||
|
manual_run: false,
|
||||||
|
software,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct VersionInfo {
|
||||||
|
pub name: String,
|
||||||
|
pub version: String,
|
||||||
|
}
|
1159
xtask/src/bench/mod.rs
Normal file
1159
xtask/src/bench/mod.rs
Normal file
File diff suppressed because it is too large
Load Diff
1
xtask/src/lib.rs
Normal file
1
xtask/src/lib.rs
Normal file
@ -0,0 +1 @@
|
|||||||
|
pub mod bench;
|
@ -1,6 +1,7 @@
|
|||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
use xtask::bench::BenchDeriveArgs;
|
||||||
|
|
||||||
/// List features available in the workspace
|
/// List features available in the workspace
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
@ -17,13 +18,16 @@ struct ListFeaturesDeriveArgs {
|
|||||||
#[command(bin_name = "cargo xtask")]
|
#[command(bin_name = "cargo xtask")]
|
||||||
enum Command {
|
enum Command {
|
||||||
ListFeatures(ListFeaturesDeriveArgs),
|
ListFeatures(ListFeaturesDeriveArgs),
|
||||||
|
Bench(BenchDeriveArgs),
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() -> anyhow::Result<()> {
|
||||||
let args = Command::parse();
|
let args = Command::parse();
|
||||||
match args {
|
match args {
|
||||||
Command::ListFeatures(args) => list_features(args),
|
Command::ListFeatures(args) => list_features(args),
|
||||||
|
Command::Bench(args) => xtask::bench::run(args)?,
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn list_features(args: ListFeaturesDeriveArgs) {
|
fn list_features(args: ListFeaturesDeriveArgs) {
|
||||||
|
Loading…
Reference in New Issue
Block a user