diff mbox series

[07/10] btrfs: reduce size of prelim_ref::level

Message ID 270b9ad9e44ece857f8ec5fa006a484459c1fddd.1694126893.git.dsterba@suse.com (mailing list archive)
State New, archived
Headers show
Series Cleanups and struct packing | expand

Commit Message

David Sterba Sept. 7, 2023, 11:09 p.m. UTC
The values of level are bounded and fit into a byte so let's use it for
the structure to reduce size from 88 to 80 bytes on a release build,
which increases number of objects in the default 8K slab from 93 to 102.

struct prelim_ref {
        struct rb_node             rbnode __attribute__((__aligned__(8))); /*     0    24 */
        u64                        root_id;              /*    24     8 */
        struct btrfs_key           key_for_search;       /*    32    17 */
        u8                         level;                /*    49     1 */

        /* XXX 2 bytes hole, try to pack */

        int                        count;                /*    52     4 */
        struct extent_inode_elem * inode_list;           /*    56     8 */
        /* --- cacheline 1 boundary (64 bytes) --- */
        u64                        parent;               /*    64     8 */
        u64                        wanted_disk_byte;     /*    72     8 */

        /* size: 80, cachelines: 2, members: 8 */
        /* sum members: 78, holes: 1, sum holes: 2 */
        /* forced alignments: 1 */
        /* last cacheline: 16 bytes */
} __attribute__((__aligned__(8)));

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/backref.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Qu Wenruo Sept. 8, 2023, 12:01 a.m. UTC | #1
On 2023/9/8 07:09, David Sterba wrote:
> The values of level are bounded and fit into a byte so let's use it for
> the structure to reduce size from 88 to 80 bytes on a release build,
> which increases number of objects in the default 8K slab from 93 to 102.
>
> struct prelim_ref {
>          struct rb_node             rbnode __attribute__((__aligned__(8))); /*     0    24 */
>          u64                        root_id;              /*    24     8 */
>          struct btrfs_key           key_for_search;       /*    32    17 */
>          u8                         level;                /*    49     1 */
>
>          /* XXX 2 bytes hole, try to pack */
>
>          int                        count;                /*    52     4 */
>          struct extent_inode_elem * inode_list;           /*    56     8 */
>          /* --- cacheline 1 boundary (64 bytes) --- */
>          u64                        parent;               /*    64     8 */
>          u64                        wanted_disk_byte;     /*    72     8 */
>
>          /* size: 80, cachelines: 2, members: 8 */
>          /* sum members: 78, holes: 1, sum holes: 2 */
>          /* forced alignments: 1 */
>          /* last cacheline: 16 bytes */
> } __attribute__((__aligned__(8)));
>
> Signed-off-by: David Sterba <dsterba@suse.com>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu
> ---
>   fs/btrfs/backref.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/backref.h b/fs/btrfs/backref.h
> index 1616e3e3f1e4..79742935399f 100644
> --- a/fs/btrfs/backref.h
> +++ b/fs/btrfs/backref.h
> @@ -247,7 +247,7 @@ struct prelim_ref {
>   	struct rb_node rbnode;
>   	u64 root_id;
>   	struct btrfs_key key_for_search;
> -	int level;
> +	u8 level;
>   	int count;
>   	struct extent_inode_elem *inode_list;
>   	u64 parent;
diff mbox series

Patch

diff --git a/fs/btrfs/backref.h b/fs/btrfs/backref.h
index 1616e3e3f1e4..79742935399f 100644
--- a/fs/btrfs/backref.h
+++ b/fs/btrfs/backref.h
@@ -247,7 +247,7 @@  struct prelim_ref {
 	struct rb_node rbnode;
 	u64 root_id;
 	struct btrfs_key key_for_search;
-	int level;
+	u8 level;
 	int count;
 	struct extent_inode_elem *inode_list;
 	u64 parent;