<div class="gmail_extra">1.5 ms per inode. Times 900K files equals 22 mins.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Large dirs are a problem is all file systems. The degree of problem</div><div class="gmail_extra">
depends on the overhead. An easy solution around is to shard the</div><div class="gmail_extra">files into multilevel dirs. Like a 2 level structure of a 1000 files in</div><div class="gmail_extra">1000 dirs. Or, a 3 level structure with even fewer files per dir.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">Or you could use the other approach suggested. Avoids stat()</div><div class="gmail_extra">by disabling color-ls. Or just use plain find.</div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Tue, Dec 4, 2012 at 3:16 PM, Erik Schwartz <span dir="ltr">&lt;<a href="mailto:schwartz.erik.c@gmail.com" target="_blank">schwartz.erik.c@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Amaury, you can see in strace output that it&#39;s performing a stat on<br>
every file.<br>
<br>
Try simply:<br>
<br>
  $ /bin/ls<br>
<br>
My guess is you&#39;re using a system where &quot;ls&quot; is aliased to use options<br>
that are more expensive.<br>
<br>
Best regards -<br>
<br>
Erik<br>
<div><div class="h5"><br>
<br>
On 12/4/12 5:12 PM, Amaury Francois wrote:<br>
&gt; The strace looks like this (on all files) :<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; 1354662591.755319<br>
&gt; lstat64(&quot;TEW_STRESS_TEST_VM.1K_100P_10000F.P069_F01589.txt&quot;,<br>
&gt; {st_mode=S_IFREG|0664, st_size=1000, ...}) = 0 &lt;0.001389&gt;<br>
&gt;<br>
&gt; 1354662591.756775<br>
&gt; lstat64(&quot;TEW_STRESS_TEST_VM.1K_100P_10000F.P035_F01592.txt&quot;,<br>
&gt; {st_mode=S_IFREG|0664, st_size=1000, ...}) = 0 &lt;0.001532&gt;<br>
&gt;<br>
&gt; 1354662591.758376<br>
&gt; lstat64(&quot;TEW_STRESS_TEST_VM.1K_100P_10000F.P085_F01559.txt&quot;,<br>
&gt; {st_mode=S_IFREG|0664, st_size=1000, ...}) = 0 &lt;0.001429&gt;<br>
&gt;<br>
&gt; 1354662591.759873<br>
&gt; lstat64(&quot;TEW_STRESS_TEST_VM.1K_100P_10000F.P027_F01569.txt&quot;,<br>
&gt; {st_mode=S_IFREG|0664, st_size=1000, ...}) = 0 &lt;0.001377&gt;<br>
&gt;<br>
&gt; 1354662591.761317<br>
&gt; lstat64(&quot;TEW_STRESS_TEST_VM.1K_100P_10000F.P002_F01581.txt&quot;,<br>
&gt; {st_mode=S_IFREG|0664, st_size=1000, ...}) = 0 &lt;0.001420&gt;<br>
&gt;<br>
&gt; 1354662591.762804<br>
&gt; lstat64(&quot;TEW_STRESS_TEST_VM.1K_100P_10000F.P050_F01568.txt&quot;,<br>
&gt; {st_mode=S_IFREG|0664, st_size=1000, ...}) = 0 &lt;0.001345&gt;<br>
&gt;<br>
&gt; 1354662591.764216<br>
&gt; lstat64(&quot;TEW_STRESS_TEST_VM.1K_100P_10000F.P089_F01567.txt&quot;,<br>
&gt; {st_mode=S_IFREG|0664, st_size=1000, ...}) = 0 &lt;0.001541&gt;<br>
&gt;<br>
&gt; 1354662591.765828<br>
&gt; lstat64(&quot;TEW_STRESS_TEST_VM.1K_100P_10000F.P010_F01594.txt&quot;,<br>
&gt; {st_mode=S_IFREG|0664, st_size=1000, ...}) = 0 &lt;0.001358&gt;<br>
&gt;<br>
&gt; 1354662591.767252<br>
&gt; lstat64(&quot;TEW_STRESS_TEST_VM.1K_100P_10000F.P045_F01569.txt&quot;,<br>
&gt; {st_mode=S_IFREG|0664, st_size=1000, ...}) = 0 &lt;0.001396&gt;<br>
&gt;<br>
&gt; 1354662591.768715<br>
&gt; lstat64(&quot;TEW_STRESS_TEST_VM.1K_100P_10000F.P036_F01592.txt&quot;,<br>
&gt; {st_mode=S_IFREG|0664, st_size=1000, ...}) = 0 &lt;0.002072&gt;<br>
&gt;<br>
&gt; 1354662591.770854<br>
&gt; lstat64(&quot;TEW_STRESS_TEST_VM.1K_100P_10000F.P089_F01568.txt&quot;,<br>
&gt; {st_mode=S_IFREG|0664, st_size=1000, ...}) = 0 &lt;0.001722&gt;<br>
&gt;<br>
&gt; 1354662591.772643<br>
&gt; lstat64(&quot;TEW_STRESS_TEST_VM.1K_100P_10000F.P009_F01600.txt&quot;,<br>
&gt; {st_mode=S_IFREG|0664, st_size=1000, ...}) = 0 &lt;0.001281&gt;<br>
&gt;<br>
&gt; 1354662591.773992<br>
&gt; lstat64(&quot;TEW_STRESS_TEST_VM.1K_100P_10000F.P022_F01583.txt&quot;,<br>
&gt; {st_mode=S_IFREG|0664, st_size=1000, ...}) = 0 &lt;0.001413&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; We are using a 32 bits architecture, can it be the cause of the kernel<br>
&gt; not having enough memory ? Any possibility to change this behavior ?<br>
&gt;<br>
&gt;<br>
&gt;<br>
</div></div><div class="im">&gt; Description : Description : Description : cid:image001.png@01CD01F3.35091200<br>
&gt;<br>
&gt;<br>
&gt;<br>
</div>&gt; * *<br>
&gt;<br>
&gt; *Amaury FRANCOIS*   •  *Ingénieur*<br>
<div class="im">&gt;<br>
&gt; Mobile <a href="tel:%2B33%20%280%296%2088%20%2012%2062%2054" value="+33688126254">+33 (0)6 88  12 62 54</a><br>
&gt;<br>
</div>&gt; *<a href="mailto:amaury.francois@digora.com">amaury.francois@digora.com</a> &lt;mailto:<a href="mailto:amaury.francois@digora.com">amaury.francois@digora.com</a>&gt;***<br>
&gt;<br>
&gt; * *<br>
&gt;<br>
&gt; *Siège Social – 66 rue du Marché Gare – 67200 STRASBOURG*<br>
<div class="im">&gt;<br>
&gt; Tél : 0 820 200 217 - <a href="tel:%2B33%20%280%293%2088%2010%2049%2020" value="+33388104920">+33 (0)3 88 10 49 20</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
</div>&gt; Description : test<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; *De :*Sunil Mushran [mailto:<a href="mailto:sunil.mushran@gmail.com">sunil.mushran@gmail.com</a>]<br>
&gt; *Envoyé :* mardi 4 décembre 2012 18:29<br>
&gt; *À :* Amaury Francois<br>
&gt; *Cc :* <a href="mailto:ocfs2-users@oss.oracle.com">ocfs2-users@oss.oracle.com</a><br>
&gt; *Objet :* Re: [Ocfs2-users] &quot;ls&quot; taking ages on a directory containing<br>
<div class="im">&gt; 900000 files<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; strace -p PID -ttt -T<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; Attach and get some timings. The simplest guess is that the system lacks<br>
&gt; memory to cache all the inodes<br>
&gt;<br>
&gt; and thus has to hit disk (and more importantly take cluster locks) for<br>
&gt; the same inode repeatedly. The user<br>
&gt;<br>
&gt; guide has a section in NOTES explaining this.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On Tue, Dec 4, 2012 at 8:54 AM, Amaury Francois<br>
</div><div><div class="h5">&gt; &lt;<a href="mailto:amaury.francois@digora.com">amaury.francois@digora.com</a> &lt;mailto:<a href="mailto:amaury.francois@digora.com">amaury.francois@digora.com</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt; Hello,<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; We are running OCFS2 1.8 and on a kernel UEK2. An ls on a directory<br>
&gt; containing approx. 1 million of files  is very long (1H). The features<br>
&gt; we have activated on the filesystem are the following :<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; [root@pa-oca-app10 ~]# debugfs.ocfs2 -R &quot;stats&quot; /dev/sdb1<br>
&gt;<br>
&gt;         Revision: 0.90<br>
&gt;<br>
&gt;         Mount Count: 0   Max Mount Count: 20<br>
&gt;<br>
&gt;         State: 0   Errors: 0<br>
&gt;<br>
&gt;         Check Interval: 0   Last Check: Fri Nov 30 19:30:17 2012<br>
&gt;<br>
&gt;         Creator OS: 0<br>
&gt;<br>
&gt;         Feature Compat: 3 backup-super strict-journal-super<br>
&gt;<br>
&gt;         Feature Incompat: 32592 sparse extended-slotmap inline-data<br>
&gt; metaecc xattr indexed-dirs refcount discontig-bg clusterinfo<br>
&gt;<br>
&gt;         Tunefs Incomplete: 0<br>
&gt;<br>
&gt;         Feature RO compat: 1 unwritten<br>
&gt;<br>
&gt;         Root Blknum: 5   System Dir Blknum: 6<br>
&gt;<br>
&gt;         First Cluster Group Blknum: 3<br>
&gt;<br>
&gt;         Block Size Bits: 12   Cluster Size Bits: 12<br>
&gt;<br>
&gt;         Max Node Slots: 8<br>
&gt;<br>
&gt;         Extended Attributes Inline Size: 256<br>
&gt;<br>
&gt;         Label: exchange2<br>
&gt;<br>
&gt;         UUID: 2375EAF4E4954C4ABB984BDE27AC93D5<br>
&gt;<br>
&gt;         Hash: 2880301520 (0xabade9d0)<br>
&gt;<br>
&gt;         DX Seeds: 1678175851 1096448356 79406012 (0x6406ee6b 0x415a7964<br>
&gt; 0x04bba3bc)<br>
&gt;<br>
&gt;         Cluster stack: o2cb<br>
&gt;<br>
&gt;         Cluster name: appcluster<br>
&gt;<br>
&gt;         Cluster flags: 1 Globalheartbeat<br>
&gt;<br>
&gt;         Inode: 2   Mode: 00   Generation: 3567595533 (0xd4a5300d)<br>
&gt;<br>
&gt;         FS Generation: 3567595533 (0xd4a5300d)<br>
&gt;<br>
&gt;         CRC32: 0c996202   ECC: 0819<br>
&gt;<br>
&gt;         Type: Unknown   Attr: 0x0   Flags: Valid System Superblock<br>
&gt;<br>
&gt;         Dynamic Features: (0x0)<br>
&gt;<br>
&gt;         User: 0 (root)   Group: 0 (root)   Size: 0<br>
&gt;<br>
&gt;         Links: 0   Clusters: 5242635<br>
&gt;<br>
&gt;         ctime: 0x508eac6b 0x0 -- Mon Oct 29 17:18:51.0 2012<br>
&gt;<br>
&gt;         atime: 0x0 0x0 -- Thu Jan  1 01:00:00.0 1970<br>
&gt;<br>
&gt;         mtime: 0x508eac6b 0x0 -- Mon Oct 29 17:18:51.0 2012<br>
&gt;<br>
&gt;         dtime: 0x0 -- Thu Jan  1 01:00:00 1970<br>
&gt;<br>
&gt;         Refcount Block: 0<br>
&gt;<br>
&gt;         Last Extblk: 0   Orphan Slot: 0<br>
&gt;<br>
&gt;         Sub Alloc Slot: Global   Sub Alloc Bit: 65535<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; May inline-data or xattr be the source of the problem ?<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; Thank you.<br>
&gt;<br>
&gt;<br>
&gt;<br>
</div></div><div class="im">&gt; Description : Description : Description : cid:image001.png@01CD01F3.35091200<br>
&gt;<br>
&gt;<br>
&gt;<br>
</div>&gt; * *<br>
&gt;<br>
&gt; *Amaury FRANCOIS*   •  *Ingénieur*<br>
<div class="im">&gt;<br>
&gt; Mobile <a href="tel:%2B33%20%280%296%2088%20%2012%2062%2054" value="+33688126254">+33 (0)6 88  12 62 54</a><br>
</div>&gt; &lt;tel:%2B33%20%280%296%2088%C2%A0%2012%2062%2054&gt;<br>
&gt;<br>
&gt; *<a href="mailto:amaury.francois@digora.com">amaury.francois@digora.com</a> &lt;mailto:<a href="mailto:amaury.francois@digora.com">amaury.francois@digora.com</a>&gt;*<br>
&gt;<br>
&gt; * *<br>
&gt;<br>
&gt; *Siège Social – 66 rue du Marché Gare – 67200 STRASBOURG*<br>
<div class="im">&gt;<br>
&gt; Tél : 0 820 200 217 - <a href="tel:%2B33%20%280%293%2088%2010%2049%2020" value="+33388104920">+33 (0)3 88 10 49 20</a><br>
</div>&gt; &lt;tel:%2B33%20%280%293%2088%2010%2049%2020&gt;<br>
<div class="im">&gt;<br>
&gt;<br>
&gt;<br>
&gt; Description : test<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Ocfs2-users mailing list<br>
</div>&gt; <a href="mailto:Ocfs2-users@oss.oracle.com">Ocfs2-users@oss.oracle.com</a> &lt;mailto:<a href="mailto:Ocfs2-users@oss.oracle.com">Ocfs2-users@oss.oracle.com</a>&gt;<br>
&gt; <a href="https://oss.oracle.com/mailman/listinfo/ocfs2-users" target="_blank">https://oss.oracle.com/mailman/listinfo/ocfs2-users</a><br>
<div class="HOEnZb"><div class="h5">&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Ocfs2-users mailing list<br>
&gt; <a href="mailto:Ocfs2-users@oss.oracle.com">Ocfs2-users@oss.oracle.com</a><br>
&gt; <a href="https://oss.oracle.com/mailman/listinfo/ocfs2-users" target="_blank">https://oss.oracle.com/mailman/listinfo/ocfs2-users</a><br>
&gt;<br>
<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
Erik Schwartz &lt;<a href="mailto:schwartz.erik.c@gmail.com">schwartz.erik.c@gmail.com</a>&gt; | GPG key 14F1139B<br>
<br>
</font></span></blockquote></div><br></div>