public inbox for [email protected]
 help / color / mirror / Atom feed
From: Alviro Iskandar Setiawan <[email protected]>
To: Ammar Faizi <[email protected]>
Cc: Jens Axboe <[email protected]>,
	"Fernanda Ma'rouf" <[email protected]>,
	Hao Xu <[email protected]>,
	Pavel Begunkov <[email protected]>,
	io-uring Mailing List <[email protected]>,
	"GNU/Weeb Mailing List" <[email protected]>
Subject: Re: [PATCH liburing v1 2/2] setup: Mark the exported functions as __cold
Date: Sun, 3 Jul 2022 19:24:27 +0700	[thread overview]
Message-ID: <CAOG64qPR4QKLu8+GgeSBFyDQMUvBCPyZEoRtnMwbu_3dS385DA@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>

On Sun, Jul 3, 2022 at 6:59 PM Ammar Faizi wrote:
>
> From: Ammar Faizi <[email protected]>
>
> These functions are called at initialization, which are slow-paths.
> Mark them as __cold so that the compiler will optimize for code size.
>
> Here is the result compiling with Ubuntu clang
> 15.0.0-++20220601012204+ec2711b35411-1~exp1~20220601012300.510
>
> Without this patch:
>
>   $ wc -c src/liburing.so.2.3
>   71288 src/liburing.so.2.3
>
> With this patch:
>
>   $ wc -c src/liburing.so.2.3
>   69448 src/liburing.so.2.3
>
> Take one slow-path function example, using __cold avoids aggresive
> inlining.
>
> Without this patch:
>
>   00000000000024f0 <io_uring_queue_init>:
>     24f0: pushq  %r14
>     24f2: pushq  %rbx
>     24f3: subq   $0x78,%rsp
>     24f7: movq   %rsi,%r14
>     24fa: xorps  %xmm0,%xmm0
>     24fd: movaps %xmm0,(%rsp)
>     2501: movaps %xmm0,0x60(%rsp)
>     2506: movaps %xmm0,0x50(%rsp)
>     250b: movaps %xmm0,0x40(%rsp)
>     2510: movaps %xmm0,0x30(%rsp)
>     2515: movaps %xmm0,0x20(%rsp)
>     251a: movaps %xmm0,0x10(%rsp)
>     251f: movq   $0x0,0x70(%rsp)
>     2528: movl   %edx,0x8(%rsp)
>     252c: movq   %rsp,%rsi
>     252f: movl   $0x1a9,%eax
>     2534: syscall
>     2536: movq   %rax,%rbx
>     2539: testl  %ebx,%ebx
>     253b: js     256a <io_uring_queue_init+0x7a>
>     253d: movq   %rsp,%rsi
>     2540: movl   %ebx,%edi
>     2542: movq   %r14,%rdx
>     2545: callq  2080 <io_uring_queue_mmap@plt>
>     254a: testl  %eax,%eax
>     254c: je     255d <io_uring_queue_init+0x6d>
>     254e: movl   %eax,%edx
>     2550: movl   $0x3,%eax
>     2555: movl   %ebx,%edi
>     2557: syscall
>     2559: movl   %edx,%ebx
>     255b: jmp    256a <io_uring_queue_init+0x7a>
>     255d: movl   0x14(%rsp),%eax
>     2561: movl   %eax,0xc8(%r14)
>     2568: xorl   %ebx,%ebx
>     256a: movl   %ebx,%eax
>     256c: addq   $0x78,%rsp
>     2570: popq   %rbx
>     2571: popq   %r14
>     2573: retq
>
> With this patch:
>
>   000000000000240c <io_uring_queue_init>:
>     240c: subq   $0x78,%rsp
>     2410: xorps  %xmm0,%xmm0
>     2413: movq   %rsp,%rax
>     2416: movaps %xmm0,(%rax)
>     2419: movaps %xmm0,0x60(%rax)
>     241d: movaps %xmm0,0x50(%rax)
>     2421: movaps %xmm0,0x40(%rax)
>     2425: movaps %xmm0,0x30(%rax)
>     2429: movaps %xmm0,0x20(%rax)
>     242d: movaps %xmm0,0x10(%rax)
>     2431: movq   $0x0,0x70(%rax)
>     2439: movl   %edx,0x8(%rax)
>     243c: movq   %rax,%rdx
>     243f: callq  2090 <io_uring_queue_init_params@plt>
>     2444: addq   $0x78,%rsp
>     2448: retq
>
> Signed-off-by: Ammar Faizi <[email protected]>

Reviewed-by: Alviro Iskandar Setiawan <[email protected]>

tq

-- Viro

  reply	other threads:[~2022-07-03 12:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-03 11:59 [PATCH liburing v1 0/2] __hot and __cold Ammar Faizi
2022-07-03 11:59 ` [PATCH liburing v1 1/2] lib: Add __hot and __cold macros Ammar Faizi
2022-07-03 12:20   ` Alviro Iskandar Setiawan
2022-07-03 11:59 ` [PATCH liburing v1 2/2] setup: Mark the exported functions as __cold Ammar Faizi
2022-07-03 12:24   ` Alviro Iskandar Setiawan [this message]
2022-07-03 13:00 ` [PATCH liburing v1 0/2] __hot and __cold Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAOG64qPR4QKLu8+GgeSBFyDQMUvBCPyZEoRtnMwbu_3dS385DA@mail.gmail.com \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox