Get rid of unconditional logging code (#276)

The `log_instruction` macro unconditionally pre-formatted some string to
be logged, even if logging is disabled, making whole AquaVM very slow.

After getting it fixed, native execution time dropped from 5sec to
thousands of milliseconds.
This commit is contained in:
Ivan Boldyrev 2022-06-22 12:25:22 +03:00 committed by GitHub
parent 6df2b9d084
commit 090eceef85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -94,16 +94,21 @@ impl<'i> ExecutableInstruction<'i> for Instruction<'i> {
#[macro_export]
macro_rules! log_instruction {
($instr_name:expr, $exec_ctx:expr, $trace_ctx:expr) => {
use std::fmt::Write as _;
log::debug!(target: air_log_targets::INSTRUCTION, "> {}", stringify!($instr_name));
log::debug!(
target: air_log_targets::INSTRUCTION,
"> {}",
stringify!($instr_name)
);
let mut variables = String::from(" scalars:");
write!(variables, "\n {}", $exec_ctx.scalars).unwrap();
write!(variables, " streams:").unwrap();
write!(variables, "\n {}", $exec_ctx.streams).unwrap();
log::trace!(target: air_log_targets::DATA_CACHE, "{}", variables);
log::trace!(
target: air_log_targets::DATA_CACHE,
" scalars:
{}
streams:
{}",
$exec_ctx.scalars,
$exec_ctx.streams
);
log::trace!(
target: air_log_targets::NEXT_PEER_PKS,
" next peers pk: {:?}",