From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 80B5C469710 for ; Mon, 8 Jun 2020 17:00:49 +0300 (MSK) Received: by mail-lf1-f67.google.com with SMTP id c21so10276635lfb.3 for ; Mon, 08 Jun 2020 07:00:49 -0700 (PDT) Date: Mon, 8 Jun 2020 17:00:46 +0300 From: Cyrill Gorcunov Message-ID: <20200608140046.GG134822@grain> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Tarantool-patches] [PATCH 06/10] region: use aligned allocations where necessary List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vladislav Shpilevoy Cc: tarantool-patches@dev.tarantool.org On Thu, May 21, 2020 at 10:37:29PM +0200, Vladislav Shpilevoy wrote: > Region is used for temporary allocations, usually bound to a > transaction, but not always. Keyword - temporary. It is usually > much faster to allocate something on the region than on the heap, > and much much faster to free the region, since it frees data in > whole slabs. Lots of objects at once. > > Region is used both for byte arrays (MessagePack, strings, blobs), > and for objects like standard types, structs. Almost always for > allocations was used region_alloc() function, which returns a not > aligned address. It can be anything, even not multiple of 2. > > That led to alignment violation for standard types and structs. > Usually it is harmless in terms of errors, but can be slower than > aligned access, and on some platforms may even crash. Also the > crash can be forced using clang undefined behaviour sanitizer, > which revealed all the not aligned accesses fixed in this patch. > > Part of #4609 Reviewed-by: Cyrill Gorcunov