Add log lines with timings

Signed-off-by: Olivier <olivier@librepush.net>
This commit is contained in:
Olivier 'reivilibre' 2024-09-29 00:05:01 +01:00
parent 1e029a1826
commit b410114523

View File

@ -13,7 +13,7 @@ use std::io::Write;
use std::path::PathBuf;
use std::process::{Child, Command, Stdio};
use std::sync::Arc;
use std::time::{SystemTime, UNIX_EPOCH};
use std::time::{Instant, SystemTime, UNIX_EPOCH};
use tokio::runtime::Handle;
use tokio::task::JoinSet;
use tracing::{debug, info, info_span, Instrument, Span};
@ -50,15 +50,22 @@ pub async fn backup(
options: &BackupOptions,
) -> eyre::Result<()> {
// Locate suitable parent pointers
let timestart = Instant::now();
let parents_to_use = find_suitable_parent_pointers(&pwc, &sources_to_backup)
.await
.context("failed to look for suitable parent pointers")?;
debug!(
"find_suitable_parent_pointers: {:?}",
Instant::now() - timestart
);
let now = Utc::now();
// (dirtrees) Scan
let timestart = Instant::now();
let dir_sources = scan_dir_sources(&sources_to_backup, parents_to_use, now, options)
.await
.context("failed to scan directory sources")?;
debug!("scan_dir_sources: {:?}", Instant::now() - timestart);
let new_unflushed_chunks: Arc<DashSet<ChunkId>> = Arc::new(Default::default());
@ -90,8 +97,13 @@ pub async fn backup(
.instrument(bvs_span)))
};
let timestart = Instant::now();
let (dir_sources_and_chunkmaps, virt_sources) =
tokio::join!(task_store_dirs, task_store_virtuals);
debug!(
"join!(task_store_dirs, task_store_virtuals): {:?}",
Instant::now() - timestart
);
let dir_sources_and_chunkmaps: BackupDirSourcesReturn = dir_sources_and_chunkmaps??;
let mut virt_sources: Vec<VirtualSourceReturn> = virt_sources??;
@ -243,14 +255,14 @@ async fn scan_dir_sources(
} = &source.inner
{
let path = path.to_owned();
let cross_filesystems = *cross_filesystems;
debug!("TODO: xf={cross_filesystems}");
let ignore = ignore.to_owned();
let (parent_name, parent) = parents.remove(source_name).unzip();
let new_pointer_name = get_pointer_name_at(&source_name, now);
let options = options.clone();
joinset.spawn_blocking(move || -> eyre::Result<DirSourcePrep> {
let timestart = Instant::now();
let scan_entry_map = scan::scan(&path, &ignore).context("Failed to scan")?;
debug!("scan: {:?}", Instant::now() - timestart);
info!(
"size estimate for {:?} (full scan): {}",
path,