Re: regression in multi-threaded git-pack-index
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 19, 2013, 17:58 UTC
- Message-ID
- <7v1ubbjmq7.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <87obef2wut.fsf@pctrast.inf.ethz.ch>
Thomas Rast <trast@student.ethz.ch> writes:
Show 6 quoted lines
> Actually scratch that again. It *is* a stack overflow, except that this > is a thread stack, for which the OS X defaults are 512kB apparently, as > opposed to 2MB on linux. > ... > And indeed the following patch fixes it. Sounds like the delta > unpacking needs a rewrite to support stackless operation. Sigh.
Yikes. Thanks for digging it to the bottom.
I am not sure if I want to carry this patch in its current form, though. As this episode demonstrates, no default is good enough for everybody, and I am not sure if a configuration variable is a good way to go, either.
Show 24 quoted lines
>
> diff --git i/builtin/index-pack.c w/builtin/index-pack.c
> index 6be99e2..f73291f 100644
> --- i/builtin/index-pack.c
> +++ w/builtin/index-pack.c
> @@ -1075,13 +1075,17 @@ static void resolve_deltas(void)
> nr_dispatched = 0;
> if (nr_threads > 1 || getenv("GIT_FORCE_THREADS")) {
> init_thread();
> + pthread_attr_t attr;
> + pthread_attr_init(&attr);
> + pthread_attr_setstacksize(&attr, 2*1024*1024);
> for (i = 0; i < nr_threads; i++) {
> - int ret = pthread_create(&thread_data[i].thread, NULL,
> + int ret = pthread_create(&thread_data[i].thread, &attr,
> threaded_second_pass, thread_data + i);
> if (ret)
> die(_("unable to create thread: %s"),
> strerror(ret));
> }
> + pthread_attr_destroy(&attr);
> for (i = 0; i < nr_threads; i++)
> pthread_join(thread_data[i].thread, NULL);
> cleanup_thread();