[nSLUG] Re: Load spikes, X bogs down. Why? Fix?

Mike Spencer mspencer at tallships.ca
Sat Apr 9 03:20:45 ADT 2016



Gales last night, couldn't work with the power flickering on and off.

Thanks for several replies.  Responding to here to Dop and sg:


Dop wrote:

On Thu, 7 Apr 2016, Mike Spencer wrote:

>> The problem is that, on a new setup, the system bogs down so badly
>> under some conditions (apparently during HD access) that the X
>> cursor takes seconds to respond and X window manipulations take
>> even longer.
>
> I've found that some of the settings in Linux are not great for
> slower storage hardware under heavy writes. Two things to do that
> may help are reduce read ahead from 128kB to 4kB:
>
> for i in `find /sys | grep read_ahead_kb` ; do echo 4 > $i ; done
>
> and reduce the max number of requests in flight from 128 to 4:
>
> for i in `find /sys | grep nr_requests$` ;  do echo 4 > $i 2>/dev/null; 
> done

Something of that kind is probably right.  It's increasingly clear
that the problem has to do with HD access.  With a music file
playing (correctly, from HD file) with mplayer:

     USBi  == Big file on ith mounted USB thumb drive
     HDn   == Dir on hard drive partition n

  cp USB1      -> HD3   X, music stutter; cp heads top(1) except some 
                        bdflush;   xload(1) spikes

  cp HD3/file  -> HD4   Same problem

  cp USB1      -> USB2  Music, X unaffected, cp heads top(1), no bdflush,
                        smaller spike in xload(1), no problem

Also:

  DVD played by mplayer: X unaffected, reasonable plateau in xload.

  Video file on HD played by mplayer: X unaffected, reasonable xload.


But I don't have the /sys hierarchy you mention on this system, only
/proc and I don't find anything there that resembles the
/sys/devices/[yadda,yadda]/block/sda/queue/read_ahead_kb
present on my much newer laptop.  Is there a similar place with an
older kernel to achieve this?  Or a boot param?

hdparm -a reports "readahead = 8  (on)" and the manpage says,

    hdparm(8)

    -a Get/set sector count for filesystem read-ahead.  This is used
       to improve performance in sequential reads of large files, by
       prefetching additional blocks in anticipation of them being
       needed by the running task.  In the current kernel version
       (2.0.10) this has a default setting of 8 sectors (4KB). 

Which, if it has the same effect as your suggestion, also has the same
value.

But the hdparm manpage continues:

       Also, many IDE drives also have a separate built-in read-ahead
       function, which alleviates the need for a filesystem read-ahead
       in many situations.

so may there be something in the HD itself that somehow forces a
larger readahead?



Stephen Gregory wrote:

> Mike Spencer <mspencer at tallships.ca> wrote:
>
>> BUT: running a command like:
>>
>>      cp /mnt/usb-thumb-drive/700-meg-file /mnt/hda3/storage
>
> I would be curious what the output of 'vmstat 1' looked like when
> you do that copy. And top.

vmstat output appended below.  For top, see above. (Or did you mean
"top -b > file", which gets pretty voluminous.  I don't see how to
tell top(1) to only show the top n lines of the display/report.)

Still working on your other suggestions/questions.  This stuff is
kinda deep water for me.

- Mike

--- Begin vmstat output, start before cp, end after cp done ---

bogus% vmstat 1
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
 1  0      0  13332   4708 383860    0    0    78    38  142   92  1  2 98  0
 0  0      0  13328   4708 383860    0    0     0     0  105   49  0  1 99  0
 0  0      0  13328   4708 383860    0    0     0     0  157  306  0  0 100  0
 0  0      0  13328   4708 383860    0    0     0     0  101   33  1  0 99  0
 0  2      0  11928   4712 385188    0    0   748     0  300  422  1  1 98  0
 1  1      0   5332   4720 391616    0    0 18825     0 6094 11956  1 27 72  0
 1  1      0   5232   4748 388540    0    0 18441     0 6031 11765  1 25 74  0
 1  1      0   4708   4772 385860    0    0 18697     0 6068 11829  0 27 73  0
 1  1      0   5180   4800 382160    0    0 18697     0 6111 11897  0 24 76  0
 2  0      0   4472   4828 379628    0    0 18826     0 6064 11825  1 28 71  0
 1  1      0   4836   4860 376092    0    0 18445     0 6031 11774  1 31 68  0
 5  2      0   5336   4860 375340    0    0  1792  6764 1104 1198  4 91  5  0
 3  0      0   4512   4892 372812    0    0 19082 32145 12148 12368 14 79  6  0
 2  3      0   5344   4916 368936    0    0 17672  4160 5801 11212  4 29 67  0
 0  2      0   5000   4936 366136    0    0 19082 34752 12337 12278 19 75  6  0
 1  1      0   4888   4964 366264    0    0 18569     0 6070 11886  1 22 77  0
 6  1      0   5320   4964 365804    0    0   384  7232  778  248 16 83  1  0
 3  0      0   4604   4992 366512    0    0 18477 30396 11608 12055 15 79  6  0
 1  1      0   4484   5020 366572    0    0 18789     0 6102 11958  1 29 70  0
 5  1      0   5264   5020 365828    0    0   128  7040  626  110 18 82  0  0
 3  0      0   4464   5048 366588    0    0 18829 32000 11822 12137 15 79  6  0
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
 2  1      0   4700   5076 366320    0    0 18569     0 6056 11851  0 21 79  0
 5  2      0   5200   5076 365832    0    0  1793  8704 1372 1211 17 78  5  0
 6  1      0   5320   5076 365748    0    0   513 29568 5446  455 16 84  0  0
 2  1      0   4376   5104 366616    0    0 18441     0 6041 11733  0 34 66  0
 1  1      0   5112   5128 365852    0    0 18441     0 6080 11901  1 26 73  0
 5  3      0   4296   5132 366656    0    0  1024  6512  780  570 10 88  3  0
 5  0      0   4224   5160 366704    0    0 18953 31885 11854 12312 16 78  6  0
 1  1      0   4660   5188 366240    0    0 18569     0 6054 11853  0 26 74  0
 4  3      0   5224   5188 365692    0    0   769  8728 1094  539 16 81  2  0
 2  1      0   5240   5216 365632    0    0 18569 29544 11289 12050 19 75  6  0
 1  1      0   4980   5248 365900    0    0 18573     0 6059 11835  0 27 73  0
 7  1      0   5196   5248 365672    0    0   896  6976  829  590  6 86  8  0
 0  1      0   4252   5276 366564    0    0 19082 30528 11588 12221 21 72  7  0
 3  2      0   5264   5300 365568    0    0 18441  4108 6068 11751  4 38 59  0
 3  3      0   4400   5304 366472    0    0   512 24372 4404  429 12 88  0  0
 2  1      0   5260   5332 365512    0    0 18569 11068 8094 11928 17 67 16  0
 1  1      0   5056   5360 365712    0    0 18477     0 6098 11900  0 24 76  0
 2  4      0   4560   5360 366192    0    0  2269  7552 1353 1335 12 83  5  0
 0  2      0   5152   5388 365536    0    0 18953 31360 11707 12318 17 76  7  0
 2  1      0   4896   5420 365816    0    0 18738     0 6099 11952  1 36 63  0
 3  2      0   5156   5424 365532    0    0   860  5952  855  550 10 88  3  0
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
 2  1      0   4916   5444 365736    0    0 18825 32320 11695 12236 19 75  6  0
 1  1      0   5264   5472 365348    0    0 18697     0 6057 11863  0 20 80  0
 5  2      0   4844   5476 365780    0    0   769  6336  738  462  9 88  4  0
 1  1      0   4452   5504 366144    0    0 19081 31421 11777 12438 16 77  6  0
 1  1      0   4744   5528 365820    0    0 18569     0 6050 11808  0 23 77  0
 5  1      0   4320   5528 366240    0    0   256  7040  640  118 14 86  0  0
 1  1      0   5188   5556 365356    0    0 19081 32128 11851 12336 16 78  7  0
 1  1      0   4548   5584 365988    0    0 18826     0 6128 11972  0 19 81  0
 3  2      0   4280   5588 366240    0    0  1152  7168  988  795 17 76  8  0
 0  1      0   4328   5612 366160    0    0 18957 31488 11766 12272 13 81  7  0
 2  1      0   4712   5644 365696    0    0 18606     0 6077 11884  1 24 75  0
 5  1      0   5172   5644 365288    0    0   860  7296  895  557 11 84  6  0
 1  1      0   4596   5672 365868    0    0 18953 30076 11434 12191 19 75  6  0
 4  2      0   4580   5696 365828    0    0 18569  4160 6162 11877  3 33 64  0
 2  1      0   4432   5724 365964    0    0 18697 34624 12156 12125 19 74  6  0
 0  0      0   4920   5740 365516    0    0  9175     0 3090 5949  0 14 86  0
 1  0      0   4900   5740 365516    0    0     0     0  101   27  1  0 99  0
 1  1      0   4900   5740 365516    0    0     0  6696  458   27 11 27 62  0
 3  0      0   4900   5740 365516    0    0     0 27200 4352  203 29 71  0  0
 0  0      0   4900   5740 365516    0    0     0  1560  846   74 25 35 40  0
 0  0      0   4900   5740 365516    0    0     0     0  101   21  0  0 100  0
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
 1  0      0   4900   5740 365516    0    0     0     0  101   51  1  0 99  0
 0  1      0   4900   5740 365516    0    0     0  4108  221   28  3  8 89  0
 2  1      0   4904   5740 365516    0    0     0 10048 1451   81 23 77  0  0
 3  1      0   4820   5740 365516    0    0     0 16128 2663  164 42 58  0  0
 0  0      0   4884   5740 365516    0    0     0  7345 1733  521 28 50 22  0
 0  0      0   4884   5740 365516    0    0     0     0  101   22  0  0 100  0
 0  0      0   4884   5740 365516    0    0     0     0  101   35  1  0 99  0
 1  1      0   4884   5740 365516    0    0     0  5568  396   27  7 22 71  0
 0  0      0   4884   5740 365516    0    0     0 22176 4605  572 20 69 11  0
 0  0      0   4884   5740 365516    0    0     0     0  175  353  1  0 99  0
 0  0      0   4884   5740 365516    0    0     0     0  199  478  1  0 99  0
 1  0      0   4884   5740 365516    0    0     0     0  141  232  0  0 100  0
 0  0      0   4884   5740 365516    0    0     0     0  110   60  0  0 100  0
 1  0      0   4888   5740 365516    0    0     0     0  133  347 14  0 86  0
 0  0      0   4884   5740 365516    0    0     0     0  168  641 37  0 63  0
 0  0      0   4880   5740 365516    0    0     0     0  181  457  5  0 95  0
 0  0      0   4880   5740 365516    0    0     0     0  109   71  0  0 100  0
 1  0      0   4880   5740 365516    0    0     0     0  121  129  0  0 100  0
 0  0      0   4880   5740 365516    0    0     0     0  130  164  0  0 100  0
 0  0      0   4880   5740 365516    0    0     0     0  130  166  1  0 99  0
 0  0      0   4880   5740 365516    0    0     0     0  130  166  0  0 100  0

bogus% --- End vmstat output, start before cp, end after cp done ---


-- 
Michael Spencer                  Nova Scotia, Canada       .~. 
                                                           /V\ 
mspencer at tallships.ca                                     /( )\
http://home.tallships.ca/mspencer/                        ^^-^^


More information about the nSLUG mailing list