linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-fsdevel@vger.kernel.org, brauner@kernel.org,
	Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: [PATCHSET 0/2] Turn single segment imports into ITER_UBUF
Date: Fri, 24 Mar 2023 15:52:08 -0600	[thread overview]
Message-ID: <45c46ee9-8479-4114-6ce9-ae3082335cb8@kernel.dk> (raw)
In-Reply-To: <CAHk-=wgjPAUwbQ9bf764x6xL8Ht56CGX79OLTG-fCS6u8yLaCA@mail.gmail.com>

On 3/24/23 3:14?PM, Linus Torvalds wrote:
> On Fri, Mar 24, 2023 at 1:44?PM Jens Axboe <axboe@kernel.dk> wrote:
>>
>> We've been doing a few conversions of ITER_IOVEC to ITER_UBUF in select
>> spots, as the latter is cheaper to iterate and hence saves some cycles.
>> I recently experimented [1] with io_uring converting single segment READV
>> and WRITEV into non-vectored variants, as we can save some cycles through
>> that as well.
>>
>> But there's really no reason why we can't just do this further down,
>> enabling it for everyone. It's quite common to use vectored reads or
>> writes even with a single segment, unfortunately, even for cases where
>> there's no specific reason to do so. From a bit of non-scientific
>> testing on a vm on my laptop, I see about 60% of the import_iovec()
>> calls being for a single segment.
> 
> I obviously think this is the RightThing(tm) to do, but it's probably
> too late for 6.3 since there is the worry that somebody "knows" that
> it's a IOVEC somewhere.
> 
> Even if it sounds unlikely, and wrong.

Agree, wasn't really targeting 6.3 though after looking over it, I do
feel better about the whole thing.

I already ran the io_uring test and it showed a nice win, wrote a small
micro benchmark that just does 10M 4k reads from /dev/zero. First
observation from the below numbers is that copying just a single vec is
EXPENSIVE. But I already knew that from the io_uring testing, where
we're spending ~8% just on that alone. Secondly, readv(..., 1) saves
about 3% with the patches in this series.

read-zero takes on argument, which is to do vectored reads or not.

Stock kernel:

axboe@r7525 ~> time taskset -c 0 ./read-zero 0
________________________________________________________
Executed in  859.98 millis    fish           external
   usr time  210.10 millis  291.00 micros  209.81 millis
   sys time  649.42 millis    0.00 micros  649.42 millis

axboe@r7525 ~> time taskset -c 0 ./read-zero 0
________________________________________________________
Executed in  853.82 millis    fish           external
   usr time  228.45 millis  304.00 micros  228.15 millis
   sys time  624.92 millis    0.00 micros  624.92 millis

axboe@r7525 ~> time taskset -c 0 ./read-zero 1
________________________________________________________
Executed in    1.84 secs    fish           external
   usr time    0.21 secs  218.00 micros    0.21 secs
   sys time    1.63 secs  101.00 micros    1.63 secs

axboe@r7525 ~> time taskset -c 0 ./read-zero 1
________________________________________________________
Executed in    1.83 secs    fish           external
   usr time    0.18 secs  594.00 micros    0.18 secs
   sys time    1.64 secs    0.00 micros    1.64 secs

And with the patches:

axboe@r7525 ~> time taskset -c 0 ./read-zero 1
________________________________________________________
Executed in    1.78 secs    fish           external
   usr time    0.22 secs  141.00 micros    0.22 secs
   sys time    1.56 secs  141.00 micros    1.56 secs

axboe@r7525 ~> time taskset -c 0 ./read-zero 1
________________________________________________________
Executed in    1.78 secs    fish           external
   usr time    0.19 secs    0.00 micros    0.19 secs
   sys time    1.59 secs  509.00 micros    1.59 secs

read-zero 0 the same with patches, as expected.

> Adding Al, who tends to be the main iovec person.
> 
> Al, see
> 
>    https://lore.kernel.org/all/20230324204443.45950-1-axboe@kernel.dk/
> 
> for the series if you didn't already see it on fsdevel.

Yep sorry, forgot to add Al.

-- 
Jens Axboe


  reply	other threads:[~2023-03-24 21:52 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-24 20:44 [PATCHSET 0/2] Turn single segment imports into ITER_UBUF Jens Axboe
2023-03-24 20:44 ` [PATCH 1/2] iov_iter: convert import_single_range() to ITER_UBUF Jens Axboe
2023-03-24 20:44 ` [PATCH 2/2] iov_iter: import single vector iovecs as ITER_UBUF Jens Axboe
2023-03-24 21:14 ` [PATCHSET 0/2] Turn single segment imports into ITER_UBUF Linus Torvalds
2023-03-24 21:52   ` Jens Axboe [this message]
2023-03-25  4:46 ` Al Viro
2023-03-27 18:01   ` Jens Axboe
2023-03-27 18:42     ` Al Viro
2023-03-27 18:52       ` Jens Axboe
2023-03-27 18:59         ` Jens Axboe
2023-03-27 20:02           ` Al Viro
2023-03-27 20:03             ` 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=45c46ee9-8479-4114-6ce9-ae3082335cb8@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=brauner@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).