git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/3] index-pack: drop type_cas mutex

From
Jeff King <peff@peff.net>
Date
Oct 7, 2020, 18:19 UTC
Message-ID
<20201007181943.GB1976631@coredump.intra.peff.net>
In-Reply-To
<20201007181708.GA222564@coredump.intra.peff.net>

The type_cas lock lost all of its callers in f08cbf60fe (index-pack: make quantum of work smaller, 2020-09-08), so we can safely delete it. The compiler didn't alert us that the variable became unused, because we still call pthread_mutex_init() and pthread_mutex_destroy() on it.

It's worth considering also whether that commit was in error to remove the use of the lock. Why don't we need it now, if we did before, as described in ab791dd138 (index-pack: fix race condition with duplicate bases, 2014-08-29)? I think the answer is that we now look at and assign the child_obj->real_type field in the main thread while holding the work_lock(). So we don't have to worry about racing with the worker threads.

Signed-off-by: Jeff King <peff@peff.net>
---
 builtin/index-pack.c | 6 ------
 1 file changed, 6 deletions(-)
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 0f05533902..f8f1b48e56 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -159,10 +159,6 @@ static pthread_mutex_t deepest_delta_mutex;
 #define deepest_delta_lock()	lock_mutex(&deepest_delta_mutex)
 #define deepest_delta_unlock()	unlock_mutex(&deepest_delta_mutex)
 
-static pthread_mutex_t type_cas_mutex;
-#define type_cas_lock()		lock_mutex(&type_cas_mutex)
-#define type_cas_unlock()	unlock_mutex(&type_cas_mutex)
-
 static pthread_key_t key;
 
 static inline void lock_mutex(pthread_mutex_t *mutex)
@@ -186,7 +182,6 @@ static void init_thread(void)
 	init_recursive_mutex(&read_mutex);
 	pthread_mutex_init(&counter_mutex, NULL);
 	pthread_mutex_init(&work_mutex, NULL);
-	pthread_mutex_init(&type_cas_mutex, NULL);
 	if (show_stat)
 		pthread_mutex_init(&deepest_delta_mutex, NULL);
 	pthread_key_create(&key, NULL);
@@ -209,7 +204,6 @@ static void cleanup_thread(void)
 	pthread_mutex_destroy(&read_mutex);
 	pthread_mutex_destroy(&counter_mutex);
 	pthread_mutex_destroy(&work_mutex);
-	pthread_mutex_destroy(&type_cas_mutex);
 	if (show_stat)
 		pthread_mutex_destroy(&deepest_delta_mutex);
 	for (i = 0; i < nr_threads; i++)
-- 
2.29.0.rc0.520.gccaf68d5cd
Previous: Junio C HamanoNext: Jonathan Tan
Message 13 of 21 in “[ANNOUNCE] Git v2.29.0-rc0”
  1. Junio C HamanoOct 5, 2020
  2. Bryan TurnerOct 5, 2020
  3. Randall S. BeckerOct 5, 2020
  4. Martin ÅgrenOct 6, 2020
  5. Junio C HamanoOct 6, 2020
  6. Ævar Arnfjörð BjarmasonOct 7, 2020
  7. Jeff KingOct 7, 2020
  8. Jeff KingOct 7, 2020
  9. Junio C HamanoOct 7, 2020
  10. 0/3 jt/threaded-inex-pack leftoversJeff King, Oct 7, 2020
  11. 1/3 index-pack: restore "resolving deltas" progress meterJeff King, Oct 7, 2020
  12. Junio C HamanoOct 7, 2020
  13. 2/3 index-pack: drop type_cas mutexJeff King, Oct 7, 2020
  14. Jonathan TanOct 7, 2020
  15. 3/3 index-pack: stop mentioning find_unresolved_deltas()Jeff King, Oct 7, 2020
  16. Jonathan TanOct 7, 2020
  17. Jeff KingOct 7, 2020
  18. index-pack: make get_base_data() comment clearerJonathan Tan, Oct 7, 2020
  19. Junio C HamanoOct 7, 2020
  20. Philippe BlainOct 7, 2020
  21. Randall S. BeckerOct 9, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.