Re: [PATCH 2/3] commit-slab: avoid large realloc

2013-04-14 Thread Junio C Hamano
Jeff King writes: > Yes, but isn't that a constant: > > (512*1024-32) / sizeof(struct commit_slab_piece) > > Leaving it as such lets the compiler optimize better, and is safe from > anybody changing it at runtime. But I think the answer to my question is > "yes, that would be the best thing for

Re: [PATCH 2/3] commit-slab: avoid large realloc

2013-04-14 Thread Jeff King
On Sun, Apr 14, 2013 at 11:51:40AM -0700, Junio C Hamano wrote: > > I don't know if shrinking the size of the realloc is all that big a > > deal. We are doubling, so the allocation cost is already amortized > > constant time. > > I was more disturbed about copying the actual bytes. One of the > e

Re: [PATCH 2/3] commit-slab: avoid large realloc

2013-04-14 Thread Junio C Hamano
Jeff King writes: > On Sat, Apr 13, 2013 at 11:04:48PM -0700, Junio C Hamano wrote: > >> Instead of using a single "slab" and keep reallocating it as we find >> that we need to deal with commits with larger values of commit->index, >> make a "slab" an array of many "slab_piece"s. Each access may

Re: [PATCH 2/3] commit-slab: avoid large realloc

2013-04-14 Thread Jeff King
On Sat, Apr 13, 2013 at 11:04:48PM -0700, Junio C Hamano wrote: > Instead of using a single "slab" and keep reallocating it as we find > that we need to deal with commits with larger values of commit->index, > make a "slab" an array of many "slab_piece"s. Each access may need > two levels of indir

[PATCH 2/3] commit-slab: avoid large realloc

2013-04-13 Thread Junio C Hamano
Instead of using a single "slab" and keep reallocating it as we find that we need to deal with commits with larger values of commit->index, make a "slab" an array of many "slab_piece"s. Each access may need two levels of indirections, but we only need to reallocate the first level array of pointers