From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Brian Malehorn <bmalehorn@gmail.com>
Cc: linux-ext4@vger.kernel.org
Subject: Re: write() hangs during flush
Date: Wed, 19 Jul 2017 23:22:12 -0700 [thread overview]
Message-ID: <20170720062212.GC4211@magnolia> (raw)
In-Reply-To: <CAJB88a2J+HY_n8=7nJHp9GQ0jVDJdYLw5TPrBxN-ySqnBXNi9g@mail.gmail.com>
On Wed, Jul 19, 2017 at 11:07:08PM -0700, Brian Malehorn wrote:
> Hi,
>
> I'm debugging an issue where write() can sometimes take several
> seconds to complete. I'm looking for general guidance on why this
> might happen, and what I can do about it.
>
> While I originally encountered the problem on an embedded device
> writing to an MMC, I can also reproduce it on my laptop (Ubuntu
> 16.04):
>
> pv -L 100m /dev/zero |
> strace -s 8 -T -e trace=write dd bs=32k of=./zero 2>&1 |
> awk 'substr($NF, 2, length($NF)-2) + 0 > 0.1'
>
> write(1, "\0\0\0\0\0\0\0\0"..., 32768) = 32768 <0.145895>
> write(1, "\0\0\0\0\0\0\0\0"..., 32768) = 32768 <0.673575>
> write(1, "\0\0\0\0\0\0\0\0"..., 32768) = 32768 <0.126722>
> write(1, "\0\0\0\0\0\0\0\0"..., 32768) = 32768 <1.284791>
>
> In the above example, I write 100 MiB / second, and print out any
> write() that took over 100 ms. In the output, the slowest write was
> 1.28 seconds. I can provide more details about the setup if needed.
>
> I believe this is happening:
>
> 1. accumulate lots of data in cache
> 2. filesystem decides to flush
> 3. nobody can write during flush
> 4. flush flushes "a lot" of data - maybe everything
>
> Do my guesses align with reality, or is there another explanation?
>
> Does anybody have ideas on how to make this more "smooth"? Ideally,
> I'd like each write() to be slowed down a little bit, rather than
> 99.99% of writes completing instantly and 0.01% taking over a second.
/proc/sys/vm/dirty* knobs?
--D
>
> Thanks,
> Brian
prev parent reply other threads:[~2017-07-20 6:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-20 6:07 write() hangs during flush Brian Malehorn
2017-07-20 6:22 ` Darrick J. Wong [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=20170720062212.GC4211@magnolia \
--to=darrick.wong@oracle.com \
--cc=bmalehorn@gmail.com \
--cc=linux-ext4@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).