Skip to content

Commit 7652d23

Browse files
committed
feat: add option to disable logging for benchmarks
1 parent 6f56d12 commit 7652d23

File tree

4 files changed

+46
-17
lines changed

4 files changed

+46
-17
lines changed

src/bench_utils.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ pub struct Args {
2121
#[arg(short, long, default_value_t = 30)]
2222
pub duration: u64,
2323

24+
#[arg(long, default_value_t = false)]
25+
pub no_log: bool,
26+
2427
#[cfg(feature = "profiling")]
2528
#[arg(long, default_value_t = false)]
2629
pub profile: bool,

src/bin/argusdb.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ struct Args {
5353
#[arg(long)]
5454
index_threshold: Option<u64>,
5555

56+
/// Disable logging
57+
#[arg(long, default_value_t = false)]
58+
no_log: bool,
59+
5660
/// Print help
5761
#[arg(long, action = clap::ArgAction::Help)]
5862
help: Option<bool>,
@@ -72,6 +76,8 @@ struct Settings {
7276
jstable_dir: String,
7377
#[serde(default = "default_index_threshold")]
7478
index_threshold: u64,
79+
#[serde(default = "default_no_log")]
80+
no_log: bool,
7581
}
7682

7783
fn default_host() -> String {
@@ -98,6 +104,10 @@ fn default_index_threshold() -> u64 {
98104
1024
99105
}
100106

107+
fn default_no_log() -> bool {
108+
false
109+
}
110+
101111
pub struct ArgusHandler {
102112
db: Arc<Mutex<DB>>,
103113
}
@@ -276,19 +286,28 @@ async fn main() {
276286
.set_override("index_threshold", index_threshold as i64)
277287
.unwrap();
278288
}
289+
if args.no_log {
290+
builder = builder.set_override("no_log", true).unwrap();
291+
}
279292

280293
let subscriber = tracing_subscriber::fmt()
281294
.with_max_level(Level::TRACE)
282295
.finish();
283296
tracing::subscriber::set_global_default(subscriber).unwrap();
284297
let settings: Settings = builder.build().unwrap().try_deserialize().unwrap();
285298

299+
let log_threshold = if settings.no_log {
300+
None
301+
} else {
302+
Some(1024 * 1024)
303+
};
304+
286305
let db = Arc::new(Mutex::new(DB::new(
287306
&settings.jstable_dir,
288307
settings.memtable_threshold,
289308
settings.jstable_threshold,
290309
settings.index_threshold,
291-
Some(1024 * 1024),
310+
log_threshold,
292311
)));
293312
let handler = Arc::new(ArgusHandler::new(db));
294313
let processor = Arc::new(ArgusProcessor { handler });

src/bin/bench_runner.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ async fn main() {
5050
let db_path = dir.path().to_str().unwrap();
5151
println!("Setting up DB at {}", db_path);
5252

53-
let db = Arc::new(Mutex::new(DB::new(db_path, 1000, 10, 1024, None)));
53+
let log_threshold = if args.no_log { None } else { Some(1024 * 1024) };
54+
let db = Arc::new(Mutex::new(DB::new(db_path, 1000, 10, 1024, log_threshold)));
5455

5556
// 2. Load Data
5657
let data_dir = Path::new("workbook/data");

src/bin/bench_runner_server.rs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,27 @@ async fn main() {
8484
let host = "127.0.0.1";
8585

8686
println!("Starting ArgusDB server on {}:{}", host, port);
87-
let child = Command::new("./target/release/argusdb")
88-
.args(&[
89-
"--jstable-dir",
90-
&db_path,
91-
"--host",
92-
host,
93-
"--port",
94-
&port.to_string(),
95-
"--memtable-threshold",
96-
"1000",
97-
"--jstable-threshold",
98-
"10",
99-
"--index-threshold",
100-
"1024",
101-
])
87+
let mut command = Command::new("./target/release/argusdb");
88+
command.args(&[
89+
"--jstable-dir",
90+
&db_path,
91+
"--host",
92+
host,
93+
"--port",
94+
&port.to_string(),
95+
"--memtable-threshold",
96+
"1000",
97+
"--jstable-threshold",
98+
"10",
99+
"--index-threshold",
100+
"1024",
101+
]);
102+
103+
if args.no_log {
104+
command.arg("--no-log");
105+
}
106+
107+
let child = command
102108
.stdout(Stdio::inherit())
103109
.stderr(Stdio::inherit())
104110
.spawn()

0 commit comments

Comments
 (0)