Skip to content

Commit

Permalink
Merge pull request #1004 from andyleiserson/log-seed
Browse files Browse the repository at this point in the history
IPA bench: log random seed and runtime at info level
  • Loading branch information
andyleiserson authored Apr 12, 2024
2 parents 38032e5 + b4763b0 commit 28411cd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
21 changes: 18 additions & 3 deletions ipa-core/benches/oneshot/ipa.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::{
env,
num::{NonZeroU32, NonZeroU64, NonZeroUsize},
time::Instant,
};
Expand Down Expand Up @@ -102,9 +103,11 @@ async fn run(args: Args) -> Result<(), Error> {
gateway_config: GatewayConfig::new(args.active()),
..TestWorldConfig::default()
};
// Construct TestWorld early to initialize logging.
let world = TestWorld::new_with(&config);

let seed = args.random_seed.unwrap_or_else(|| random());
tracing::trace!(
tracing::info!(
"Using random seed: {seed} for {q} records",
q = args.query_size
);
Expand Down Expand Up @@ -154,12 +157,11 @@ async fn run(args: Args) -> Result<(), Error> {
&order,
);

let world = TestWorld::new_with(config.clone());
tracing::trace!("Preparation complete in {:?}", _prep_time.elapsed());

let _protocol_time = Instant::now();
test_oprf_ipa::<BenchField>(&world, raw_data, &expected_results, args.config()).await;
tracing::trace!(
tracing::info!(
"{m:?} IPA for {q} records took {t:?}",
m = args.mode,
q = args.query_size,
Expand All @@ -172,6 +174,19 @@ fn main() -> Result<(), Error> {
#[cfg(feature = "dhat-heap")]
let _profiler = dhat::Profiler::new_heap();

// The default in test_fixture::logging is to enable logging for ipa-core only. Override that to
// include logs from the bench as well.
if env::var_os("RUST_LOG").is_none() {
env::set_var(
"RUST_LOG",
format!(
"{}=INFO,{}=INFO",
ipa_core::CRATE_NAME,
env!("CARGO_CRATE_NAME")
),
);
}

let args = Args::parse();
let rt = Builder::new_multi_thread()
.worker_threads(args.threads)
Expand Down
2 changes: 2 additions & 0 deletions ipa-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ pub(crate) mod test_executor {
}
}

pub const CRATE_NAME: &str = env!("CARGO_CRATE_NAME");

#[macro_export]
macro_rules! const_assert {
($x:expr $(,)?) => {
Expand Down

0 comments on commit 28411cd

Please sign in to comment.