From: arlie@worldash.org (Arlie Stephens)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Work (really slow directory access on ext4)
Date: Fri, 25 Jul 2014 18:08:35 -0700 [thread overview]
Message-ID: <20140726010835.GA3181@worldash.org> (raw)
In-Reply-To: <28795.1406331350@turing-police.cc.vt.edu>
On Jul 25 2014, Valdis.Kletnieks at vt.edu wrote:
> On Fri, 25 Jul 2014 15:23:42 -0700, Arlie Stephens said:
>
> > If you want an annoying problem, explain and/or fix directory
> > performance on ext4. I've got a server where an ls of a directory took
> > 5 seconds, according to "time", even though it only has 295 entries at
> > present.
>
> I don't suppose you could get a trace of where that ls is spending its
> time with the kernel's trace facilities, or even just getting a stack trace
> of where that ls is in the kernel?
These are all very good questions.
To my amazement, I found that no one had yet fixed the problem by
deleting and recreating the directory, and I do have sudo access.
This time it was only 4 seconds...
real 0m3.992s
user 0m0.005s
sys 0m0.052s
> I'll go out on a limb and ask if a *second* ls of the same directory runs
> quickly because it's now cache-hot. If so, I'd start looking at whether
> there's large amounts of *other* disk activity going on, and the reads of the
> directory are getting hung in the I/O queue behind other disk
> read/writes.
Sure enough, the cache saved me on a second read -
real 0m0.010s
user 0m0.000s
sys 0m0.010s
> Also, are you doing an 'ls' (which just requires reading the name/inode#
> pairs), or an 'ls -l' whihc in addition requires a stat() call to read in the
> inode itself)? That makes a lot of difference. Cache-cold on my laptop, and a
> *huge* Mail/linux-kernel directory (yes, it really *is* an 11M directory,
> it's got a half-million entries in it):
I was doing a vanilla ls. So was the original reporter, unless he has
some really strange aliases.
I'm afraid I'll be rather unpopular if I drop the caches on the system
in question, creating a burst of poor performance, so my best bet is
probably to see what I can do with ftrace on Monday, or perhaps
partway through the weekend.
There is normally a fair amount of disk activity going on - much of it
writes. So I can expect cached blocks to age out in a reasonable time.
> [~] echo 3 >| /proc/sys/vm/drop_caches
> [~] cd Mail
> [~/Mail] time ls linux-kernel/ | wc -l
> 478401
>
> real 0m2.387s
> user 0m0.500s
> sys 0m0.433s
> [~/Mail] ls -ld linux-kernel/
> drwxr-xr-x. 2 valdis valdis 11005952 Jul 25 19:30 linux-kernel/
Compared to your directory, mine is microscopic
$ ls -ld xxxx
drwxr-xr-x 2 yyy yyy 36864 Jul 25 12:19 xxxx
> [~/Mail] time ls -l linux-kernel/ | wc -l
> 478402
>
> real 0m32.915s
> user 0m2.483s
> sys 0m20.787s
--
Arlie
(Arlie Stephens arlie at worldash.org)
next prev parent reply other threads:[~2014-07-26 1:08 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-24 16:38 Work Nick Krause
2014-07-24 16:43 ` Work Kristofer Hallin
2014-07-24 16:44 ` Work Lucas Tanure
2014-07-24 16:47 ` Work Nick Krause
2014-07-26 21:13 ` Work Yi Li
2014-07-26 21:55 ` Work Lucas Tanure
2014-07-24 16:51 ` Work Andev
2014-07-24 17:10 ` Work Nick Krause
2014-07-25 2:23 ` Work Nick Krause
2014-07-25 5:33 ` Work ravi ranjan Mishra
2014-07-25 11:44 ` Work Lucas Tanure
2014-07-25 12:17 ` Work Robert P. J. Day
2014-07-25 15:19 ` Work Nick Krause
2014-07-25 17:18 ` Work Robert P. J. Day
2014-07-25 17:28 ` Work Valdis.Kletnieks at vt.edu
2014-07-25 17:42 ` Work Valdis.Kletnieks at vt.edu
2014-07-25 21:54 ` Work Nick Krause
2014-07-25 22:23 ` Work Arlie Stephens
2014-07-25 23:02 ` Work Nick Krause
2014-07-25 23:35 ` Work Valdis.Kletnieks at vt.edu
2014-07-25 23:44 ` Work Nick Krause
2014-07-26 1:08 ` Arlie Stephens [this message]
2014-07-26 1:22 ` Work (really slow directory access on ext4) Nick Krause
2014-07-30 2:34 ` Nick Krause
2014-07-30 17:38 ` Arlie Stephens
2014-07-30 19:48 ` Valdis.Kletnieks at vt.edu
2014-07-30 20:45 ` Nick Krause
2014-07-31 23:36 ` Arlie Stephens
2014-07-31 23:41 ` Henry Hallam
2014-08-01 1:47 ` Nick Krause
-- strict thread matches above, loose matches on Subject: below --
2014-08-06 14:49 Theodore Ts'o
2014-08-06 18:26 ` Arlie Stephens
2014-08-06 19:29 ` Nick Krause
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=20140726010835.GA3181@worldash.org \
--to=arlie@worldash.org \
--cc=kernelnewbies@lists.kernelnewbies.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).