From: Johannes Sixt Date: Thu, 26 Jul 2018 08:12:40 GMT Subject: Re: [PATCH v2] pack-objects: fix performance issues on packing large deltas Message-ID: In-Reply-To: <20180722080421.12887-1-pclouds@gmail.com> Am 22.07.2018 um 10:04 schrieb Nguyễn Thái Ngọc Duy: > + 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