From: Miao Xie <miaox@cn.fujitsu.com>
To: dsterba@suse.cz, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] Btrfs: allocate the free space by the existed max extent size when ENOSPC
Date: Fri, 30 Aug 2013 18:58:31 +0800 [thread overview]
Message-ID: <52207AD7.6010008@cn.fujitsu.com> (raw)
In-Reply-To: <20130829124510.GH23113@twin.jikos.cz>
On thu, 29 Aug 2013 14:45:10 +0200, David Sterba wrote:
> On Thu, Aug 29, 2013 at 01:47:38PM +0800, Miao Xie wrote:
>> By the current code, if the requested size is very large, and all the extents
>> in the free space cache are small, we will waste lots of the cpu time to cut
>> the requested size in half and search the cache again and again until it gets
>> down to the size the allocator can return. In fact, we can know the max extent
>> size in the cache after the first search, so we needn't cut the size in half
>> repeatedly, and just use the max extent size directly. This way can save
>> lots of cpu time and make the performance grow up when there are only fragments
>> in the free space cache.
>>
>> According to my test, if there are only 4KB free space extents in the fs,
>> and the total size of those extents are 256MB, we can reduce the execute
>> time of the following test from 5.4s to 1.4s.
>> dd if=/dev/zero of=<testfile> bs=1MB count=1 oflag=sync
>
> Sounds like a good improvement! Can you please post the test? Fragmented
> free space is nothing uncommon, so I guess aging the filesystem for a
> while works as well and there the improvement would show up in reduced
> cpu time.
# mkfs.btrfs -f -b 1g <dev>
# mount <dev> <mnt>
# cd <mnt>
# i=0
# while [ 1 ];
> do
> fallocate -o 0 -l 1M tmpfile_1M_$i
> if [ $? -ne 0 ]
> then
> break
> fi
> i=$((i+1))
> done
# dd if=/dev/zero of=tmpfile_4K bs=4K oflag=sync
# rm -f tmpfile_1M_{0..511}
# i=0
# while [ 1 ];
> do
> fallocate -o 0 -l 4K fragmented_file_4K_$i
> if [ $? -ne 0 ]
> then
> break
> fi
> i=$((i+1))
> done
# i=0
# while [ 1 ];
> do
> rm -f fragmented_file_4K_$i
> i=$((i+2))
> done
Now, we have a fs with 4K-fragmented free space, the free space is 256MB in total.
then, we can do
# dd if=/dev/zero of=<testfile> bs=1MB count=1 oflag=sync
Thanks
Miao
next prev parent reply other threads:[~2013-08-30 10:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-29 5:47 [PATCH] Btrfs: allocate the free space by the existed max extent size when ENOSPC Miao Xie
2013-08-29 12:45 ` David Sterba
2013-08-30 10:58 ` Miao Xie [this message]
2013-08-29 19:34 ` Josef Bacik
-- strict thread matches above, loose matches on Subject: below --
2013-08-30 10:35 Miao Xie
2013-09-06 13:47 ` Stefan Behrens
2013-09-09 6:21 ` Miao Xie
2013-09-09 9:06 ` Stefan Behrens
2013-09-17 13:13 ` David Sterba
2013-09-18 4:04 ` Miao Xie
2013-09-20 9:25 ` David Sterba
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=52207AD7.6010008@cn.fujitsu.com \
--to=miaox@cn.fujitsu.com \
--cc=dsterba@suse.cz \
--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).