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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Junio C Hamano <gitster@xxxxxxxxx> writes:

> Michael J Gruber <git@xxxxxxxxxxxxxxxxxxxx> 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;
 }
 
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]