intl: Reduce known_translation_t 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
Place counter next to category to eliminate two four-byte alignment gaps
on x86-64 when per-thread locales are enabled. This reduces the size of
struct known_translation_t from 64 to 56 bytes and moves msgid from
offset 56 to offset 48.
Cache entries are allocated using offsetof (struct known_translation_t,
msgid) plus the string lengths, so each allocation request is eight bytes
smaller. The msgid union remains the last member.
Signed-off-by: Shamil Abdulaev <ashamil435@gmail.com>
---
intl/dcigettext.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
base-commit: 9e77a668c94f892f2ce0ad9ef7f6e88525852af3
Comments
On Thu, Oct 22, 2026 at 3:33 PM Shamil Abdulaev <ashamil435@gmail.com> wrote:
> Place counter next to category to eliminate two four-byte alignment gaps
> on x86-64 when per-thread locales are enabled. This reduces the size of
> struct known_translation_t from 64 to 56 bytes and moves msgid from
> offset 56 to offset 48.
>
> Cache entries are allocated using offsetof (struct known_translation_t,
> msgid) plus the string lengths, so each allocation request is eight bytes
> smaller. The msgid union remains the last member.
> - /* State of the catalog counter at the point the string was found. */
> - int counter;
> -
> /* Catalog where the string was found. */
> struct loaded_l10nfile *domain;
"counter" and "domain" are related. I wonder if it would be better
organized to swap "category" and "localename"?
If we're reorganizing things, maybe this is a good time to expand the
comment for "msgid" to say it needs to be last.
Looks good otherwise. Maybe I'm just nit picking ;-)
@@ -225,14 +225,14 @@ struct known_translation_t
/* The category. */
int category;
+ /* State of the catalog counter at the point the string was found. */
+ int counter;
+
#ifdef HAVE_PER_THREAD_LOCALE
/* Name of the relevant locale category, or "" for the global locale. */
const char *localename;
#endif
- /* State of the catalog counter at the point the string was found. */
- int counter;
-
/* Catalog where the string was found. */
struct loaded_l10nfile *domain;