Currently, logging messages that require formatting are a bit heavy on the CU consumption. For example, a simple msg!("lamports={}", lamports) log can take ~627 CUs.
Solution
Create a lightweight log! macro that improves CU consumption.
[x] log! macro
[x] Log trait to define custom logic for formatting/logging
[x] pinocchio-log crate
[x] Optimize and measure CU
Below is a sample of the improvements observed when formatting log messages, measured in terms of compute units (CU):
Problem
Currently, logging messages that require formatting are a bit heavy on the CU consumption. For example, a simple
msg!("lamports={}", lamports)
log can take~627
CUs.Solution
Create a lightweight
log!
macro that improves CU consumption.log!
macroLog
trait to define custom logic for formatting/loggingpinocchio-log
cratelog!
msg!
"Hello world!"
"lamports={}"
+u64
"{}"
+[&str; 2]
"{}"
+[u64; 2]
"lamports={}"
+i64
"{}"
+[u8; 32]
(pubkey bytes)