No string in slog (#2017)

## Issue Addressed

Following slog's documentation, this should help a bit with string allocations. I left it run for two days and mem usage is lower. This is of course anecdotal, but shouldn't harm anyway 

## Proposed Changes

remove `String` creation in logs when possible
This commit is contained in:
divma
2020-11-30 10:33:00 +00:00
parent 3f036fd193
commit 8fcd22992c
22 changed files with 160 additions and 158 deletions

View File

@@ -513,7 +513,7 @@ impl<T: BeaconChainTypes> SyncingChain<T> {
// This should be unlikely, so we tolerate these errors, but not often.
let action = PeerAction::LowToleranceError;
warn!(self.log, "Batch failed to download. Dropping chain scoring peers";
"score_adjustment" => action.to_string(),
"score_adjustment" => %action,
"batch_epoch"=> batch_id);
for (peer, _) in self.peers.drain() {
network.report_peer(peer, action);
@@ -1028,7 +1028,7 @@ impl<T: BeaconChainTypes> slog::KV for SyncingChain<T> {
"to",
serializer,
)?;
serializer.emit_str("end_root", &self.target_head_root.to_string())?;
serializer.emit_arguments("end_root", &format_args!("{}", self.target_head_root))?;
Value::serialize(
&self.processing_target,
record,