From: Duncan <1i5t5.duncan@cox.net>
To: linux-btrfs@vger.kernel.org
Subject: Re: btrfs fi defrag does not defrag files >256kB?
Date: Fri, 29 Jul 2016 03:56:53 +0000 (UTC) [thread overview]
Message-ID: <pan$7c912$9463b0ec$94c17ac2$5933daf0@cox.net> (raw)
In-Reply-To: CAD=QJKgmrd_pmcYPOk6BXstVJ+JSdSwm7s0KEPbLJrezbUCLpw@mail.gmail.com
Nicholas D Steeves posted on Thu, 28 Jul 2016 13:53:31 -0400 as excerpted:
> Additionally, I've read that -o autodefrag doesn't yet work well for
> large databases. Would a supplementary targeted defrag policy be useful
> here? For example: a general cron/systemd.trigger default of "-t 32M",
> and then another job for /var/lib/mysql/ with a policy of "-f -t 1G"?
> Or did your findings also show that large databases did not benefit from
> larger target extent defrags?
That the autodefrag mount option didn't work well with large rewrite-
pattern files like vm images and databases was the previous advice, yes,
but that changed at some point. I'm not sure if autodefrag has always
worked this way and they simply weren't sure before, or if it changed,
but in any case, these days, it doesn't rewrite the entire file, only a
(relatively) larger block of it than the individual 4 KiB block that
would otherwise be rewritten. (I'm not sure what size, perhaps the same
256 KiB that's the kernel default for manual defrag?)
As such, it scales better than it would if the full gig-size (or
whatever) file was being rewritten, altho there will still be some
fragmentation.
And for the same reason, it's actually not as bad with snapshots as it
might have been otherwise, because it only cows/de-reflinks a bit more of
the file than would otherwise be cowed due to the write in any case, so
it doesn't duplicate the entire file as originally feared by some, either.
Tho the only way to be sure would be to try it.
Meanwhile, it's worth noting that autodefrag works best if on from the
beginning, so fragmentation doesn't get ahead of it. Here, I ensure
autodefrag is on from the first time I mount it, while the filesystem is
still empty. That way, fragmentation should never get out of hand,
fragmenting free space so badly that free large extents to defrag into
/can't/ be found, as may be the case if autodefrag isn't turned on until
later and manual defrag hasn't been done regularly either. There have
been a few reports of people waiting to turn it on until the filesystem
is highly fragmented, and then having several days of low performance as
defrag tries to catch up. If it's consistently on from the beginning,
that shouldn't happen.
Of course that may mean backing up and recreating the filesystem fresh in
ordered to have autodefrag on from the beginning, if you're looking at
trying it on existing filesystems that are likely highly fragmented.
--
Duncan - List replies preferred. No HTML msgs.
"Every nonfree program has a lord, a master --
and if you use the program, he is your master." Richard Stallman
prev parent reply other threads:[~2016-07-29 3:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-26 23:03 btrfs fi defrag -r -t 32M? What is actually happening? Nicholas D Steeves
2016-07-27 1:10 ` Duncan
2016-07-27 17:19 ` btrfs fi defrag does not defrag files >256kB? Nicholas D Steeves
2016-07-28 5:14 ` Duncan
2016-07-28 10:55 ` David Sterba
2016-07-28 17:25 ` Duncan
2016-07-28 17:53 ` Nicholas D Steeves
2016-07-29 3:56 ` Duncan [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='pan$7c912$9463b0ec$94c17ac2$5933daf0@cox.net' \
--to=1i5t5.duncan@cox.net \
--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).