Showing posts with label Linux tunining. Show all posts
Showing posts with label Linux tunining. Show all posts

Thursday, July 9, 2009

Tweaking hard disk on Linux

 
hdparm -Tt /dev/hda

/dev/hda:
Timing buffer-cache reads: 128 MB in 1.34 seconds =95.52 MB/sec
Timing buffered disk reads: 64 MB in 17.86 seconds = 3.58 MB/sec

hdparm /dev/hda

/dev/hda:
multcount = 0 (off)
I/O support = 0 (default 16-bit)
unmaskirq = 0 (off)
using_dma = 0 (off)
keepsettings = 0 (off)
nowerr = 0 (off)
readonly = 0 (off)
readahead = 8 (on)
geometry = 1870/255/63, sectors = 30043440, start = 0

  1. multcount: Short for multiple sector count. This controls how many sectors are fetched from the disk in a single I/O interrupt. Almost all modern IDE drives support this. The man page claims: when this feature is enabled, it typically reduces operating system overhead for disk I/O by 30-50%. On many systems, it also provides increased data throughput of anywhere from 5% to 50%.
  2. I/O support: This is a big one. This flag controls how data is passed from the PCI bus to the controller. Almost all modern controller chipsets support mode 3, or 32-bit mode w/sync. Some even support 32-bit async. Turning this on will almost certainly double your throughput (see below.)
  3. unmaskirq: Turning this on will allow Linux to unmask other interrupts while processing a disk interrupt. What does that mean? It lets Linux attend to other interrupt-related tasks (i.e., network traffic) while waiting for your disk to return with the data it asked for. It should improve overall system response time, but be warned: Not all hardware configurations will be able to handle it. See the manpage.
  4. using_dma: DMA can be a tricky business. If you can get your controller and drive using a DMA mode, do it. But I have seen more than one machine hang while playing with this option.

 
hdparm -X66 -d1 -u1 -m16 -c3 /dev/hda:
setting 32-bit I/O support flag to 3
setting multcount to 16
setting unmaskirq to 1 (on)
setting using_dma to 1 (on)
setting xfermode to 66 (UltraDMA mode2)
multcount = 16 (on)
I/O support = 3 (32-bit w/sync)
unmaskirq = 1 (on)
using_dma = 1 (on)

hdparm -tT /dev/hda

/dev/hda:
Timing buffer-cache reads: 128 MB in 1.43 seconds = 89.51 MB/sec
Timing buffered disk reads: 64 MB in 3.18 seconds = 20.13 MB/sec

Tuesday, March 3, 2009

System calls analysys tool

strace -cp 18875

% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 77.61    0.019695           0    782458       read
 12.31    0.003123           0      9456        write
  3.60    0.000913           0     47291        fcntl64
  3.32    0.000843           0      9463         open
  1.34    0.000341           0     18920        close
  1.27    0.000323           0     18914        dup2
  0.55    0.000140           0      9457         rt_sigprocmask
  0.00    0.000000           0         6           fstat64
  0.00    0.000000           0        12          getdents64
------ ----------- ----------- --------- --------- ----------------
100.00    0.025378                895977           total


Sunday, November 30, 2008

Process File Descriptor Tuning on Linux

I've recently encountered on file handlers limit problem while running java program that holds a large hash of file descriptors. The following example describes how to raise the maximum number of file descriptors per process to 4096 on the RedHat/CentOS distibution of Linux:

Process File Descriptor Tuning

In addition to configuring system-wide global file-descriptor values, you must also consider per-process limits.

The following example describes how to raise the maximum number of file descriptors per process to 4096 on the RedHat?CentOS distibution of Linux:

  1. Allow all users to modify their file descriptor limits from an initial value of 1024 up to the maximum permitted value of 4096 by changing /etc/security/limits.conf

       *       soft    nofile  1024
    * hard nofile 4096

    In /etc/pam.d/login, add:

       session required /lib/security/pam_limits.so
  2. Increase the system-wide file descriptor limit by adding the following line to the /etc/rc.d/rc.local startup script:

       echo -n "8192" > /proc/sys/fs/file-max

    or, on 2.6 kernels:

       echo -n "8192" > $( mount | grep sysfs | cut -d" " -f 3 )/fs/file-max

    Now restart the system or run these commands from a command line to apply these changes.

  3. You will then need to tell the system to use the new limits:

    ulimit -n unlimited (bash)

    or

    ulimit -n 65535 (bash)

    or

    unlimit descriptors (csh, tcsh).
  4. Verify this has raised the limit by checking the output of:
    ulimit -a (bash) or limit (csh, tcsh)