Re: [PATCH v2] pack-objects: fix performance issues on packing large deltas
- From
Johannes Sixt <j6t@kdbg.org>
- Date
- Jul 26, 2018, 08:12 UTC
- Message-ID
- <c872c664-a078-853d-4ce9-631dfd110c94@kdbg.org>
- In-Reply-To
- <20180722080421.12887-1-pclouds@gmail.com>
Am 22.07.2018 um 10:04 schrieb Nguyễn Thái Ngọc Duy:
Show 10 quoted lines
> + if (size < pack->oe_delta_size_limit) {
> + e->delta_size_ = size;
> + e->delta_size_valid = 1;
> + } else {
> + packing_data_lock(pack);
> + if (!pack->delta_size)
> + ALLOC_ARRAY(pack->delta_size, pack->nr_alloc);
> + packing_data_unlock(pack);
> +
> + pack->delta_size[e - pack->objects] = size;My first thought was that this is wrong (falling prey to the same mistake as the double-checked locking pattern). But after thinking twice over it again, I think that this unprotected access of pack->delta_size is thread-safe.
Of course, I'm assuming that different threads never assign to the same array index.
> + e->delta_size_valid = 0; > + } > }
-- Hannes