linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: "Bhatnagar, Rishabh" <risbhat@amazon.com>
Cc: Jan Kara <jack@suse.cz>,
	tytso@mit.edu, akpm@linux-foundation.org, linux-mm@kvack.org,
	linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org,
	abuehaze@amazon.com
Subject: Re: EXT4 IOPS degradation between 4.14 and 5.10
Date: Thu, 26 Jan 2023 10:32:31 +0100	[thread overview]
Message-ID: <20230126093231.ujn6yaxhexwzizp5@quack3> (raw)
In-Reply-To: <053b60a6-133e-5d59-0732-464d5160772a@amazon.com>

Hello!

On Wed 25-01-23 16:33:54, Bhatnagar, Rishabh wrote:
> As discussed in the previous thread I'm chasing IOPS regression between 4.14
> -> 5.10 kernels.
> https://lore.kernel.org/lkml/20230112113820.hjwvieq3ucbwreql@quack3/T/
> <https://lore.kernel.org/lkml/20230112113820.hjwvieq3ucbwreql@quack3/T/>
> 
> Last issue we discussed was difficult to resolve so keeping it on the back
> burner for now.
> 
> I did some more bisecting and saw another series of patches that potentially
> impacts iops score:
> 72b045aecdd856b083521f2a963705b4c2e59680 (mm: implement
> find_get_pages_range_tag())
> 
> Running fio tests on tip as 9c19a9cb1642c074aa8bc7693cd4c038643960ae
> (including the 16 patch series) vs tip as
> 6b4c54e3787bc03e810062bd257a3b05fd9c72d6 (without the above series) shows an
> IOPS jump.

Ok, thanks for pinpointing this. That series landed a long time ago ;).

> Fio with buffered io/fsync=1/randwrite

So I'm curious. Do you have any workload that actually does these
synchronous random buffered IOs? Or is it just a benchmarking exercise?

> With HEAD as 9c19a9cb1642c074aa8bc7693cd4c038643960ae (with the above
> series)
> 
> write: io=445360KB, bw=7418.6KB/s, *iops=463*, runt= 60033msec
> clat (usec): min=4, max=32132, avg=311.90, stdev=1812.74
> lat (usec): min=5, max=32132, avg=312.28, stdev=1812.74
> clat percentiles (usec):
> | 1.00th=[ 8], 5.00th=[ 10], 10.00th=[ 16], 20.00th=[ 25],
> | 30.00th=[ 36], 40.00th=[ 47], 50.00th=[ 60], 60.00th=[ 71],
> | 70.00th=[ 84], 80.00th=[ 97], 90.00th=[ 111], 95.00th=[ 118],
> | 99.00th=[11840], 99.50th=[15936], 99.90th=[21888], 99.95th=[23936],
> 
> With HEAD as 6b4c54e3787bc03e810062bd257a3b05fd9c72d6(without the above
> series)
> 
> write: io=455184KB, bw=7583.4KB/s, *iops=473*, runt= 60024msec
> clat (usec): min=6, max=24325, avg=319.72, stdev=1694.52
> lat (usec): min=6, max=24326, avg=319.99, stdev=1694.53
> clat percentiles (usec):
> | 1.00th=[ 9], 5.00th=[ 11], 10.00th=[ 17], 20.00th=[ 26],
> | 30.00th=[ 38], 40.00th=[ 50], 50.00th=[ 60], 60.00th=[ 73],
> | 70.00th=[ 85], 80.00th=[ 98], 90.00th=[ 111], 95.00th=[ 118],
> | 99.00th=[ 9792], 99.50th=[14016], 99.90th=[21888], 99.95th=[22400],
> | 99.99th=[24192]

OK, about 2% regression. How stable is that across multiple runs?

> I also see that number of handles per transaction were much higher before
> this patch series
> 
> 0ms waiting for transaction
> 0ms request delay
> 20ms running transaction
> 0ms transaction was being locked
> 0ms flushing data (in ordered mode)
> 10ms logging transaction
> *13524us average transaction commit time*
> *73 handles per transaction*
> 0 blocks per transaction
> 1 logged blocks per transaction
> 
> vs after the patch series.
> 
> 0ms waiting for transaction
> 0ms request delay
> 20ms running transaction
> 0ms transaction was being locked
> 0ms flushing data (in ordered mode)
> 20ms logging transaction
> *21468us average transaction commit time*
> *66 handles per transaction*
> 1 blocks per transaction
> 1 logged blocks per transaction
> 
> This is probably again helping in bunching the writeback transactions and
> increasing throughput.

Yeah, probably.

> I looked at the code to understand what might be going on.
> It seems like commit 72b045aecdd856b083521f2a963705b4c2e59680 changes the
> behavior of find_get_pages_range_tag.
> Before this commit if find_get_pages_tag cannot find nr_pages (PAGEVEC_SIZE)
> it returns the number of pages found as ret and
> sets the *index to the last page it found + 1. After the commit the behavior
> changes such that if we don’t find nr_pages pages
> we set the index to end and not to the last found page. (added diff from
> above commit)
> Since pagevec_lookup_range_tag is always called in a while loop (index <=
> end) the code before the commit helps in coalescing
> writeback of pages if there are multiple threads doing write as it might
> keep finding new dirty (tagged) pages since it doesn’t set index to end.
> 
> + /*
> + * We come here when we got at @end. We take care to not overflow the
> + * index @index as it confuses some of the callers. This breaks the
> + * iteration when there is page at index -1 but that is already broken
> + * anyway.
> + */
> + if (end == (pgoff_t)-1)
> + *index = (pgoff_t)-1;
> + else
> + *index = end + 1;
> +out:
> rcu_read_unlock();
> 
> - if (ret)
> - *index = pages[ret - 1]->index + 1;
> -
> 
> From the description of the patch i didn't see any mention of this
> functional change.
> Was this change intentional and did help some usecase or general performance
> improvement?

So the change was intentional. When I was working on the series, I was
somewhat concerned that the old code could end up in a pathological
situation like:
  We scan range 0-1000000, find the only dirty page at index 0, return it.
  We scan range 1-1000000, find the only dirty page at index 1, return it.
  ...

This way we end up with rather inefficient scanning and in theory malicious
user could livelock writeback like this. That being said this was/is mostly
a theoretical concern.

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  reply	other threads:[~2023-01-26  9:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-26  0:33 EXT4 IOPS degradation between 4.14 and 5.10 Bhatnagar, Rishabh
2023-01-26  9:32 ` Jan Kara [this message]
2023-01-26 18:23   ` Bhatnagar, Rishabh
2023-01-27 12:17     ` Jan Kara
2023-01-30 17:45       ` Bhatnagar, Rishabh
2023-02-08 14:02         ` Jan Kara
2023-02-08 19:17           ` Bhatnagar, Rishabh
2023-02-09  8:34             ` Jan Kara
2023-02-08 19:37           ` Theodore Ts'o

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=20230126093231.ujn6yaxhexwzizp5@quack3 \
    --to=jack@suse.cz \
    --cc=abuehaze@amazon.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=risbhat@amazon.com \
    --cc=tytso@mit.edu \
    /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).