linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC 1/2] ext4: speed-up truncate/unlink
@ 2012-09-17 21:00 Andrey Sidorov
  2012-09-18  4:10 ` Theodore Ts'o
  0 siblings, 1 reply; 4+ messages in thread
From: Andrey Sidorov @ 2012-09-17 21:00 UTC (permalink / raw)
  To: linux-ext4

Do not iterate over data blocks scanning for bh's to forget as they're
never exist. This improves time taken by unlink / truncate syscall.
Tested by continuously truncating file that is being written by dd.
Another test is rm -rf of linux tree while tar unpacks it. With
ordered data mode condition unlikely(!tbh) was always met in
ext4_free_blocks. With journal data mode tbh was found only few times,
so optimisation is also possible.

Unlinking fallocated 60G file after doing sync && echo 3 >
/proc/sys/vm/drop_caches && time rm --help

X86 before (linux 3.6-rc4):
# time rm -f test1
real    0m2.710s
user    0m0.000s
sys     0m1.530s

X86 after:
# time rm -f test1
real    0m0.644s
user    0m0.003s
sys     0m0.060s

MIPS before (linux 2.6.37):
# time rm -f test1
real    0m 4.93s
user    0m 0.00s
sys     0m 4.61s

MIPS after:
# time rm -f test1
real    0m 0.16s
user    0m 0.00s
sys     0m 0.06s

---
 fs/ext4/extents.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Index: linux-3.6-rc6/fs/ext4/extents.c
===================================================================
--- linux-3.6-rc6.orig/fs/ext4/extents.c	2012-09-17 12:08:48.842901966 -0400
+++ linux-3.6-rc6/fs/ext4/extents.c	2012-09-17 12:09:43.403630792 -0400
@@ -2274,10 +2274,13 @@ static int ext4_remove_blocks(handle_t *
 	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
 	unsigned short ee_len =  ext4_ext_get_actual_len(ex);
 	ext4_fsblk_t pblk;
-	int flags = EXT4_FREE_BLOCKS_FORGET;
+	int flags = 0;

 	if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode))
-		flags |= EXT4_FREE_BLOCKS_METADATA;
+		flags |= EXT4_FREE_BLOCKS_METADATA | EXT4_FREE_BLOCKS_FORGET;
+	else if (ext4_should_journal_data(inode))
+		flags |= EXT4_FREE_BLOCKS_FORGET;
+
 	/*
 	 * For bigalloc file systems, we never free a partial cluster
 	 * at the beginning of the extent.  Instead, we make a note

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

* Re: [PATCH RFC 1/2] ext4: speed-up truncate/unlink
  2012-09-17 21:00 [PATCH RFC 1/2] ext4: speed-up truncate/unlink Andrey Sidorov
@ 2012-09-18  4:10 ` Theodore Ts'o
  2012-09-18 18:17   ` Andrey Sidorov
  0 siblings, 1 reply; 4+ messages in thread
From: Theodore Ts'o @ 2012-09-18  4:10 UTC (permalink / raw)
  To: Andrey Sidorov; +Cc: linux-ext4

On Tue, Sep 18, 2012 at 01:00:30AM +0400, Andrey Sidorov wrote:
> Do not iterate over data blocks scanning for bh's to forget as they're
> never exist. This improves time taken by unlink / truncate syscall.
> Tested by continuously truncating file that is being written by dd.
> Another test is rm -rf of linux tree while tar unpacks it. With
> ordered data mode condition unlikely(!tbh) was always met in
> ext4_free_blocks. With journal data mode tbh was found only few times,
> so optimisation is also possible.

Thanks for this patch.  It's good you did the testing, although from a
theoretical point of view I'm sure it's sound because the only case
where journal=data mode will there be data blocks in the buffer cache.
In the other cases, the data is cached in the page cache, so it's a
waste of time looking up the blocks so they can be bforgotten.

The one thing which is missing from your patch is a Signed-off-by:
footer.  This has a specific legal meaning.  See:

	http://elinux.org/Developer_Certificate_Of_Origin

You don't need to resend this patch, though; just reply with an
acknowledgement that you agree to add your DCO to the patch:

Signed-off-by: Andrey Sidorov <qrxd43@motorola.com>


Thanks for contributing to the ext4 file system!

						- Ted

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

* Re: [PATCH RFC 1/2] ext4: speed-up truncate/unlink
  2012-09-18  4:10 ` Theodore Ts'o
@ 2012-09-18 18:17   ` Andrey Sidorov
  2012-09-19 18:16     ` Theodore Ts'o
  0 siblings, 1 reply; 4+ messages in thread
From: Andrey Sidorov @ 2012-09-18 18:17 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: linux-ext4

On Tue, Sep 18, 2012 at 12:10 AM, Theodore Ts'o <tytso@mit.edu> wrote:
> The one thing which is missing from your patch is a Signed-off-by:
> footer.  This has a specific legal meaning.  See:
>
>         http://elinux.org/Developer_Certificate_Of_Origin
>
> You don't need to resend this patch, though; just reply with an
> acknowledgement that you agree to add your DCO to the patch:
>
> Signed-off-by: Andrey Sidorov <qrxd43@motorola.com>
>
>
> Thanks for contributing to the ext4 file system!
>
>                                                 - Ted

Hi Ted,

Yes, please add
Signed-off-by: Andrey Sidorov <qrxd43@motorola.com>

Thanks!

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

* Re: [PATCH RFC 1/2] ext4: speed-up truncate/unlink
  2012-09-18 18:17   ` Andrey Sidorov
@ 2012-09-19 18:16     ` Theodore Ts'o
  0 siblings, 0 replies; 4+ messages in thread
From: Theodore Ts'o @ 2012-09-19 18:16 UTC (permalink / raw)
  To: Andrey Sidorov; +Cc: linux-ext4

On Tue, Sep 18, 2012 at 02:17:09PM -0400, Andrey Sidorov wrote:
> 
> Yes, please add
> Signed-off-by: Andrey Sidorov <qrxd43@motorola.com>

Thanks, applied.

I am interested in your proposed patch 2/2 as well, but it's going to
require more detailed review, and it sounds like you were planning on
doing some work to better handle corner cases as well?

						- Ted

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

end of thread, other threads:[~2012-09-19 18:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-17 21:00 [PATCH RFC 1/2] ext4: speed-up truncate/unlink Andrey Sidorov
2012-09-18  4:10 ` Theodore Ts'o
2012-09-18 18:17   ` Andrey Sidorov
2012-09-19 18:16     ` Theodore Ts'o

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