Skip to content

Commit 577a495

Browse files
committed
bench uring
Signed-off-by: Onur Satici <[email protected]>
1 parent a2e5fba commit 577a495

File tree

4 files changed

+57
-2
lines changed

4 files changed

+57
-2
lines changed

bench-vortex/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ workspace = true
1818

1919
[features]
2020
lance = ["dep:lance", "dep:lance-encoding"]
21+
uring = ["vortex/uring"]
2122

2223
[dependencies]
2324
lance = { version = "0.39.0", optional = true }

bench-vortex/src/bin/query_bench.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use std::path::PathBuf;
55

66
use bench_vortex::IdempotentPath as _;
7+
use bench_vortex::RuntimeChoice;
78
use bench_vortex::Target;
89
use bench_vortex::benchmark_driver::DriverConfig;
910
use bench_vortex::benchmark_driver::run_benchmark;
@@ -62,6 +63,10 @@ struct CommonArgs {
6263
#[arg(short, long)]
6364
threads: Option<usize>,
6465

66+
/// Runtime to use for Vortex operations.
67+
#[arg(long, value_enum)]
68+
runtime: Option<RuntimeChoice>,
69+
6570
#[arg(short, long)]
6671
verbose: bool,
6772

@@ -283,6 +288,7 @@ fn validate_scale_factor(val: &str) -> Result<String, String> {
283288

284289
fn main() -> anyhow::Result<()> {
285290
let args = Args::parse();
291+
bench_vortex::configure_runtime(args.command.common().runtime);
286292
match args.command {
287293
Commands::ClickBench(clickbench_args) => run_clickbench(clickbench_args),
288294
Commands::TpcH(tpch_args) => run_tpch(tpch_args),
@@ -293,6 +299,23 @@ fn main() -> anyhow::Result<()> {
293299
}
294300
}
295301

302+
trait CommandRuntime {
303+
fn common(&self) -> &CommonArgs;
304+
}
305+
306+
impl CommandRuntime for Commands {
307+
fn common(&self) -> &CommonArgs {
308+
match self {
309+
Commands::ClickBench(args) => &args.common,
310+
Commands::TpcH(args) => &args.common,
311+
Commands::TpcDS(args) => &args.common,
312+
Commands::StatPopGen(args) => &args.common,
313+
Commands::Fineweb(args) => &args.common,
314+
Commands::GhArchive(args) => &args.common,
315+
}
316+
}
317+
}
318+
296319
fn run_clickbench(args: ClickBenchArgs) -> anyhow::Result<()> {
297320
setup_logging_and_tracing(args.common.verbose, args.common.tracing)?;
298321

bench-vortex/src/lib.rs

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use std::clone::Clone;
88
use std::fmt::Display;
99
use std::str::FromStr;
1010
use std::sync::LazyLock;
11+
use std::sync::OnceLock;
1112

1213
use clap::ValueEnum;
1314
use itertools::Itertools;
@@ -55,8 +56,37 @@ use vortex::session::VortexSession;
5556
#[global_allocator]
5657
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
5758

58-
pub static SESSION: LazyLock<VortexSession> =
59-
LazyLock::new(|| VortexSession::default().with_tokio());
59+
pub static SESSION: LazyLock<VortexSession> = LazyLock::new(make_session);
60+
61+
#[derive(Clone, Copy, Debug, PartialEq, Eq, ValueEnum, Serialize)]
62+
#[serde(rename_all = "kebab-case")]
63+
pub enum RuntimeChoice {
64+
Tokio,
65+
#[cfg(all(feature = "uring", target_os = "linux"))]
66+
Uring,
67+
}
68+
69+
static RUNTIME_OVERRIDE: OnceLock<RuntimeChoice> = OnceLock::new();
70+
71+
/// Configure the runtime used by benchmarks. Must be called before `SESSION` is first accessed.
72+
pub fn configure_runtime(choice: Option<RuntimeChoice>) {
73+
if let Some(choice) = choice {
74+
let _ = RUNTIME_OVERRIDE.set(choice);
75+
}
76+
}
77+
78+
fn make_session() -> VortexSession {
79+
match RUNTIME_OVERRIDE.get().copied().unwrap_or(RuntimeChoice::Tokio) {
80+
RuntimeChoice::Tokio => VortexSession::default().with_tokio(),
81+
#[cfg(all(feature = "uring", target_os = "linux"))]
82+
RuntimeChoice::Uring => {
83+
use vortex::io::runtime::uring::PerCoreUringPool;
84+
static URING_POOL: OnceLock<PerCoreUringPool> = OnceLock::new();
85+
let pool = URING_POOL.get_or_init(|| PerCoreUringPool::new(None));
86+
VortexSession::default().with_handle(pool.handle())
87+
}
88+
}
89+
}
6090

6191
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, Serialize)]
6292
pub struct Target {

vortex/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ serde = [
8383
]
8484
# This feature enabled unstable encodings for which we don't guarantee stability.
8585
unstable_encodings = ["vortex-btrblocks/unstable_encodings"]
86+
uring = ["vortex-io/uring"]
8687

8788
[[bench]]
8889
name = "single_encoding_throughput"

0 commit comments

Comments
 (0)