]> git.ipfire.org Git - thirdparty/git.git/blobdiff - preload-index.c
reftable: handle null refnames in reftable_ref_record_equal
[thirdparty/git.git] / preload-index.c
index c7dc3f2b9f62a762efd7f590d6e8959fc1707479..e5529a586366d4031a5300d7ab0dfa6ec97489b8 100644 (file)
@@ -8,6 +8,7 @@
 #include "config.h"
 #include "progress.h"
 #include "thread-utils.h"
+#include "repository.h"
 
 /*
  * Mostly randomly chosen maximum thread counts: we
@@ -30,6 +31,7 @@ struct thread_data {
        struct pathspec pathspec;
        struct progress_data *progress;
        int offset, nr;
+       int t2_nr_lstat;
 };
 
 static void *preload_thread(void *_data)
@@ -72,12 +74,13 @@ static void *preload_thread(void *_data)
                        continue;
                if (threaded_has_symlink_leading_path(&cache, ce->name, ce_namelen(ce)))
                        continue;
+               p->t2_nr_lstat++;
                if (lstat(ce->name, &st))
                        continue;
                if (ie_match_stat(index, ce, &st, CE_MATCH_RACY_IS_DIRTY|CE_MATCH_IGNORE_FSMONITOR))
                        continue;
                ce_mark_uptodate(ce);
-               mark_fsmonitor_valid(ce);
+               mark_fsmonitor_valid(index, ce);
        } while (--nr > 0);
        if (p->progress) {
                struct progress_data *pd = p->progress;
@@ -97,6 +100,7 @@ void preload_index(struct index_state *index,
        int threads, i, work, offset;
        struct thread_data data[MAX_PARALLEL];
        struct progress_data pd;
+       int t2_sum_lstat = 0;
 
        if (!HAVE_THREADS || !core_preload_index)
                return;
@@ -106,6 +110,9 @@ void preload_index(struct index_state *index,
                threads = 2;
        if (threads < 2)
                return;
+
+       trace2_region_enter("index", "preload", NULL);
+
        trace_performance_enter();
        if (threads > MAX_PARALLEL)
                threads = MAX_PARALLEL;
@@ -140,18 +147,22 @@ void preload_index(struct index_state *index,
                struct thread_data *p = data+i;
                if (pthread_join(p->pthread, NULL))
                        die("unable to join threaded lstat");
+               t2_sum_lstat += p->t2_nr_lstat;
        }
        stop_progress(&pd.progress);
 
        trace_performance_leave("preload index");
+
+       trace2_data_intmax("index", NULL, "preload/sum_lstat", t2_sum_lstat);
+       trace2_region_leave("index", "preload", NULL);
 }
 
-int read_index_preload(struct index_state *index,
-                      const struct pathspec *pathspec,
-                      unsigned int refresh_flags)
+int repo_read_index_preload(struct repository *repo,
+                           const struct pathspec *pathspec,
+                           unsigned int refresh_flags)
 {
-       int retval = read_index(index);
+       int retval = repo_read_index(repo);
 
-       preload_index(index, pathspec, refresh_flags);
+       preload_index(repo->index, pathspec, refresh_flags);
        return retval;
 }