Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: ethanlien <ethanlien@synology.com>
Cc: linux-btrfs@vger.kernel.org, cunankimo@gmail.com
Subject: Re: [PATCH v2] btrfs: remove unnecessary EXTENT_UPTODATE state in buffered I/O path
Date: Mon, 22 Aug 2022 13:56:49 +0200	[thread overview]
Message-ID: <20220822115649.GS13489@twin.jikos.cz> (raw)
In-Reply-To: <20220819024408.9714-1-ethanlien@synology.com>

On Fri, Aug 19, 2022 at 10:44:08AM +0800, ethanlien wrote:
> From: Ethan Lien <ethanlien@synology.com>
> 
> After we copied data to page cache in buffered I/O, we
> 1. Insert a EXTENT_UPTODATE state into inode's io_tree, by
>    endio_readpage_release_extent(), set_extent_delalloc() or
>    set_extent_defrag().
> 2. Set page uptodate before we unlock the page.
> 
> But the only place we check io_tree's EXTENT_UPTODATE state is in
> btrfs_do_readpage(). We know we enter btrfs_do_readpage() only when we
> have a non-uptodate page, so it is unnecessary to set EXTENT_UPTODATE.
> 
> For example, when performing a buffered random read:
> 
> 	fio --rw=randread --ioengine=libaio --direct=0 --numjobs=4 \
> 		--filesize=32G --size=4G --bs=4k --name=job \
> 		--filename=/mnt/file --name=job
> 
> Then check how many extent_state in io_tree:
> 
> 	cat /proc/slabinfo | grep btrfs_extent_state | awk '{print $2}'
> 
> w/o this patch, we got 640567 btrfs_extent_state.
> w/  this patch, we got    204 btrfs_extent_state.
> 
> Maintaining such a big tree brings overhead since every I/O needs to insert
> EXTENT_LOCKED, insert EXTENT_UPTODATE, then remove EXTENT_LOCKED. And in
> every insert or remove, we need to lock io_tree, do tree search, alloc or
> dealloc extent states. By removing unnecessary EXTENT_UPTODATE, we keep
> io_tree in a minimal size and reduce overhead when performing buffered I/O.
> 
> Signed-off-by: Ethan Lien <ethanlien@synology.com>
> Reviewed-by: Robbie Ko <robbieko@synology.com>
> ---
> 
> V2: Remove set_extent_uptodate() from btrfs_get_extent(), and when we found
>     a inline extent, set page uptodate in btrfs_do_readpage().

Added to misc-next, thanks.

      parent reply	other threads:[~2022-08-22 12:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-19  2:44 [PATCH v2] btrfs: remove unnecessary EXTENT_UPTODATE state in buffered I/O path ethanlien
2022-08-19 16:42 ` Filipe Manana
2022-08-22 11:56 ` David Sterba [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 \
    --in-reply-to=20220822115649.GS13489@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=cunankimo@gmail.com \
    --cc=ethanlien@synology.com \
    --cc=linux-btrfs@vger.kernel.org \
    /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