@@ -512,15 +512,15 @@ impl GlobalCacheTracker {
512
512
/// Returns whether or not an auto GC should be performed, compared to the
513
513
/// last time it was recorded in the database.
514
514
pub fn should_run_auto_gc ( & mut self , frequency : Duration ) -> CargoResult < bool > {
515
- trace ! ( "should_run_auto_gc" ) ;
515
+ trace ! ( target : "gc" , "should_run_auto_gc" ) ;
516
516
if self . auto_gc_checked_this_session {
517
517
return Ok ( false ) ;
518
518
}
519
519
let last_auto_gc: Timestamp =
520
520
self . conn
521
521
. query_row ( "SELECT last_auto_gc FROM global_data" , [ ] , |row| row. get ( 0 ) ) ?;
522
522
let should_run = last_auto_gc + frequency. as_secs ( ) < now ( ) ;
523
- trace ! (
523
+ trace ! ( target : "gc" ,
524
524
"last auto gc was {}, {}" ,
525
525
last_auto_gc,
526
526
if should_run { "running" } else { "skipping" }
@@ -559,7 +559,7 @@ impl GlobalCacheTracker {
559
559
src : config. registry_source_path ( ) . into_path_unlocked ( ) ,
560
560
} ;
561
561
let now = now ( ) ;
562
- trace ! ( "cleaning {gc_opts:?}" ) ;
562
+ trace ! ( target : "gc" , "cleaning {gc_opts:?}" ) ;
563
563
let tx = self . conn . transaction ( ) ?;
564
564
let mut delete_paths = Vec :: new ( ) ;
565
565
// This can be an expensive operation, so only perform it if necessary.
@@ -701,7 +701,7 @@ impl GlobalCacheTracker {
701
701
delete_paths : & mut Vec < PathBuf > ,
702
702
) -> CargoResult < ( ) > {
703
703
let _p = crate :: util:: profile:: start ( "global cache db sync" ) ;
704
- debug ! ( "starting db sync" ) ;
704
+ debug ! ( target : "gc" , "starting db sync" ) ;
705
705
// For registry_index and git_db, add anything that is missing in the db.
706
706
Self :: update_parent_for_missing_from_db ( conn, REGISTRY_INDEX_TABLE , & base. index ) ?;
707
707
Self :: update_parent_for_missing_from_db ( conn, GIT_DB_TABLE , & base. git_db ) ?;
@@ -797,7 +797,7 @@ impl GlobalCacheTracker {
797
797
let _p = crate :: util:: profile:: start ( format ! (
798
798
"update parent db for missing from db {parent_table_name}"
799
799
) ) ;
800
- trace ! ( "checking for untracked parent to add to {parent_table_name}" ) ;
800
+ trace ! ( target : "gc" , "checking for untracked parent to add to {parent_table_name}" ) ;
801
801
let names = Self :: names_from ( base_path) ?;
802
802
803
803
let mut stmt = conn. prepare_cached ( & format ! (
@@ -824,7 +824,7 @@ impl GlobalCacheTracker {
824
824
base_path : & Path ,
825
825
) -> CargoResult < ( ) > {
826
826
let _p = crate :: util:: profile:: start ( format ! ( "update db for removed {table_name}" ) ) ;
827
- trace ! ( "checking for db entries to remove from {table_name}" ) ;
827
+ trace ! ( target : "gc" , "checking for db entries to remove from {table_name}" ) ;
828
828
let mut select_stmt = conn. prepare_cached ( & format ! (
829
829
"SELECT {table_name}.rowid, {parent_table_name}.name, {table_name}.name
830
830
FROM {parent_table_name}, {table_name}
@@ -855,7 +855,7 @@ impl GlobalCacheTracker {
855
855
let _p = crate :: util:: profile:: start ( format ! (
856
856
"update db parent for removed from disk {parent_table_name}"
857
857
) ) ;
858
- trace ! ( "checking for db entries to remove from {parent_table_name}" ) ;
858
+ trace ! ( target : "gc" , "checking for db entries to remove from {parent_table_name}" ) ;
859
859
let mut select_stmt =
860
860
conn. prepare_cached ( & format ! ( "SELECT rowid, name FROM {parent_table_name}" ) ) ?;
861
861
let mut delete_stmt =
@@ -870,7 +870,7 @@ impl GlobalCacheTracker {
870
870
for child_base in child_base_paths {
871
871
let child_path = child_base. join ( & id_name) ;
872
872
if child_path. exists ( ) {
873
- debug ! ( "removing orphaned path {child_path:?}" ) ;
873
+ debug ! ( target : "gc" , "removing orphaned path {child_path:?}" ) ;
874
874
delete_paths. push ( child_path) ;
875
875
}
876
876
}
@@ -884,7 +884,7 @@ impl GlobalCacheTracker {
884
884
/// cargo).
885
885
fn populate_untracked_crate ( conn : & Connection , base_path : & Path ) -> CargoResult < ( ) > {
886
886
let _p = crate :: util:: profile:: start ( "populate untracked crate" ) ;
887
- trace ! ( "populating untracked crate files" ) ;
887
+ trace ! ( target : "gc" , "populating untracked crate files" ) ;
888
888
let mut insert_stmt = conn. prepare_cached (
889
889
"INSERT INTO registry_crate (registry_id, name, size, timestamp)
890
890
VALUES (?1, ?2, ?3, ?4)
@@ -923,7 +923,7 @@ impl GlobalCacheTracker {
923
923
populate_size : bool ,
924
924
) -> CargoResult < ( ) > {
925
925
let _p = crate :: util:: profile:: start ( format ! ( "populate untracked {table_name}" ) ) ;
926
- trace ! ( "populating untracked files for {table_name}" ) ;
926
+ trace ! ( target : "gc" , "populating untracked files for {table_name}" ) ;
927
927
// Gather names (and make sure they are in the database).
928
928
let id_names = Self :: names_from ( & base_path) ?;
929
929
@@ -987,7 +987,7 @@ impl GlobalCacheTracker {
987
987
base_path : & Path ,
988
988
) -> CargoResult < ( ) > {
989
989
let _p = crate :: util:: profile:: start ( format ! ( "update NULL sizes {table_name}" ) ) ;
990
- trace ! ( "updating NULL size information in {table_name}" ) ;
990
+ trace ! ( target : "gc" , "updating NULL size information in {table_name}" ) ;
991
991
let mut null_stmt = conn. prepare_cached ( & format ! (
992
992
"SELECT {table_name}.rowid, {table_name}.name, {parent_table_name}.name
993
993
FROM {table_name}, {parent_table_name}
@@ -1024,7 +1024,7 @@ impl GlobalCacheTracker {
1024
1024
base_path : & Path ,
1025
1025
delete_paths : & mut Vec < PathBuf > ,
1026
1026
) -> CargoResult < ( ) > {
1027
- debug ! ( "cleaning {table_name} since {max_age:?}" ) ;
1027
+ debug ! ( target : "gc" , "cleaning {table_name} since {max_age:?}" ) ;
1028
1028
let mut stmt = conn. prepare_cached ( & format ! (
1029
1029
"DELETE FROM {table_name} WHERE timestamp < ?1
1030
1030
RETURNING registry_id, name"
@@ -1054,7 +1054,7 @@ impl GlobalCacheTracker {
1054
1054
base_path : & Path ,
1055
1055
delete_paths : & mut Vec < PathBuf > ,
1056
1056
) -> CargoResult < ( ) > {
1057
- debug ! ( "cleaning {table_name} till under {max_size:?}" ) ;
1057
+ debug ! ( target : "gc" , "cleaning {table_name} till under {max_size:?}" ) ;
1058
1058
let total_size: u64 = conn. query_row (
1059
1059
& format ! ( "SELECT coalesce(SUM(size), 0) FROM {table_name}" ) ,
1060
1060
[ ] ,
@@ -1111,7 +1111,7 @@ impl GlobalCacheTracker {
1111
1111
base : & BasePaths ,
1112
1112
delete_paths : & mut Vec < PathBuf > ,
1113
1113
) -> CargoResult < ( ) > {
1114
- debug ! ( "cleaning download till under {max_size:?}" ) ;
1114
+ debug ! ( target : "gc" , "cleaning download till under {max_size:?}" ) ;
1115
1115
1116
1116
// This SQL statement selects from both registry_src and
1117
1117
// registry_crate so that sorting of timestamps incorporates both of
@@ -1149,7 +1149,7 @@ impl GlobalCacheTracker {
1149
1149
} ) ?
1150
1150
. collect :: < Result < Vec < ( i64 , i64 , String , String , u64 ) > , _ > > ( ) ?;
1151
1151
let mut total_size: u64 = rows. iter ( ) . map ( |r| r. 4 ) . sum ( ) ;
1152
- debug ! ( "total download cache size appears to be {total_size}" ) ;
1152
+ debug ! ( target : "gc" , "total download cache size appears to be {total_size}" ) ;
1153
1153
for ( table, rowid, name, index_name, size) in rows {
1154
1154
if total_size <= max_size {
1155
1155
break ;
@@ -1177,7 +1177,7 @@ impl GlobalCacheTracker {
1177
1177
base : & BasePaths ,
1178
1178
delete_paths : & mut Vec < PathBuf > ,
1179
1179
) -> CargoResult < ( ) > {
1180
- debug ! ( "cleaning git till under {max_size:?}" ) ;
1180
+ debug ! ( target : "gc" , "cleaning git till under {max_size:?}" ) ;
1181
1181
1182
1182
// Collect all the sizes from git_db and git_checkouts, and then sort them by timestamp.
1183
1183
let mut stmt = conn. prepare_cached ( "SELECT rowid, name, timestamp FROM git_db" ) ?;
@@ -1224,7 +1224,7 @@ impl GlobalCacheTracker {
1224
1224
let mut delete_co_stmt =
1225
1225
conn. prepare_cached ( "DELETE FROM git_checkout WHERE rowid = ?1" ) ?;
1226
1226
let mut total_size: u64 = git_info. iter ( ) . map ( |r| r. 4 ) . sum ( ) ;
1227
- debug ! ( "total git cache size appears to be {total_size}" ) ;
1227
+ debug ! ( target : "gc" , "total git cache size appears to be {total_size}" ) ;
1228
1228
while let Some ( ( _timestamp, rowid, db_name, name, size) ) = git_info. pop ( ) {
1229
1229
if total_size <= max_size {
1230
1230
break ;
@@ -1262,7 +1262,7 @@ impl GlobalCacheTracker {
1262
1262
base : & BasePaths ,
1263
1263
delete_paths : & mut Vec < PathBuf > ,
1264
1264
) -> CargoResult < ( ) > {
1265
- debug ! ( "cleaning index since {max_age:?}" ) ;
1265
+ debug ! ( target : "gc" , "cleaning index since {max_age:?}" ) ;
1266
1266
let mut stmt = conn. prepare_cached (
1267
1267
"DELETE FROM registry_index WHERE timestamp < ?1
1268
1268
RETURNING name" ,
@@ -1287,7 +1287,7 @@ impl GlobalCacheTracker {
1287
1287
base_path : & Path ,
1288
1288
delete_paths : & mut Vec < PathBuf > ,
1289
1289
) -> CargoResult < ( ) > {
1290
- debug ! ( "cleaning git co since {max_age:?}" ) ;
1290
+ debug ! ( target : "gc" , "cleaning git co since {max_age:?}" ) ;
1291
1291
let mut stmt = conn. prepare_cached (
1292
1292
"DELETE FROM git_checkout WHERE timestamp < ?1
1293
1293
RETURNING git_id, name" ,
@@ -1316,7 +1316,7 @@ impl GlobalCacheTracker {
1316
1316
base : & BasePaths ,
1317
1317
delete_paths : & mut Vec < PathBuf > ,
1318
1318
) -> CargoResult < ( ) > {
1319
- debug ! ( "cleaning git db since {max_age:?}" ) ;
1319
+ debug ! ( target : "gc" , "cleaning git db since {max_age:?}" ) ;
1320
1320
let mut stmt = conn. prepare_cached (
1321
1321
"DELETE FROM git_db WHERE timestamp < ?1
1322
1322
RETURNING name" ,
@@ -1361,7 +1361,7 @@ macro_rules! insert_or_update_parent {
1361
1361
" SET timestamp = ?1 WHERE id = ?2"
1362
1362
) ) ?;
1363
1363
for ( parent, new_timestamp) in std:: mem:: take( & mut $self. $timestamps_field) {
1364
- trace!(
1364
+ trace!( target : "gc" ,
1365
1365
concat!( "insert " , $table_name, " {:?} {}" ) ,
1366
1366
parent,
1367
1367
new_timestamp
@@ -1553,7 +1553,7 @@ impl DeferredGlobalLastUse {
1553
1553
/// This will also clear the state of `self`.
1554
1554
pub fn save ( & mut self , tracker : & mut GlobalCacheTracker ) -> CargoResult < ( ) > {
1555
1555
let _p = crate :: util:: profile:: start ( "saving last-use data" ) ;
1556
- trace ! ( "saving last-use data" ) ;
1556
+ trace ! ( target : "gc" , "saving last-use data" ) ;
1557
1557
if self . is_empty ( ) {
1558
1558
return Ok ( ( ) ) ;
1559
1559
}
@@ -1565,7 +1565,7 @@ impl DeferredGlobalLastUse {
1565
1565
self . insert_registry_src_from_cache ( & tx) ?;
1566
1566
self . insert_git_checkout_from_cache ( & tx) ?;
1567
1567
tx. commit ( ) ?;
1568
- trace ! ( "last-use save complete" ) ;
1568
+ trace ! ( target : "gc" , "last-use save complete" ) ;
1569
1569
Ok ( ( ) )
1570
1570
}
1571
1571
@@ -1632,7 +1632,7 @@ impl DeferredGlobalLastUse {
1632
1632
fn insert_registry_crate_from_cache ( & mut self , conn : & Connection ) -> CargoResult < ( ) > {
1633
1633
let registry_crate_timestamps = std:: mem:: take ( & mut self . registry_crate_timestamps ) ;
1634
1634
for ( registry_crate, timestamp) in registry_crate_timestamps {
1635
- trace ! ( "insert registry crate {registry_crate:?} {timestamp}" ) ;
1635
+ trace ! ( target : "gc" , "insert registry crate {registry_crate:?} {timestamp}" ) ;
1636
1636
let registry_id = self . registry_id ( conn, registry_crate. encoded_registry_name ) ?;
1637
1637
let mut stmt = conn. prepare_cached (
1638
1638
"INSERT INTO registry_crate (registry_id, name, size, timestamp)
@@ -1657,7 +1657,7 @@ impl DeferredGlobalLastUse {
1657
1657
fn insert_registry_src_from_cache ( & mut self , conn : & Connection ) -> CargoResult < ( ) > {
1658
1658
let registry_src_timestamps = std:: mem:: take ( & mut self . registry_src_timestamps ) ;
1659
1659
for ( registry_src, timestamp) in registry_src_timestamps {
1660
- trace ! ( "insert registry src {registry_src:?} {timestamp}" ) ;
1660
+ trace ! ( target : "gc" , "insert registry src {registry_src:?} {timestamp}" ) ;
1661
1661
let registry_id = self . registry_id ( conn, registry_src. encoded_registry_name ) ?;
1662
1662
let mut stmt = conn. prepare_cached (
1663
1663
"INSERT INTO registry_src (registry_id, name, size, timestamp)
0 commit comments