From: Eric Dumazet <dada1@cosmosbay.com>
To: dipankar@in.ibm.com
Cc: Andrew Morton <akpm@osdl.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] : struct dentry : place d_hash close to d_parent and d_name to speedup lookups
Date: Thu, 01 Sep 2005 21:52:09 +0200 [thread overview]
Message-ID: <43175BE9.6030808@cosmosbay.com> (raw)
In-Reply-To: <20050901173634.GA4767@in.ibm.com>
Dipankar Sarma a écrit :
> On Thu, Sep 01, 2005 at 05:48:28PM +0200, Eric Dumazet wrote:
>
>>dentry cache uses sophisticated RCU technology (and prefetching if
>>available) but touches 2 cache lines per dentry during hlist lookup.
>>
>>This patch moves d_hash in the same cache line than d_parent and d_name
>>fields so that :
>>
>>1) One cache line is needed instead of two.
>>2) the hlist_for_each_rcu() prefetching has a chance to bring all the
>>needed data in advance, not only the part that includes d_hash.next.
>>
>>I also changed one old comment that was wrong for 64bits.
>>
>>A further optimisation would be to separate dentry in two parts, one that
>>is mostly read, and one writen (d_count/d_lock) to avoid false sharing on
>>SMP/NUMA but this would need different field placement depending on 32bits
>>or 64bits platform.
>
>
> Do you have performance numbers that show the benefits ? In the
> past, I did try some optimizations like this but found no demonstrable
> benefits. If it ain't broken .....
>
You mean... a microbenchmark ? :)
Well, the dentry cache hash table is so large that it's difficult to see the
benefit, because chain length average is < 1 on most setups.
I suspect the sizing strategy of this hash table was made a long time ago...
Reducing the number of cache lines touched per dentry in lookup could let us
shrink the hash table and save some ram.
Facts now :
------------
On a 512MB ia32 machine, the default sizing of the hash table gives 131072
slots (0.5 MB of ram). So it's quite hard to populate the cache without eating
all ram.
To see a benefit, I had to force a smaller hash size (appending in kernel
params "dhash_entries=8191")
On this 512MB PIII 866MHz machine (L1_CACHE_SIZE=32), with 563887 files or
directories the results are :
Remount the disk with noatime to make sure no disk access will be done
# mount -o remount /dev/hda2 / -o noatime
Populate the caches (dentry and disk buffers for directories)
# find / -name foofoo >/dev/null
# grep dentry_cache /proc/slabinfo
dentry_cache 131104 131370 136 29 1 : tunables 120 60 0 :
slabdata 4530 4530 0
So average chain length is now 16
then time new searches using data in cache
time / -name foofoo >/dev/null
# time find / -name foofoo
real 0m3.077s
user 0m1.724s
sys 0m1.344s
# time find / -name foofoo
real 0m3.077s
user 0m1.728s
sys 0m1.348s
# time find / -name foofoo
real 0m3.084s
user 0m1.784s
sys 0m1.276s
# time find / -name foofoo
real 0m3.108s
user 0m1.716s
sys 0m1.348s
# time find / -name foofoo
real 0m3.061s
user 0m1.672s
sys 0m1.384s
# time find / -name foofoo
real 0m3.067s
user 0m1.644s
sys 0m1.424s
# time find / -name foofoo
real 0m3.061s
user 0m1.804s
sys 0m1.252s
kernel 2.6.13 build time
------------------------
mount -o remount /dev/hda2 /
make clean
time make bzImage
real 12m21.755s
user 11m5.070s
sys 1m0.756s
------------------------------------------------------------------
Results with a patched kernel
# time find / -name foofoo
real 0m3.017s
user 0m1.700s
sys 0m1.316s
# time find / -name foofoo
real 0m3.018s
user 0m1.592s
sys 0m1.424s
# time find / -name foofoo
real 0m3.017s
user 0m1.624s
sys 0m1.396s
# time find / -name foofoo
real 0m3.019s
user 0m1.680s
sys 0m1.340s
# time find / -name foofoo
real 0m3.021s
user 0m1.676s
sys 0m1.344s
# time find / -name foofoo
real 0m3.022s
user 0m1.644s
sys 0m1.376s
# time find / -name foofoo
real 0m3.021s
user 0m1.620s
sys 0m1.404s
kernel 2.6.13 build time
------------------------
mount -o remount /dev/hda2 /
make clean
time make bzImage
real 12m8.814s
user 11m2.129s
sys 0m52.187s
Conclusions:
-----------
1) There is a clear benefit, even without a microbenchmark :)
2) As sizeof(struct dentry)=136 on ia32 UP (140 on SMP), and dentry slab is
not using SLAB_HWCACHE_ALIGN, I suspect lot of dentries are not aligned on a
cache line boundary, so maybe reducing DNAME_INLINE_LEN_MIN (or increasing it)
so that sizeof(struct dentry)%L1_CACHE_BYTES = {0 or (L1_CACHE_BYTES/2)} would
even give better results.
Thank you
Eric
next prev parent reply other threads:[~2005-09-01 19:52 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-01 10:55 2.6.13-mm1 Andrew Morton
2005-09-01 14:22 ` 2.6.13-mm1 Martin J. Bligh
2005-09-01 14:50 ` 2.6.13-mm1 Alan Cox
2005-09-01 20:56 ` 2.6.13-mm1 Joel Schopp
2005-09-01 21:16 ` 2.6.13-mm1 Alan Cox
2005-09-01 21:26 ` 2.6.13-mm1 Joel Schopp
2005-09-01 21:44 ` 2.6.13-mm1 Alan Cox
2005-09-12 16:34 ` tty patches in 2.6.13-mm3 (was Re: 2.6.13-mm1) serue
2005-09-12 16:55 ` Joel Schopp
2005-09-12 17:04 ` 2.6.13-mm1 serue
2005-09-01 14:59 ` 2.6.13-mm1 Adrian Bunk
2005-09-01 15:01 ` [PATCH] mips: remove typedef from struct flock Yoichi Yuasa
2005-09-01 15:38 ` 2.6.13-mm1 Dominik Karall
2005-09-01 16:09 ` 2.6.13-mm1 John Stoffel
2005-09-01 16:28 ` 2.6.13-mm1 Dominik Karall
2005-09-01 17:34 ` 2.6.13-mm1 John Stoffel
2005-09-01 18:05 ` 2.6.13-mm1 Dominik Karall
2005-09-01 18:27 ` 2.6.13-mm1 John Stoffel
2005-09-01 15:44 ` [PATCH] : struct dentry : place d_hash close to d_parent and d_name to speedup lookups Eric Dumazet
2005-09-01 15:48 ` Eric Dumazet
2005-09-01 17:36 ` Dipankar Sarma
2005-09-01 19:52 ` Eric Dumazet [this message]
2005-09-01 17:41 ` 2.6.13-mm1 - drivers/isdn/i4l/isdn_tty broken Damir Perisa
2005-09-01 21:06 ` Alan Cox
2005-09-02 1:05 ` 2.6.13-mm1 - drivers/serial/jsm/jsm_tty broken too Damir Perisa
2005-09-01 21:14 ` 2.6.13-mm1: PCMCIA problem Rafael J. Wysocki
2005-09-01 21:28 ` Andrew Morton
2005-09-02 8:30 ` Rafael J. Wysocki
2005-09-02 8:37 ` Rafael J. Wysocki
2005-09-02 10:43 ` Pavel Machek
2005-09-02 10:58 ` Rafael J. Wysocki
2005-09-02 11:09 ` Andrew Morton
2005-09-02 11:45 ` 2.6.13-mm1: swsusp problem (was: PCMCIA problem) Rafael J. Wysocki
2005-09-02 14:17 ` Rafael J. Wysocki
2005-09-04 14:29 ` 2.6.13-mm1: PCMCIA problem Pavel Machek
2005-09-01 22:19 ` 2.6.13-mm1: broken drivers/video/sis/Makefile Adrian Bunk
2005-09-01 23:24 ` Thomas Winischhofer
2005-09-01 23:25 ` 2.6.13-mm1: misc mwave issues Adrian Bunk
2005-09-02 12:36 ` Alan Cox
2005-09-02 13:57 ` 2.6.13-mm1 Benjamin LaHaise
2005-09-02 20:57 ` 2.6.13-mm1 Andrew Morton
2005-09-06 11:50 ` 2.6.13-mm1 Benjamin LaHaise
2005-09-02 14:30 ` 2.6.13-mm1 Alexander Nyberg
2005-09-02 14:40 ` 2.6.13-mm1 Zwane Mwaikambo
2005-09-03 12:21 ` 2.6.13-mm1 Adrian Bunk
2005-09-03 19:34 ` 2.6.13-mm1 Andrew Morton
2005-09-03 19:54 ` 2.6.13-mm1 Adrian Bunk
2005-09-03 20:06 ` 2.6.13-mm1 Andrew Morton
2005-09-04 20:00 ` 2.6.13-mm1 Adrian Bunk
2005-09-04 21:24 ` 2.6.13-mm1 Jesper Juhl
2005-09-04 21:30 ` 2.6.13-mm1 Andrew Morton
2005-09-04 21:36 ` 2.6.13-mm1 Jesper Juhl
2005-09-07 0:05 ` 2.6.13-mm1 Paul Jackson
2005-09-07 0:32 ` 2.6.13-mm1 Andrew Morton
2005-09-07 0:44 ` 2.6.13-mm1 Jesper Juhl
2005-09-07 2:38 ` 2.6.13-mm1 Paul Jackson
2005-09-04 10:26 ` 2.6.13-mm1 Alexander Nyberg
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=43175BE9.6030808@cosmosbay.com \
--to=dada1@cosmosbay.com \
--cc=akpm@osdl.org \
--cc=dipankar@in.ibm.com \
--cc=linux-kernel@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