Re: [PATCH] btrfs: add special case to setget helpers for 64k pages
From: David Sterba <hidden>
Date: 2021-07-02 11:09:04
On Fri, Jul 02, 2021 at 08:10:50AM +0100, Christoph Hellwig wrote:
quoted
+ if (INLINE_EXTENT_BUFFER_PAGES == 1) { \ return get_unaligned_le##bits(token->kaddr + oip); \ + } else { \No need for an else after the return and thus no need for all the reformatting.
That leads to worse code, compiler does not eliminate the block that would otherwise be in the else block. Measured on x86_64 with instrumented code to force INLINE_EXTENT_BUFFER_PAGES = 1 this adds +1100 bytes of code and has impact on stack consumption. That the code that is in two branches that do not share any code is maybe not pretty but the compiler did what I expected. The set/get helpers get called a lot and are performance sensitive. This patch pre (original version), post (with dropped else): 1156210 19305 14912 1190427 122a1b pre/btrfs.ko 1157386 19305 14912 1191603 122eb3 post/btrfs.ko DELTA: +1176 And effect on function stacks: btrfs_set_token_32 +8 (48 -> 56) btrfs_set_token_64 +16 (48 -> 64) btrfs_set_32 +32 (32 -> 64) btrfs_set_16 +32 (32 -> 64) btrfs_set_token_16 +8 (48 -> 56) btrfs_set_64 +40 (32 -> 72) btrfs_set_token_8 -8 (48 -> 40)