From: Junio C Hamano Date: Fri, 14 Feb 2020 20:54:20 +0000 (-0800) Subject: Merge branch 'mt/threaded-grep-in-object-store' X-Git-Tag: v2.26.0-rc0~65 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=56ceb64eb0377acb2884226d4fb7d7c3f4032354;p=thirdparty%2Fgit.git Merge branch 'mt/threaded-grep-in-object-store' 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 --- 56ceb64eb0377acb2884226d4fb7d7c3f4032354 diff --cc builtin/grep.c index ae2d5bbafc,629eaf5dbc..99e2685090 --- a/builtin/grep.c +++ b/builtin/grep.c @@@ -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 sha1-file.c index 03ae9ae93a,9dc0649748..6575d6f1fc --- a/sha1-file.c +++ b/sha1-file.c @@@ -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;