nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nano-devel] [PATCH] Optimize the order of struct members


From: Brand Huntsman
Subject: Re: [Nano-devel] [PATCH] Optimize the order of struct members
Date: Thu, 23 Aug 2018 17:08:29 -0600

On Thu, 23 Aug 2018 19:58:50 +0200
Benno Schulenberg <address@hidden> wrote:

> > - Reorder members to reduce padding and wasted RAM, most noticeable
> > on x64  
> 
> How much memory is saved?  When all syntaxes are included and nano
> has opened all src/*.c files.

Most allocators should have multiples of 16 bytes in the low sizes (32,48,64). 
When I checked a while back, I think reordering and removing the bright field 
might have dropped 64bit below the 48 byte point (saving 16 bytes per struct) 
but did nothing for 32bit.

Ordering fields by descending size should be part of the style guide to avoid 
gaps that push the struct to the next bucket size and waste memory.


> > - Put links first so foo->next is a simple dereference  
> 
> Is next really the most used element in all the structures?  I would
> think that for the linestruct it would be the data element.

Every iteration uses next. I can't remember, but [ptr+0] and 
[ptr+any_other_byte_immediate] might be the same instruction on x86.


> > - Replace rex_flags with a bool called ignore_case. This prevents
> > using an entire word boundary in x64.  
> 
> Using a word boundary?  What do you mean?

int is arch word size (32bits on 32bit archs and 64bits on 64bit archs). 
Apparently rex_flags is only used for case and could be stored in 8bits on all 
archs.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]