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

Re: [PATCHv3 7/7] grep: honor --textconv for the case rev:path

From
Junio C Hamano <gitster@pobox.com>
Date
May 10, 2013, 18:31 UTC
Message-ID
<7v38tu1yb7.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7v7gj61z9h.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 17 quoted lines
> Michael J Gruber <git@drmicha.warpmail.net> writes:
>
>> diff --git a/object.h b/object.h
>> index 97d384b..695847d 100644
>> --- a/object.h
>> +++ b/object.h
>> @@ -13,6 +13,7 @@ struct object_array {
>>  		struct object *item;
>>  		const char *name;
>>  		unsigned mode;
>> +		struct object_context *context;
>>  	} *objects;
>>  };
>
> fsck has to hold this for each and every objects in the repository
> it has found but hasn't inspected (i.e. pending), doesn't it? Do we
> really want to add 8 bytes for each of them?
Perhaps fsck does not even want "name" and "mode" for that matter.

I wonder what improvement, if any, we would see with a change like this patch in a large-ish repository.

 builtin/fsck.c | 35 ++++++++++++++++++++++++++++++-----
 1 file changed, 30 insertions(+), 5 deletions(-)
diff --git a/builtin/fsck.c b/builtin/fsck.c
index bb9a2cd..c1de2a9 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -73,7 +73,32 @@ static int fsck_error_func(struct object *obj, int type, const char *err, ...)
 	return (type == FSCK_WARN) ? 0 : 1;
 }
 
-static struct object_array pending;
+static struct pending_object {
+	unsigned int nr;
+	unsigned int alloc;
+	struct object **objects;
+} pending;
+
+static int max_pending;
+
+static void add_pending(struct object *object)
+{
+	unsigned nr = pending.nr;
+	unsigned alloc = pending.alloc;
+	struct object **objects = pending.objects;
+
+	if (nr >= alloc) {
+		alloc = (alloc + 32) * 2;
+		objects = xrealloc(objects, alloc * sizeof(*objects));
+		pending.alloc = alloc;
+		pending.objects = objects;
+	}
+	objects[nr] = object;
+	pending.nr = ++nr;
+
+	if (max_pending < nr)
+		max_pending = nr;
+}
 
 static int mark_object(struct object *obj, int type, void *data)
 {
@@ -112,7 +137,7 @@ static int mark_object(struct object *obj, int type, void *data)
 		return 1;
 	}
 
-	add_object_array(obj, (void *) parent, &pending);
+	add_pending(obj);
 	return 0;
 }
 
@@ -148,15 +173,15 @@ static int traverse_reachable(void)
 	if (show_progress)
 		progress = start_progress_delay("Checking connectivity", 0, 0, 2);
 	while (pending.nr) {
-		struct object_array_entry *entry;
-		struct object *obj;
+		struct object **entry, *obj;
 
 		entry = pending.objects + --pending.nr;
-		obj = entry->item;
+		obj = *entry;
 		result |= traverse_one_object(obj);
 		display_progress(progress, ++nr);
 	}
 	stop_progress(&progress);
+	fprintf(stderr, "max# pending objects = %d\n", max_pending);
 	return !!result;
 }
 
Previous: Junio C Hamano
Message 77 of 77 in “grep with textconv”
  1. 0/6 grep with textconvMichael J Gruber, Apr 19, 2013
  2. 1/6 t4030: demonstrate behavior of show with textconvMichael J Gruber, Apr 19, 2013
  3. Jeff KingApr 20, 2013
  4. Michael J GruberApr 20, 2013
  5. 2/6 show: obey --textconv for blobsMichael J Gruber, Apr 19, 2013
  6. Jeff KingApr 20, 2013
  7. Michael J GruberApr 20, 2013
  8. Jeff KingApr 21, 2013
  9. Michael J GruberApr 22, 2013
  10. Junio C HamanoApr 22, 2013
  11. Jeff KingApr 22, 2013
  12. Jeremy RosenApr 22, 2013
  13. Matthieu MoyApr 22, 2013
  14. Michael J GruberApr 23, 2013
  15. 3/6 cat-file: do not die on --textconv without textconv filtersMichael J Gruber, Apr 19, 2013
  16. Junio C HamanoApr 19, 2013
  17. Jeff KingApr 20, 2013
  18. Michael J GruberApr 20, 2013
  19. 4/6 t7008: demonstrate behavior of grep with textconvMichael J Gruber, Apr 19, 2013
  20. 5/6 grep: allow to use textconv filtersMichael J Gruber, Apr 19, 2013
  21. Jeff KingApr 20, 2013
  22. 6/6 grep: obey --textconv for the case rev:pathMichael J Gruber, Apr 19, 2013
  23. Jeff KingApr 20, 2013
  24. Michael J GruberApr 20, 2013
  25. Jeff KingApr 21, 2013
  26. Junio C HamanoApr 19, 2013
  27. Jeff KingApr 20, 2013
  28. Michael J GruberApr 20, 2013
  29. 0/7 grep with textconvMichael J Gruber, Apr 23, 2013
  30. 1/7 t4030: demonstrate behavior of show with textconvMichael J Gruber, Apr 23, 2013
  31. Junio C HamanoApr 23, 2013
  32. 2/7 show: obey --textconv for blobsMichael J Gruber, Apr 23, 2013
  33. Junio C HamanoApr 23, 2013
  34. Michael J GruberApr 24, 2013
  35. Junio C HamanoApr 24, 2013
  36. 3/7 cat-file: do not die on --textconv without textconv filtersMichael J Gruber, Apr 23, 2013
  37. Junio C HamanoApr 23, 2013
  38. 4/7 t7008: demonstrate behavior of grep with textconvMichael J Gruber, Apr 23, 2013
  39. Junio C HamanoApr 23, 2013
  40. Michael J GruberApr 24, 2013
  41. Junio C HamanoApr 24, 2013
  42. 5/7 grep: allow to use textconv filtersMichael J Gruber, Apr 23, 2013
  43. 6/7 grep: honor --textconv for the case rev:pathMichael J Gruber, Apr 23, 2013
  44. 7/7 git grep: honor textconv by defaultMichael J Gruber, Apr 23, 2013
  45. Junio C HamanoApr 23, 2013
  46. Michael J GruberApr 24, 2013
  47. Junio C HamanoApr 24, 2013
  48. Matthieu MoyApr 24, 2013
  49. Junio C HamanoApr 24, 2013
  50. Michael J GruberApr 26, 2013
  51. Matthieu MoyApr 26, 2013
  52. Michael J GruberApr 29, 2013
  53. Junio C HamanoApr 29, 2013
  54. 1/7 t4030: demonstrate behavior of show with textconvMichael J Gruber, May 10, 2013
  55. 2/7 diff_opt: track whether flags have been set explicitlyMichael J Gruber, May 10, 2013
  56. Eric SunshineMay 10, 2013
  57. 3/7 show: honor --textconv for blobsMichael J Gruber, May 10, 2013
  58. Junio C HamanoMay 10, 2013
  59. Jeff KingMay 10, 2013
  60. Junio C HamanoMay 10, 2013
  61. Jeff KingMay 11, 2013
  62. Junio C HamanoMay 11, 2013
  63. Michael J GruberMay 11, 2013
  64. Michael J GruberMay 11, 2013
  65. Junio C HamanoMay 13, 2013
  66. Jeff KingMay 13, 2013
  67. Michael J GruberMay 13, 2013
  68. Junio C HamanoMay 13, 2013
  69. Jeff KingMay 16, 2013
  70. Junio C HamanoMay 11, 2013
  71. Michael J GruberMay 12, 2013
  72. 4/7 cat-file: do not die on --textconv without textconv filtersMichael J Gruber, May 10, 2013
  73. 5/7 t7008: demonstrate behavior of grep with textconvMichael J Gruber, May 10, 2013
  74. 6/7 grep: allow to use textconv filtersMichael J Gruber, May 10, 2013
  75. 7/7 grep: honor --textconv for the case rev:pathMichael J Gruber, May 10, 2013
  76. Junio C HamanoMay 10, 2013
  77. Junio C HamanoMay 10, 2013

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.