Commit c441ea4
grep: allow submodule functions to run in parallel
Now that object reading operations are internally protected, the
submodule initialization functions at builtin/grep.c:grep_submodule()
are very close to being thread-safe. Let's take a look at each call and
remove from the critical section what we can, for better performance:
- submodule_from_path() and is_submodule_active() cannot be called in
parallel yet only because they call repo_read_gitmodules() which
contains, in its call stack, operations that would otherwise be in
race condition with object reading (for example parse_object() and
is_promisor_remote()). However, they only call repo_read_gitmodules()
if it wasn't read before. So let's pre-read it before firing the
threads and allow these two functions to safely be called in
parallel.
- repo_submodule_init() is already thread-safe, so remove it from the
critical section without other necessary changes.
- The repo_read_gitmodules(&subrepo) call at grep_submodule() is safe as
no other thread is performing object reading operations in the subrepo
yet. However, threads might be working in the superproject, and this
function calls add_to_alternates_memory() internally, which is racy
with object readings in the superproject. So it must be kept
protected for now. Let's add a "NEEDSWORK" to it, informing why it
cannot be removed from the critical section yet.
- Finally, add_to_alternates_memory() must be kept protected for the
same reason as the item above.
Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>1 parent d799242 commit c441ea4
1 file changed
+22
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
401 | 401 | | |
402 | 402 | | |
403 | 403 | | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | 404 | | |
412 | 405 | | |
413 | | - | |
414 | | - | |
| 406 | + | |
415 | 407 | | |
416 | | - | |
417 | 408 | | |
418 | | - | |
419 | | - | |
| 409 | + | |
420 | 410 | | |
421 | | - | |
422 | 411 | | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
423 | 421 | | |
424 | 422 | | |
425 | 423 | | |
| |||
1052 | 1050 | | |
1053 | 1051 | | |
1054 | 1052 | | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
1055 | 1056 | | |
1056 | 1057 | | |
1057 | 1058 | | |
| |||
1071 | 1072 | | |
1072 | 1073 | | |
1073 | 1074 | | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
1074 | 1083 | | |
1075 | 1084 | | |
1076 | 1085 | | |
| |||
1105 | 1114 | | |
1106 | 1115 | | |
1107 | 1116 | | |
1108 | | - | |
1109 | | - | |
1110 | | - | |
1111 | 1117 | | |
1112 | 1118 | | |
1113 | 1119 | | |
| |||
0 commit comments