public inbox for ~johnnyrichard/olang-devel@lists.sr.ht
 help / color / mirror / code / Atom feed
From: Johnny Richard <johnny@johnnyrichard.com>
To: Carlos Maniero <carlos@maniero.me>
Cc: ~johnnyrichard/olang-devel@lists.sr.ht
Subject: Re: [PATCH olang v3] arena: optimization: ensure alignment memory access
Date: Wed, 28 Feb 2024 19:25:44 +0100	[thread overview]
Message-ID: <ovryacc4s52nw3j45tlhlhmh3kpb725ivzudx23767dpcozvsk@r4t7fhltokiy> (raw)
In-Reply-To: <20240228142534.1810524-1-carlos@maniero.me>

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 <johnny@johnnyrichard.com>

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?

  parent reply	other threads:[~2024-02-28 17:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-28 14:25 Carlos Maniero
2024-02-28 14:26 ` [olang/patches/.build.yml] build success builds.sr.ht
2024-02-28 18:25 ` Johnny Richard [this message]
2024-02-28 19:59   ` [PATCH olang v3] arena: optimization: ensure alignment memory access Carlos Maniero
2024-02-28 22:39     ` Johnny Richard

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=ovryacc4s52nw3j45tlhlhmh3kpb725ivzudx23767dpcozvsk@r4t7fhltokiy \
    --to=johnny@johnnyrichard.com \
    --cc=carlos@maniero.me \
    --cc=~johnnyrichard/olang-devel@lists.sr.ht \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.johnnyrichard.com/olang.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox