Re: [PATCH 07/12] fetch-pack: cache results of for_each_alternate_ref

2017-01-25 Thread Jeff King
On Wed, Jan 25, 2017 at 11:21:11AM -0800, Junio C Hamano wrote: > > diff --git a/object.h b/object.h > > index 614a00675..f52957dcb 100644 > > --- a/object.h > > +++ b/object.h > > @@ -29,7 +29,7 @@ struct object_array { > > /* > > * object flag allocation: > > * revision.h:

Re: [PATCH 07/12] fetch-pack: cache results of for_each_alternate_ref

2017-01-25 Thread Junio C Hamano
Jeff King writes: > +struct alternate_object_cache { > + struct object **items; > + size_t nr, alloc; > +}; > + > +static void cache_one_alternate(const char *refname, > + const struct object_id *oid, > + void

[PATCH 07/12] fetch-pack: cache results of for_each_alternate_ref

2017-01-23 Thread Jeff King
We may run for_each_alternate_ref() twice, once in find_common() and once in everything_local(). This operation can be expensive, because it involves running a sub-process which must freshly load all of the alternate's refs from disk. Let's cache and reuse the results between the two calls. We