From e2287f35db7504f85334884efa038abe7c7a6a8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Sat, 19 Feb 2022 15:12:31 +0100 Subject: [PATCH] spa: support: loop: move struct members Move the boolean members of `struct source_impl` to the end of the struct. This changes the size of the struct from 104 bytes to 96 bytes on x86-64. Before: struct source_impl { struct spa_source source; /* 0 48 */ struct impl * impl; /* 48 8 */ struct spa_list link; /* 56 16 */ /* --- cacheline 1 boundary (64 bytes) was 8 bytes ago --- */ _Bool close; /* 72 1 */ /* XXX 7 bytes hole, try to pack */ union { spa_source_io_func_t io; /* 80 8 */ spa_source_idle_func_t idle; /* 80 8 */ spa_source_event_func_t event; /* 80 8 */ spa_source_timer_func_t timer; /* 80 8 */ spa_source_signal_func_t signal; /* 80 8 */ } func; /* 80 8 */ _Bool enabled; /* 88 1 */ /* XXX 7 bytes hole, try to pack */ struct spa_source * fallback; /* 96 8 */ /* size: 104, cachelines: 2, members: 7 */ /* sum members: 90, holes: 2, sum holes: 14 */ /* last cacheline: 40 bytes */ }; After: struct source_impl { struct spa_source source; /* 0 48 */ struct impl * impl; /* 48 8 */ struct spa_list link; /* 56 16 */ /* --- cacheline 1 boundary (64 bytes) was 8 bytes ago --- */ union { spa_source_io_func_t io; /* 72 8 */ spa_source_idle_func_t idle; /* 72 8 */ spa_source_event_func_t event; /* 72 8 */ spa_source_timer_func_t timer; /* 72 8 */ spa_source_signal_func_t signal; /* 72 8 */ } func; /* 72 8 */ struct spa_source * fallback; /* 80 8 */ _Bool close; /* 88 1 */ _Bool enabled; /* 89 1 */ /* size: 96, cachelines: 2, members: 7 */ /* padding: 6 */ /* last cacheline: 32 bytes */ }; --- spa/plugins/support/loop.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spa/plugins/support/loop.c b/spa/plugins/support/loop.c index 04739eb2a..444b57028 100644 --- a/spa/plugins/support/loop.c +++ b/spa/plugins/support/loop.c @@ -98,7 +98,6 @@ struct source_impl { struct impl *impl; struct spa_list link; - bool close; union { spa_source_io_func_t io; spa_source_idle_func_t idle; @@ -106,8 +105,11 @@ struct source_impl { spa_source_timer_func_t timer; spa_source_signal_func_t signal; } func; - bool enabled; + struct spa_source *fallback; + + bool close; + bool enabled; }; /** \endcond */