linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Btrfs: avoid unnecessary ordered extent cache resets
@ 2013-11-22 16:52 Filipe David Borba Manana
  2013-11-22 17:29 ` Josef Bacik
  2013-11-22 18:54 ` [PATCH v2] " Filipe David Borba Manana
  0 siblings, 2 replies; 3+ messages in thread
From: Filipe David Borba Manana @ 2013-11-22 16:52 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Filipe David Borba Manana

After an ordered extent completes, don't blindly reset the
inode's ordered tree last accessed ordered extent pointer.

While running the xfstests I noticed that about 29% of the
time the ordered extent to which tree->last pointed was not
the same as our just completed ordered extent. After that I
ran the following sysbench test (after a prepare phase) and
noticed that about 68% of the time tree->last pointed to
a different ordered extent too.

sysbench --test=fileio --file-num=32 --file-total-size=4G \
    --file-test-mode=rndwr --num-threads=512 \
    --file-block-size=32768 --max-time=60 --max-requests=0 run

Therefore reset tree->last on ordered extent removal only if
it pointed to the ordered extent we're removing from the tree.

Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
---
 fs/btrfs/ordered-data.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index 69582d5..b8c2ded 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -520,7 +520,8 @@ void btrfs_remove_ordered_extent(struct inode *inode,
 	spin_lock_irq(&tree->lock);
 	node = &entry->rb_node;
 	rb_erase(node, &tree->tree);
-	tree->last = NULL;
+	if (tree->last == node)
+		tree->last = NULL;
 	set_bit(BTRFS_ORDERED_COMPLETE, &entry->flags);
 	spin_unlock_irq(&tree->lock);
 
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Btrfs: avoid unnecessary ordered extent cache resets
  2013-11-22 16:52 [PATCH] Btrfs: avoid unnecessary ordered extent cache resets Filipe David Borba Manana
@ 2013-11-22 17:29 ` Josef Bacik
  2013-11-22 18:54 ` [PATCH v2] " Filipe David Borba Manana
  1 sibling, 0 replies; 3+ messages in thread
From: Josef Bacik @ 2013-11-22 17:29 UTC (permalink / raw)
  To: Filipe David Borba Manana; +Cc: linux-btrfs

On Fri, Nov 22, 2013 at 04:52:43PM +0000, Filipe David Borba Manana wrote:
> After an ordered extent completes, don't blindly reset the
> inode's ordered tree last accessed ordered extent pointer.
> 
> While running the xfstests I noticed that about 29% of the
> time the ordered extent to which tree->last pointed was not
> the same as our just completed ordered extent. After that I
> ran the following sysbench test (after a prepare phase) and
> noticed that about 68% of the time tree->last pointed to
> a different ordered extent too.
> 
> sysbench --test=fileio --file-num=32 --file-total-size=4G \
>     --file-test-mode=rndwr --num-threads=512 \
>     --file-block-size=32768 --max-time=60 --max-requests=0 run
> 
> Therefore reset tree->last on ordered extent removal only if
> it pointed to the ordered extent we're removing from the tree.
> 

Well this is excellent, how much does it affect performance tho?  I'm still
going to take it, I'd just like to know how big of an impact it makes.  Thanks,

Josef

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2] Btrfs: avoid unnecessary ordered extent cache resets
  2013-11-22 16:52 [PATCH] Btrfs: avoid unnecessary ordered extent cache resets Filipe David Borba Manana
  2013-11-22 17:29 ` Josef Bacik
@ 2013-11-22 18:54 ` Filipe David Borba Manana
  1 sibling, 0 replies; 3+ messages in thread
From: Filipe David Borba Manana @ 2013-11-22 18:54 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Filipe David Borba Manana

After an ordered extent completes, don't blindly reset the
inode's ordered tree last accessed ordered extent pointer.

While running the xfstests I noticed that about 29% of the
time the ordered extent to which tree->last pointed was not
the same as our just completed ordered extent. After that I
ran the following sysbench test (after a prepare phase) and
noticed that about 68% of the time tree->last pointed to
a different ordered extent too.

sysbench --test=fileio --file-num=32 --file-total-size=4G \
    --file-test-mode=rndwr --num-threads=512 \
    --file-block-size=32768 --max-time=60 --max-requests=0 run

Therefore reset tree->last on ordered extent removal only if
it pointed to the ordered extent we're removing from the tree.

Results from 4 runs of the following test before and after
applying this patch:

$ sysbench --test=fileio --file-num=32 --file-total-size=4G \
  --file-test-mode=seqwr --num-threads=512 \
  --file-block-size=32768 --max-time=60 --file-io-mode=sync prepare
$ sysbench --test=fileio --file-num=32 --file-total-size=4G \
  --file-test-mode=seqwr --num-threads=512 \
  --file-block-size=32768 --max-time=60 --file-io-mode=sync run

Before this path:

run 1 - 64.049Mb/sec
run 2 - 63.455Mb/sec
run 3 - 64.656Mb/sec
run 4 - 63.833Mb/sec

After this patch:

run 1 - 66.149Mb/sec
run 2 - 68.459Mb/sec
run 3 - 66.338Mb/sec
run 4 - 66.176Mb/sec

With random writes (--file-test-mode=rndwr) I had huge fluctuations
on the results (+- 35% easily).

Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
---

V2: Updated commit message with benchmark results.

 fs/btrfs/ordered-data.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index 69582d5..b8c2ded 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -520,7 +520,8 @@ void btrfs_remove_ordered_extent(struct inode *inode,
 	spin_lock_irq(&tree->lock);
 	node = &entry->rb_node;
 	rb_erase(node, &tree->tree);
-	tree->last = NULL;
+	if (tree->last == node)
+		tree->last = NULL;
 	set_bit(BTRFS_ORDERED_COMPLETE, &entry->flags);
 	spin_unlock_irq(&tree->lock);
 
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-11-22 18:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-22 16:52 [PATCH] Btrfs: avoid unnecessary ordered extent cache resets Filipe David Borba Manana
2013-11-22 17:29 ` Josef Bacik
2013-11-22 18:54 ` [PATCH v2] " Filipe David Borba Manana

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).