From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mail-a.sr.ht; dkim=pass header.d=johnnyrichard.com header.i=@johnnyrichard.com Received: from out-186.mta1.migadu.com (out-186.mta1.migadu.com [IPv6:2001:41d0:203:375::ba]) by mail-a.sr.ht (Postfix) with ESMTPS id 0C3B320322 for <~johnnyrichard/olang-devel@lists.sr.ht>; Wed, 28 Feb 2024 17:25:44 +0000 (UTC) Date: Wed, 28 Feb 2024 19:25:44 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=johnnyrichard.com; s=key1; t=1709141143; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=XzKp0f3FDfq9CTXdElA2vuYQDObbhgUmRdUzKyEWRK8=; b=mNiHRQFTRxqnsgL85m0Cm1WZxP61Mf/enzpFeBpPevNg7HJKTmGyVuQcjDl55NMwZt/bko b+rhDtPN3Rq6UY0JoGtoxTtXZ5o7qcj1Vbdw8PsKHBe70/3fsqpxhsyGkZxNWgVJhG9y2L Zf4/c1A41jZh7xSu2YiyQPP57fGdNelaYOhtRdhpygx2ilO5WJzb/VYT5y84er78kYBCEp HBFCr5icm1vYYsICeeTYIKqSKpbBU3gwTdeiZN9bY86MAtfwWXP0YGA+dR20NENhZT2i88 K8O1ub6q+fE29nPVBvuJ0cOAyrSBc1LB4Ul7v8pI+NlCpJN91MlFI+5zqistNQ== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Johnny Richard To: Carlos Maniero Cc: ~johnnyrichard/olang-devel@lists.sr.ht Subject: Re: [PATCH olang v3] arena: optimization: ensure alignment memory access Message-ID: X-Sourcehut-Patchset-Update: APPLIED References: <20240228142534.1810524-1-carlos@maniero.me> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240228142534.1810524-1-carlos@maniero.me> X-Migadu-Flow: FLOW_OUT X-TUID: xg9lQeCUC97U Fantastic patch, I don't think we need a new revision at all. I have just comments for the commit message. And if you agree on changing it, we can apply then changes when during patch-apply. Let me know what you think. Otherwise I can apply it. Signed-off-by: Johnny Richard On Wed, Feb 28, 2024 at 11:25:34AM -0300, Carlos Maniero wrote: > This commit changes the pointers returned by *arena_alloc* to always be > 16 bytes aligned. Non-aligned data structure could have a huge impact on nitpick: s/Non-aligned/Unaligned/ > performance. Take the example bellow: > > int main() { > void *pointer = malloc(1024); Let's use an "uint8_t *" pointer to be safer here. Pointer arithmetics with "void *" pointers a unpredictable. > > int offset = 0; *int* is not a good type to store a pointer offset since it cannot address all possible offsets. I know that for this test is fine... **size_t** is a better type for this kind of operations. > long long* data = pointer + offset; *long long* might have different size depending on the platform you are running. If you want the example to be more complete you should describe on which platforming you are running this test. > > for (int i = 0; i < INT_MAX; i++) { > *data += i; > } > > printf("result = %lld", *data); > } > > These are the execution times in my machine: Perhaps describe **my machine** details? **x86_64** right?