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