From: Pavel Begunkov <[email protected]>
To: JackieLiu <[email protected]>
Cc: [email protected], [email protected]
Subject: Re: [PATCH RESEND] io_uring: a small optimization for REQ_F_DRAIN_LINK
Date: Fri, 22 Nov 2019 13:54:55 +0300 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
On 11/22/2019 1:26 PM, JackieLiu wrote:
>> Not sure about that. It's 1 CMP + 1 SETcc/STORE, which works pretty fast
>> as @drain_next is hot (especially after read) and there is no write-read
>> dependency close. For yours, there is likely always 3 CMPs in the way.
>>
>> Did you benchmarked it somehow or compared assembly?
>
> It is only theoretically possible. In most cases, our drain_link
> and drain_next are both false, so only two CMPs are needed, and modern CPUs
> have branch predictions. Perhaps these judgments can be optimized.
>
My bad, right, 2 CMPs in the common way.
> Your code is very nice, when I reading and understanding your code,
> I want to try if there is any other way to optimize it.
>
> Sometimes you don't need to reset drain_next, such as drain_link == true &&
> drain_next == true, you don't need to set below one more time.
We may think to change like below, but I'd rather rely on a compiler to
optimise it for us (i.e. knowing the target architecture). Everything
else is a really rare/slow path in my opinion, so shouldn't be of concern.
- req->ctx->drain_next = (req->flags & REQ_F_DRAIN_LINK);
+ if (req->flags & REQ_F_DRAIN_LINK)
+ req->ctx->drain_next = true;
If the goal is to micro-optimise things, it's better to think how to
toss the whole scheme to reduce number of CMPs and memory read/writes in
the hot path, including setting REQ_F_DRAIN_LINK in submit_sqe().
Though, there are still heavier things happening around.
--
Pavel Begunkov
prev parent reply other threads:[~2019-11-22 11:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-22 6:01 [PATCH liburing RESEND] Update link_drain with new kernel method Jackie Liu
2019-11-22 6:01 ` [PATCH RESEND] io_uring: a small optimization for REQ_F_DRAIN_LINK Jackie Liu
2019-11-22 10:05 ` Pavel Begunkov
2019-11-22 10:26 ` JackieLiu
2019-11-22 10:54 ` Pavel Begunkov [this message]
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 \
[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