intl: Reduce loaded_domain padding

Message ID 20261022193302.3206461-1-ashamil435@gmail.com (mailing list archive)
State New
Headers
Series intl: Reduce loaded_domain padding |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
redhat-pt-bot/TryBot-32bit success Build for i686
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_glibc_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 success Test passed

Commit Message

Shamil Abdulaev Oct. 22, 2026, 7:33 p.m. UTC
  Group use_mmap with must_swap, nstrings with n_sysdep_strings, and
hash_size with must_swap_hash_tab to eliminate six four-byte alignment
gaps on x86-64.  This reduces struct loaded_domain from 200 to 176 bytes,
saving 24 bytes in the allocation request for each opened catalog.

All members and their types are retained.  This changes only the
in-memory catalog descriptor, not the .mo file format.

Signed-off-by: Shamil Abdulaev <ashamil435@gmail.com>
---
 intl/gettextP.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)


base-commit: 9e77a668c94f892f2ce0ad9ef7f6e88525852af3
  

Comments

DJ Delorie Oct. 22, 2026, 10:33 p.m. UTC | #1
This file comes from the GNU gettext package.  We should fix it there
first, then merge the commit from them.  I will add that some of the
fields are grouped by purpose; arbitrarily rearranging them makes the
struct more difficult to understand.
  
Shamil Abdulaev Oct. 22, 2026, 10:57 p.m. UTC | #2
> We should fix it there first, then merge the commit from them.

I won't be able to pursue this in GNU gettext myself. If a corresponding
change is accepted there, I can update the glibc patch accordingly.

пт, 23 окт. 2026 г. в 01:34, DJ Delorie <dj@redhat.com>:

> This file comes from the GNU gettext package.  We should fix it there
> first, then merge the commit from them.  I will add that some of the
> fields are grouped by purpose; arbitrarily rearranging them makes the
> struct more difficult to understand.
>
  

Patch

diff --git a/intl/gettextP.h b/intl/gettextP.h
index bc007e40e2..062f741667 100644
--- a/intl/gettextP.h
+++ b/intl/gettextP.h
@@ -150,22 +150,22 @@  struct loaded_domain
   const char *data;
   /* 1 if the memory is mmap()ed, 0 if the memory is malloc()ed.  */
   int use_mmap;
-  /* Size of mmap()ed memory.  */
-  size_t mmap_size;
   /* 1 if the .mo file uses a different endianness than this machine.  */
   int must_swap;
+  /* Size of mmap()ed memory.  */
+  size_t mmap_size;
   /* Pointer to additional malloc()ed memory.  */
   void *malloced;
 
   /* Number of static strings pairs.  */
   nls_uint32 nstrings;
+  /* Number of system dependent strings pairs.  */
+  nls_uint32 n_sysdep_strings;
   /* Pointer to descriptors of original strings in the file.  */
   const struct string_desc *orig_tab;
   /* Pointer to descriptors of translated strings in the file.  */
   const struct string_desc *trans_tab;
 
-  /* Number of system dependent strings pairs.  */
-  nls_uint32 n_sysdep_strings;
   /* Pointer to descriptors of original sysdep strings.  */
   const struct sysdep_string_desc *orig_sysdep_tab;
   /* Pointer to descriptors of translated sysdep strings.  */
@@ -173,10 +173,10 @@  struct loaded_domain
 
   /* Size of hash table.  */
   nls_uint32 hash_size;
-  /* Pointer to hash table.  */
-  const nls_uint32 *hash_tab;
   /* 1 if the hash table uses a different endianness than this machine.  */
   int must_swap_hash_tab;
+  /* Pointer to hash table.  */
+  const nls_uint32 *hash_tab;
 
   /* Cache of charset conversions of the translated strings.  */
   struct converted_domain *conversions;