Shorten log duration
@@ -185,25 +185,14 @@ fn to_known_view(upstream_repo: &str, filter_spec: &str) -> String {
);
}
-pub fn spawn_thread(
- repo: git2::Repository,
+fn refresh_known_filters(
+ repo: &git2::Repository,
known_views: Arc<RwLock<housekeeping::KnownViews>>,
forward_maps: Arc<RwLock<view_maps::ViewMaps>>,
backward_maps: Arc<RwLock<view_maps::ViewMaps>>,
- do_gc: bool,
-) -> std::thread::JoinHandle<()> {
- let mut gc_timer = std::time::Instant::now();
- let mut persist_timer =
- std::time::Instant::now() - std::time::Duration::from_secs(60 * 5);
- std::thread::spawn(move || {
+) -> JoshResult<usize> {
let mut total = 0;
- loop {
- housekeeping::discover_filter_candidates(
- &repo,
- known_views.clone(),
- )
- .ok();
- if let Ok(kn) = known_views.read() {
+ let kn = known_views.read()?.clone();
for (prefix2, e) in kn.iter() {
info!("background rebuild root: {:?}", prefix2);
@@ -213,17 +202,10 @@ pub fn spawn_thread(
let mut updated_count = 0;
for v in e.iter() {
- tracing::trace!(
- "background rebuild: {:?} {:?}",
- prefix2,
- v
- );
+ tracing::trace!("background rebuild: {:?} {:?}", prefix2, v);
- let refs = find_refs(
- &repo,
- &&to_known_view(&prefix2, &v),
- &prefix2,
- );
+ let refs =
+ find_refs(&repo, &&to_known_view(&prefix2, &v), &prefix2);
updated_count += scratch::apply_filter_to_refs(
&repo,
@@ -246,7 +228,34 @@ pub fn spawn_thread(
forward_maps.merge(&fm);
});
}
+ return Ok(total);
}
+
+pub fn spawn_thread(
+ repo: git2::Repository,
+ known_views: Arc<RwLock<housekeeping::KnownViews>>,
+ forward_maps: Arc<RwLock<view_maps::ViewMaps>>,
+ backward_maps: Arc<RwLock<view_maps::ViewMaps>>,
+ do_gc: bool,
+) -> std::thread::JoinHandle<()> {
+ let mut gc_timer = std::time::Instant::now();
+ let mut persist_timer =
+ std::time::Instant::now() - std::time::Duration::from_secs(60 * 5);
+ std::thread::spawn(move || {
+ let mut total = 0;
+ loop {
+ housekeeping::discover_filter_candidates(
+ &repo,
+ known_views.clone(),
+ )
+ .ok();
+ total += refresh_known_filters(
+ &repo,
+ known_views.clone(),
+ forward_maps.clone(),
+ backward_maps.clone(),
+ )
+ .unwrap_or(0);
if total > 1000
|| persist_timer.elapsed()
> std::time::Duration::from_secs(60 * 15)
