Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(logging): Reduce loglevel of blob GC #1866

Merged
merged 3 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 26 additions & 22 deletions iroh-bytes/src/store/traits.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
//! Traits for in-memory or persistent maps of blob with bao encoded outboards.
use std::{collections::BTreeSet, io, path::PathBuf};

use crate::{
hashseq::parse_hash_seq,
util::{
progress::{IdGenerator, ProgressSender},
Tag,
},
BlobFormat, Hash, HashAndFormat, TempTag,
};
use bao_tree::{blake3, ChunkRanges};
use bytes::Bytes;
use futures::{future::BoxFuture, stream::LocalBoxStream, Stream, StreamExt};
Expand All @@ -18,6 +10,15 @@ use iroh_io::AsyncSliceReader;
use serde::{Deserialize, Serialize};
use tokio::{io::AsyncRead, sync::mpsc};

use crate::{
hashseq::parse_hash_seq,
util::{
progress::{IdGenerator, ProgressSender},
Tag,
},
BlobFormat, Hash, HashAndFormat, TempTag,
};

pub use bao_tree;
pub use range_collections;

Expand Down Expand Up @@ -263,8 +264,11 @@ pub trait Store: ReadableStore + PartialMap {
}
}
}
co.yield_(GcSweepEvent::CustomInfo(format!("deleted {} blobs", count)))
.await;
co.yield_(GcSweepEvent::CustomDebug(format!(
"deleted {} blobs",
count
)))
.await;
})
.boxed_local()
}
Expand All @@ -290,9 +294,9 @@ async fn gc_mark_task<'a>(
extra_roots: impl IntoIterator<Item = io::Result<HashAndFormat>> + 'a,
co: &Co<GcMarkEvent>,
) -> anyhow::Result<()> {
macro_rules! info {
macro_rules! debug {
($($arg:tt)*) => {
co.yield_(GcMarkEvent::CustomInfo(format!($($arg)*))).await;
co.yield_(GcMarkEvent::CustomDebug(format!($($arg)*))).await;
};
}
macro_rules! warn {
Expand All @@ -301,20 +305,20 @@ async fn gc_mark_task<'a>(
};
}
let mut roots = BTreeSet::new();
info!("traversing tags");
debug!("traversing tags");
for (name, haf) in store.tags() {
info!("adding root {:?} {:?}", name, haf);
debug!("adding root {:?} {:?}", name, haf);
roots.insert(haf);
}
info!("traversing temp roots");
debug!("traversing temp roots");
for haf in store.temp_tags() {
info!("adding temp pin {:?}", haf);
debug!("adding temp pin {:?}", haf);
roots.insert(haf);
}
info!("traversing extra roots");
debug!("traversing extra roots");
for haf in extra_roots {
let haf = haf?;
info!("adding extra root {:?}", haf);
debug!("adding extra root {:?}", haf);
roots.insert(haf);
}
let mut live: BTreeSet<Hash> = BTreeSet::new();
Expand All @@ -337,7 +341,7 @@ async fn gc_mark_task<'a>(
warn!("gc: {} parse failed", hash);
continue;
};
info!("parsed collection {} {:?}", hash, count);
debug!("parsed collection {} {:?}", hash, count);
loop {
let item = match stream.next().await {
Ok(Some(item)) => item,
Expand All @@ -352,7 +356,7 @@ async fn gc_mark_task<'a>(
}
}
}
info!("gc mark done. found {} live blobs", live.len());
debug!("gc mark done. found {} live blobs", live.len());
store.add_live(live);
Ok(())
}
Expand All @@ -361,7 +365,7 @@ async fn gc_mark_task<'a>(
#[derive(Debug)]
pub enum GcMarkEvent {
/// A custom event (info)
CustomInfo(String),
CustomDebug(String),
/// A custom non critical error
CustomWarning(String, Option<anyhow::Error>),
/// An unrecoverable error during GC
Expand All @@ -372,7 +376,7 @@ pub enum GcMarkEvent {
#[derive(Debug)]
pub enum GcSweepEvent {
/// A custom event (info)
CustomInfo(String),
CustomDebug(String),
/// A custom non critical error
CustomWarning(String, Option<anyhow::Error>),
/// An unrecoverable error during GC
Expand Down
12 changes: 6 additions & 6 deletions iroh/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,12 +506,12 @@ where
continue 'outer;
}

tracing::info!("Starting GC mark phase");
tracing::debug!("Starting GC mark phase");
let mut stream = db.gc_mark(None);
while let Some(item) = stream.next().await {
match item {
GcMarkEvent::CustomInfo(text) => {
tracing::info!("{}", text);
GcMarkEvent::CustomDebug(text) => {
tracing::debug!("{}", text);
}
GcMarkEvent::CustomWarning(text, _) => {
tracing::warn!("{}", text);
Expand All @@ -523,12 +523,12 @@ where
}
}

tracing::info!("Starting GC sweep phase");
tracing::debug!("Starting GC sweep phase");
let mut stream = db.gc_sweep();
while let Some(item) = stream.next().await {
match item {
GcSweepEvent::CustomInfo(text) => {
tracing::info!("{}", text);
GcSweepEvent::CustomDebug(text) => {
tracing::debug!("{}", text);
}
GcSweepEvent::CustomWarning(text, _) => {
tracing::warn!("{}", text);
Expand Down