Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
use tempdir for buf as well
Browse files Browse the repository at this point in the history
  • Loading branch information
NikVolf committed Oct 7, 2020
1 parent 1629f74 commit 13f3c83
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions bin/node/testing/src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ impl BenchPair {
}

/// Drop system cache.
///
///
/// Will panic if cache drop is impossbile.
pub fn drop_system_cache() {

#[cfg(target_os = "windows")] {
log::warn!(target: "bench-logistics",
log::warn!(target: "bench-logistics",
"Clearing system cache on windows is not supported. Benchmark might totally be wrong.");
return;
return;
}

std::process::Command::new("sync")
Expand All @@ -110,9 +110,11 @@ pub fn drop_system_cache() {
.output()
.expect("Failed to execute system cache clear");

let temp_path = tempfile::tempdir().expect("Failed to spawn tempdir");

// this should refill write cache with 2GB of garbage
std::process::Command::new("dd")
.args(&["if=/dev/urandom", "of=./benchmark-tmp", "bs=64M", "count=32"])
.args(&["if=/dev/urandom", &format!("of={}/buf", temp_path.path().to_string_lossy()), "bs=64M", "count=32"])
.output()
.expect("Failed to execute dd for cache clear");

Expand All @@ -125,7 +127,7 @@ pub fn drop_system_cache() {
std::process::Command::new("sync")
.output()
.expect("Failed to execute system cache clear");

log::trace!(target: "bench-logistics", "Clearing system cache done!");
}

Expand Down Expand Up @@ -178,8 +180,8 @@ impl Clone for BenchDb {

// We clear system cache after db clone but before any warmups.
// This populates system cache with some data unrelated to actual
// data we will be quering further under benchmark (like what
// would have happened in real system that queries random entries
// data we will be quering further under benchmark (like what
// would have happened in real system that queries random entries
// from database).
drop_system_cache();

Expand Down

0 comments on commit 13f3c83

Please sign in to comment.