linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nikolay Borisov <nborisov@suse.com>
To: fdmanana@gmail.com
Cc: linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH] btrfs: Remove BTRFS_INODE_IN_DELALLOC_LIST flag
Date: Thu, 28 May 2020 10:09:19 +0300	[thread overview]
Message-ID: <f836d38d-1bbd-fbce-7979-d0ade0febf31@suse.com> (raw)
In-Reply-To: <CAL3q7H5vZdvgs7Jsu3jp-9BFyv=XyBEJQOE-xytgzmud2we5Gw@mail.gmail.com>



On 27.05.20 г. 22:48 ч., Filipe Manana wrote:
> On Wed, May 27, 2020 at 12:42 PM Nikolay Borisov <nborisov@suse.com> wrote:
>>
>> The flag simply replicates whether btrfs_inode::delallocs_inodes list
>> is empty or not. Just defer this check to the list management functions
>> (btrfs_add_delalloc_inodes/__btrfs_del_delalloc_inode) which are
>> always called under btrfs_root::delalloc_lock.
> 
> The flag is there to avoid taking the root's delalloc_lock spinlock
> everytime a range is marked for delalloc for any inode of the
> subvolume.
> Have you measured performance with very high concurrency of buffered
> writes against files in the same subvolume?
> 
> Thanks.


I performed the following test on a 16-core VM 
(physical cores are 12 on the host): 

fio --direct=0 --ioengine=sync --thread --directory=/media/scratch/ --invalidate=1 --group_reporting=1 \
--fallocate=posix --name=RandomWrites-async-64512-4k-4 --new_group --rw=randwrite --size=50m --numjobs=200 \
--bs=4k --fsync_on_close=0 --fallocate=none --end_fsync=0 --filename_format=FioWorkloads.\$jobnum

And here's what /proc/lock_stat report: 

With BTRFS_INODE_IN_DELALLOC_LIST: 

class name                     con-bounces    contentions   waittime-min   waittime-max waittime-total   waittime-avg    acq-bounces   acquisitions   holdtime-min   holdtime-max holdtime-total   holdtime-avg
 &root->delalloc_lock:           245              245             0.08          4.14          88.10          0.36            62168         122055         0.05          60.41        32721.41           0.27

Fio output:
 WRITE: bw=43.9MiB/s (45.0MB/s), 43.9MiB/s-43.9MiB/s (45.0MB/s-45.0MB/s), io=9.77GiB (10.5GB), run=228044-228044msec


Without BTRFS_INODE_IN_DELALLOC_LIST:
class name                           con-bounces    contentions   waittime-min   waittime-max waittime-total   waittime-avg    acq-bounces   acquisitions   holdtime-min   holdtime-max holdtime-total   holdtime-avg
 &root->delalloc_lock:                   8824          8838           0.05           210.92        3451.03           0.39        2542011        2685019           0.03         301.63      451369.98           0.17

  WRITE: bw=33.8MiB/s (35.5MB/s), 33.8MiB/s-33.8MiB/s (35.5MB/s-35.5MB/s), io=9.77GiB (10.5GB), run=295770-295770msec


So yeah, it does have noticeable effect, and massively reduces lock contentions on the delalloc_lock but 
it increases the critical section, due to the added avg times. But the improvement in performance 
in terms of throughput and reduced acquires/contentions is indisputable. So yeah, this patch 
should be dropped. 

Thanks for spotting this. 

      parent reply	other threads:[~2020-05-28  7:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-27 10:11 [PATCH] btrfs: Remove BTRFS_INODE_IN_DELALLOC_LIST flag Nikolay Borisov
2020-05-27 14:03 ` David Sterba
2020-05-27 19:48 ` Filipe Manana
2020-05-27 21:24   ` David Sterba
2020-05-28  7:09   ` Nikolay Borisov [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=f836d38d-1bbd-fbce-7979-d0ade0febf31@suse.com \
    --to=nborisov@suse.com \
    --cc=fdmanana@gmail.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;
as well as URLs for NNTP newsgroup(s).