From: Sergey Vlasov <vsu@altlinux.ru>
To: Nicolas Pitre <nico@cam.org>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: pack-objects: Fix segfault when object count is less than thread count
Date: Mon, 21 Jan 2008 20:40:52 +0300 [thread overview]
Message-ID: <20080121174052.GA4627@atlas.home> (raw)
In-Reply-To: <alpine.LFD.1.00.0801211103480.20753@xanadu.home>
[-- Attachment #1: Type: text/plain, Size: 1793 bytes --]
On Mon, Jan 21, 2008 at 11:07:15AM -0500, Nicolas Pitre wrote:
> On Mon, 21 Jan 2008, Sergey Vlasov wrote:
>
> > When partitioning the work amongst threads, dividing the number of
> > objects by the number of threads may return 0 when there are less
> > objects than threads; this will cause the subsequent code to segfault
> > when accessing list[sub_size-1]. Fix this by ensuring that sub_size
> > is not zero if there is at least one object to process.
>
> No. Forcing one object in a thread is counter productive since it won't
> have anything to delta against. Instead, the thread should be allowed
> to have zero objects and let the other threads have more.
>
> This patch would be a proper fix:
>
> diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
> index ec10238..d3efeff 100644
> --- a/builtin-pack-objects.c
> +++ b/builtin-pack-objects.c
> @@ -1672,7 +1672,8 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,
> p[i].data_ready = 0;
>
> /* try to split chunks on "path" boundaries */
> - while (sub_size < list_size && list[sub_size]->hash &&
> + while (sub_size && sub_size < list_size &&
> + list[sub_size]->hash &&
> list[sub_size]->hash == list[sub_size-1]->hash)
> sub_size++;
Actually there will not be any significant differences - with my patch
the object distribution between threads will be 1, 1, ..., 0, 0...,
and with your patch it would be 0, 0, ..., 1, 1, ... (unless the
objects had the same hash, in which case they would be passed to a
single thread in both cases).
We could even introduce some limit on the number of objects below
which multithreaded packing is not attempted, so that packing a small
number of objects would be more efficient.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
next prev parent reply other threads:[~2008-01-21 17:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-21 14:35 pack-objects: Fix segfault when object count is less than thread count Sergey Vlasov
2008-01-21 15:12 ` Johannes Sixt
2008-01-21 16:08 ` Nicolas Pitre
2008-01-21 16:07 ` Nicolas Pitre
2008-01-21 17:40 ` Sergey Vlasov [this message]
2008-01-21 17:53 ` Nicolas Pitre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080121174052.GA4627@atlas.home \
--to=vsu@altlinux.ru \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=nico@cam.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox