]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'mt/threaded-grep-in-object-store'
authorJunio C Hamano <gitster@pobox.com>
Fri, 14 Feb 2020 20:54:20 +0000 (12:54 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 14 Feb 2020 20:54:20 +0000 (12:54 -0800)
Traditionally, we avoided threaded grep while searching in objects
(as opposed to files in the working tree) as accesses to the object
layer is not thread-safe.  This limitation is getting lifted.

* mt/threaded-grep-in-object-store:
  grep: use no. of cores as the default no. of threads
  grep: move driver pre-load out of critical section
  grep: re-enable threads in non-worktree case
  grep: protect packed_git [re-]initialization
  grep: allow submodule functions to run in parallel
  submodule-config: add skip_if_read option to repo_read_gitmodules()
  grep: replace grep_read_mutex by internal obj read lock
  object-store: allow threaded access to object reading
  replace-object: make replace operations thread-safe
  grep: fix racy calls in grep_objects()
  grep: fix race conditions at grep_submodule()
  grep: fix race conditions on userdiff calls

1  2 
Documentation/git-grep.txt
builtin/grep.c
object-store.h
packfile.c
sha1-file.c
unpack-trees.c

Simple merge
diff --cc builtin/grep.c
index ae2d5bbafcae263e91cd7f9ea7a97dc7a874d4aa,629eaf5dbc9cc1c4e7d93c6d4e3ec7211f5d4df9..99e26850907b74374000675aa19bb42cf39c32b2
@@@ -1065,7 -1050,10 +1053,10 @@@ int cmd_grep(int argc, const char **arg
        pathspec.recursive = 1;
        pathspec.recurse_submodules = !!recurse_submodules;
  
-       if (list.nr || cached || show_in_pager) {
 -      if (recurse_submodules && (!use_index || untracked))
 -              die(_("option not supported with --recurse-submodules"));
++      if (recurse_submodules && untracked)
++              die(_("--untracked not supported with --recurse-submodules"));
+       if (show_in_pager) {
                if (num_threads > 1)
                        warning(_("invalid option combination, ignoring --threads"));
                num_threads = 1;
diff --cc object-store.h
Simple merge
diff --cc packfile.c
Simple merge
diff --cc sha1-file.c
index 03ae9ae93a53d911137a8f06aa687472c73806c9,9dc0649748da28406435ee524675cf99945189ca..6575d6f1fcbe4c44b49bc318320086b4c37ebe37
@@@ -1411,13 -1422,34 +1422,35 @@@ static int loose_object_info(struct rep
        return (status < 0) ? status : 0;
  }
  
+ int obj_read_use_lock = 0;
+ pthread_mutex_t obj_read_mutex;
+ void enable_obj_read_lock(void)
+ {
+       if (obj_read_use_lock)
+               return;
+       obj_read_use_lock = 1;
+       init_recursive_mutex(&obj_read_mutex);
+ }
+ void disable_obj_read_lock(void)
+ {
+       if (!obj_read_use_lock)
+               return;
+       obj_read_use_lock = 0;
+       pthread_mutex_destroy(&obj_read_mutex);
+ }
  int fetch_if_missing = 1;
  
- int oid_object_info_extended(struct repository *r, const struct object_id *oid,
-                            struct object_info *oi, unsigned flags)
+ static int do_oid_object_info_extended(struct repository *r,
+                                      const struct object_id *oid,
+                                      struct object_info *oi, unsigned flags)
  {
        static struct object_info blank_oi = OBJECT_INFO_INIT;
 +      struct cached_object *co;
        struct pack_entry e;
        int rtype;
        const struct object_id *real = oid;
diff --cc unpack-trees.c
Simple merge