Some time back an rsync being really slow came up on ALE. The SLLUG group sent this out and I am forwarding it here. Some very good details about memory usage and a kernel tweak to help flush memory buffers faster to not develop IO issues.<br>
<div class="gmail_quote"><br>----------------------------------------<br>This posting today on the rsync user list &lt;<a href="http://rsync.lists.samba.org" target="_blank">rsync.lists.samba.org</a>&gt;<br>
raises an interesting point that most of us probably have not thought<br>
much about before, but might find useful in improving our Linux<br>
systems performance:<br>
<br>
&gt;&gt; ...<br>
&gt;&gt; Date: Thu, 22 Apr 2010 15:30:36 -0700<br>
&gt;&gt; From: Erich Weiler &lt;<a href="mailto:weiler@soe.ucsc.edu">weiler@soe.ucsc.edu</a>&gt;<br>
&gt;&gt; User-Agent: Thunderbird 2.0.0.22 (X11/20090625)<br>
&gt;&gt; To: <a href="mailto:rsync@lists.samba.org">rsync@lists.samba.org</a><br>
&gt;&gt; Subject: Re: Odd behavior<br>
&gt;&gt;<br>
&gt;&gt; Well, I solved this problem myself, it seems.  It was not an rsync<br>
&gt;&gt; problem, per se, but it&#39;s interesting anyway on big filesystems like<br>
&gt;&gt; this so I&#39;ll outline what went down:<br>
&gt;&gt;<br>
&gt;&gt; Because my rsyncs were mostly just statting millions of files very<br>
&gt;&gt; quickly, RAM filled up with inode cache.  At a certain point, the kernel<br>
&gt;&gt; stopped allowing new cache entries to be added to the slab memory it had<br>
&gt;&gt; been using, and was slow to reclaim memory on old, clean inode cache<br>
&gt;&gt; entries.  So it basically slowed the I/O of the computer to barely anything.<br>
&gt;&gt;<br>
&gt;&gt; Slab memory can be checked by looking at the /proc/meminfo file.  If you<br>
&gt;&gt; see that slab memory is using up a fair portion of your total memory,<br>
&gt;&gt; run the &#39;slabtop&#39; program to see the top offenders.  In my case, it was<br>
&gt;&gt; the filesystem that was screwing me (by way of the kernel).<br>
&gt;&gt;<br>
&gt;&gt; I was able to speed up the reclaiming of clean, unused inode cache<br>
&gt;&gt; entries by tweaking this in the kernel:<br>
&gt;&gt;<br>
&gt;&gt; # sysctl -w vm.vfs_cache_pressure=10000<br>
&gt;&gt;<br>
&gt;&gt; The default value for that is 100, where higher values release memory<br>
&gt;&gt; faster for dentries and inodes.  It helped, but my rsyncs were still<br>
&gt;&gt; faster than it was, and it didn&#39;t help that much.  What really fixed it<br>
&gt;&gt; was this:<br>
&gt;&gt;<br>
&gt;&gt; # echo 3 &gt; /proc/sys/vm/drop_caches<br>
&gt;&gt;<br>
&gt;&gt; That effectively clears ALL dentry and inode entries from slab memory<br>
&gt;&gt; immediately.  When I did that, memory usage dropped from 35GB to 500MB,<br>
&gt;&gt; my rsyncs fired themselves up again magically, and the computer was<br>
&gt;&gt; responsive again.<br>
&gt;&gt;<br>
&gt;&gt; Slab memory began to fill up again of course, as the rsyncs were still<br>
&gt;&gt; going.  But slowly.  For this edge case, I&#39;m just going to configure a<br>
&gt;&gt; cron job to flush the dentry/inode cache every five minutes or so.  But<br>
&gt;&gt; things look much better now!<br>
&gt;&gt;<br>
&gt;&gt; A word of warning for folks rsyncing HUGE numbers of files under linux.  ;)<br>
&gt;&gt;<br>
&gt;&gt; As a side note, Solaris does not seem to have this problem, presumably<br>
&gt;&gt; because the kernel handles inode/dentry caching in a different way.<br>
&gt;&gt;<br>
&gt;&gt; -erich<br><br>
</div><br>-- <br>-- <br>James P. Kinney III<br>Actively in pursuit of Life, Liberty and Happiness         <br><br>