lkml.org 
[lkml]   [1999]   [Aug]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subject[PATCH] ext2/namei.c lookup performance patch
It looks like that ext2_find_entry() is one of the most frequently
referenced functions and affects the system performance.
Therefore, I browsed the source code and found a little spot, i.e.,
When sys_unlink() does directory look up, it calls ext2_find_entry()
if the target is not dcached. Getting the dentry, it checks the permission,
and calls ext2_unlink(). However, the function ext2_unlink() calls
ext2_find_entry() once again.

Because the target is linearly searched, it is not effective to
searching the same file from the start of the directory.
If the "offset" of the "de" is remembered in the dentry struct,
the next lookup can directly jump to the right block and right offset.

Fortunately, there is a good field in the dentry, i.e., d_fsdata.
It is initialized to NULL whenever the dentry is newly allocated.
However, the current ext2 code never uses this field. Therefore
we can save the "modified offset" there. We save the offset in a
modified form to distinguish offset 0 and uninitialized offset NULL.

Due to this change, synopsys of ext2_find_entry() and ext2_add_entry()
are changed to use dentry directly. Also, a new function ext2_has_entry()
is added.

The lookup statitistics can be generated by defining EXT2_LOOKUP_STATS.
The following is an example of the statitics on my personal news server.

Aug 9 13:43:49 news kernel: ext2_de_stats: lookup 2653 hit 680 found 856
miss 1117 init 1079 del 697
Aug 9 13:48:49 news kernel: ext2_de_stats: lookup 2582 hit 650 found 904
miss 1028 init 1006 del 666
Aug 9 13:53:49 news kernel: ext2_de_stats: lookup 3126 hit 756 found 1071
miss 1299 init 1265 del 776

The number "lookup" is the total number of lookups during the collecting
period, 5 minutes. "hit" is the cache hit, meaning the remembered offset
in the dentry is used to locate the ext2_dentry_2. The number "found "
is the total number of existing file loops, while the number "miss" is
that of the non-existing file lookups. The number "init" is the number
of newly created directory entries, and the number "del" is the number of
deleted files.

I made a diff against kernel-2.2.10. The patch updates only one file
linux/fs/ext2.namei.c.
--
Sang-yong Suh, Group Leader, Seismic Data Processing Lab.
Korea Institute of Geology Mining and Materials (KIGAM)
30 Gajeong-dong, Yuseong-gu, Taejeon, Korea 305-350
Tel: 82+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EUZOU4_-LN/^$<B#0?W)G9
M[[GW,[\5FB'0.>$<P!$2],7S=L?J9L<A#XCY'1 K9+%M6QV[:WQEOMNVNKTL
MMB@UTU\=/135*EW32'=DM(LWW=35UZJHCCY8%S$Q:F34')\[YW\_>4G]*AU)
M<I?,?CX[OAA0%_()%:V%)+9;8#SUOX06\0_:I&K4@Y#7,RX"_(EJ9&!6R.0N
M,+G;S_2H!R58KYFAGJ*UDB1CFHTI<66S2FD$MNC41GV]L\(5D=IMU:UNJ[.:
MAZCFK;?9S2X?Q'^=$:?7;UO]>D&*>9]$?N%PTNV!X'J=7#:1STO33M.;XY,?
MG;='O^3."FN#M_C\"XE0;:J_$8="Z3=!**U&+@UX0 +NA%\1PWO-)OB -'[C
MLF V=FA?7U[S&_1CN0MA]'UO/6W%9^$(GT[AFR)&%PPPLWF@HH][X15_B^8E
MW>_$&U&L5OJR9"1 \6)'C/G7FQ9!%'G#F13'ITAS$$9[&L+/^D8#13WC-]HL
MOHSIQ7@#8G&-WR*GBQ!B$0;X$Q@LU%[/ZO=31_E03/HJZ2]4FE;'ZK6-B]%9
M4B'YP)^9A+S1C@#?9R*GI_R="LV_%0[1"N10?FFF1JI!5S#,RL0#F5WP5FFY
M2_<--(9I3UHWV-5D]1W!>KV!/U-D]/R_%,GW1D>A("$EZ/5LXPBO@"SN!:7;
M\,[T)?8<'8:#NJWDMHDNG?=$I1M/\Q2GQ]C%6+/D(,EIU)OFA?:'HC'#6WP>
MPH4BZC>L7K]C_ 1GO=4$BEK&;73>-=]V9T]B/*,]\%]!=L>3V1>1LE39=6W(
3XK03W%I\Y%3S_P"4GP<WL%0 '3>

end

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:53    [W:1.258 / U:0.348 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site