1992.12.22

SUBJECT: Disk Performance Tuning
 
STATUS OF THIS MEMO:
System Performance Tuning°ú °ü·ÃÇÏ¿© DISK PerformanceÀÇ ÃøÁ¤À» ÇϱâÀ§ÇÑ
utility¸¦ Á¤¸®ÇÑ °ÍÀÓ

CONTENTS:
1. Disk Specifications
2. Filesystem Block Size
3. Inodes
4. Fragmentation Control(BSD Only)
5. Fragmentation Control(System V Only)
6. Balancing I/O Workload
   1) iostat
   2) sadp
7. Filesystem Buffers
8. In-memory Filesystems
9. Stripted Filesystems
10. Conserving Disk Space
   1) Disk spaceÀÇ ³¶ºñ¸¦ ÁÙÀ̱â À§ÇØ
   2) Disk Rationing


DESCRIPTION:

1. Disk Specifications

   - Seek Times

   - Rotational Speed
     Almost all modern disk drivers have the same rotational speed 3600 RPM

   - Raw Transfer Rate

   - Disk Capacity

2. Filesystem Block Size

   - A block is a unit of data that the filesystem will always atomically 
     allocate on the disk

   - System V¿¡¼­´Â 512, 1024, 2048 bytesÀÇ block size¸¦ support

   - BSD¿¡¼­´Â 4, 8, 16, 32 KBÀÇ block size¸¦ supportÇϴµ¥, ÀÌ°ÍÀº
     ´õ ÁÁÀº throughputÀ» Á¦°øÇϸç, spaceÀÇ ³¶ºñ¸¦ ÇÇÇϱâ À§ÇØ BSD
     ¼³°èÀÚµéÀº disk fragmentÀÇ °³³äÀ» µµÀÔ

   - °¢ blockÀº 2, 4, 8°³ÀÇ fragment·Î ³ª´©¾î Áö´Âµ¥
     ¸¸¾à 25-KBÀÇ fileÀÌ ÀÖ´Ù¸é ÀÌ´Â 8KÀÇ disk block 3°³¿Í 1°³ÀÇ fragment·Î
     ÀÌ·ç¾î Áö¸ç, ÀÌÈÄ ÀÌ fileÀÌ 51-KB·Î ´Ã¾î³ª¸é filesystemÀº fragment¸¦
     ¾î¶² empty blockÀ¸·Î copyÇÏ°í, ´õ ¸¹Àº blockÀ» addÇÑÈÄ ¸¶Áö¸·¿¡
     fragment¸¦ addÇÏ¿© 6°³ÀÇ block°ú 3°³ÀÇfragment·Î ±¸¼ºÇÏ°Ô µÈ´Ù

   - Block size°¡ Ä¿Áö¸é performance´Â ÁÁ¾ÆÁö³ª disk spaceÀÇ ³¶ºñ¸¦ °¡Á®¿À´Âµ¥,
     System V¿¡¼­µµ 2048-byte blockÀÌ 1024, 512-byte blockº¸´Ù ´õ ³ªÀº 
     performance¸¦ Á¦°øÇÏÁö¸¸ diskÀÇ ³¶ºñ¸¦ ÃÊ·¡Çϸç

     standard block size(1024 byte)´Â º¸Åë performance¿Í efficiency¿¡¼­ 
     ÃÖÀûÀ» Á¦°øÇÑ´Ù

   - ¾î¶² filesystemÀÇ block size´Â mkfs°¡ filesystemÀ» ¸¸µé¶§ setµÇ¸ç
     204800 512-byte block(100 MB) sizeÀÇ filesystemÀ» 2048 byte blockÀÇ
     default inode¼ö¸¦ °¡Áö´Â »õ·Î¿î filesystemÀ¸·Î »ý¼ºÇÏ°íÀÚ ÇÒ°æ¿ì

         # mkfs /dev/rdsk/cld0s3 204800 -b 2048

3. Inodes

   - An inode is a data structure that describes a file

   - inodeÀÇ ¼ö´Â mkfs°¡ filesystemÀ» ¸¸µé¶§ °áÁ¤

   - Standard BSD UNIXÀÇ newfs¿Í mkfs´Â ¸Å 2048 byte¸¶´Ù ÇϳªÀÇ inode¸¦
     »ý¼ºÇϴµ¥, ÀÌ°ÍÀº average file size°¡ 2KÀÌ»óÀ¸·Î °£ÁÖÇؼ­ÀÌ´Ù.   

   - ¸¸¾à device /dev/rdisk1e¿¡ 12000 byte¸¶´Ù 1°³ÀÇ inode¸¦ »ý¼ºÇÏ°íÀÚ Çϸé

         # newfs -i 12000 /dev/rdisk1e cdc-9715 ( cdc-9715 disk driver)

4. Fragmentation Control(BSD Only)

   - BSD filesystemÀº disk fragmentationÀ» °ÞÁö ¾Êµµ·Ï ¼³°èµÇ¾î ÀÖÀ¸¸ç,
     ÀÏÁ¤ÇÑ performance¸¦ Á¦°øÇÑ´Ù

   - BSD filesystemÀÇ ¾Ë°í¸®ÁòÀº filesystemÀÌ fullÀÌ µÇ¸éfree blockÀ» ¹ß°ßÇϱâ
     À§ÇØ ±Ø´ÜÀûÀ¸·Î ´À·ÁÁö°ÔµÇ´Âµ¥

   - ÀÌ·¯ÇÑ °ÍÀ» ¹æÁöÇϱâ À§ÇØ °¢ filesystemÀº free spaceÀÇ ·®À» reserveÇÒ ¼ö
     Àִµ¥, ÀÌ minimum free space´Â ±âº»ÀûÀ¸·Î filesystemÀÇ 10%À̸ç
     super user¿¡ ÀÇÇØ "tunefs"³ª "newfs"¿¡ -m optionÀ» »ç¿ëÇÏ¿© modifyÇÒ¼ö ÀÖ´Ù

   - How to use tunefs to set the minimum free space to 12% 
     # umount /dev/disk1e
     # tunefs -m 12 -o time /dev/disk1e
     # mount /dev/disk1e
       ¿©±â¼­ "-o time"Àº blockÀ» ÇÒ´çÇϱâ À§ÇØ ÇÊ¿äÇÑ ½Ã°£À» minimizeÇϱâÀ§ÇÑ
       optionÀÌ´Ù

   - Use newfs to set minimum free space & optimization 
     # BACKUP FILESYSTEM
     # umount /dev/rdisk1e
     # newfs -m 12 -o time /dev/rdisk1e cdc-9715
     # mount /dev/rdisk1e
     # RESTORE THE FILESYSTEM

5. Fragmentation Control(System V Only)

   - System V filesystemÀÇ °¡ÀåÅ« ¹®Á¦Á¡Àº fragmentationÀÇ Ãë¾à¿¡ ÀÖ´Ù

   - ½Ã°£ÀÌ Áö³²¿¡ µû¶ó ÇϳªÀÇ file¿¡ ´ëÇØ ¿¬¼ÓµÈ disk blockÀ» ÇÒ´çÇϴ°ÍÀÌ
     Áß¿äÇѵ¥, free list´Â »ç¿ëµÇÁö ¾ÊÀº °³°³ÀÇ disk block¿¡ ´ëÇÑ list¸¦
     °¡Áö°í ÀÖÀ¸³ª sequenceÇÑ°ÍÀº ¾Æ´Ï´Ù

   - System VÀÇ fsck utility´Â minimize fragmentationÀ» À§ÇØ free list¸¦
     reorganizeÇÒ ¼ö ÀÖ´Ù

     ¨ç Put the system in single-user mode (with shutdown )
     ¨è Dismount the filesystem that you are interested in
     ¨é Run fsck -S to rebuild the free list
     ¨ê Reboot the system as soon as fsck -S finishes.

   - fragmentationÀ» Á¦°ÅÇÏ´Â ¿ÏÀüÇÑ ¹æ¹ýÀº filesystem backupÈÄ mkfs¸¦ »ç¿ë
     reinitilizeÇÏ´Â ¹æ¹ý»ÓÀÌ´Ù

6. Balancing I/O Workload

   1) iostat

      - BSD toolÀÎ iostat´Â I/OÀÇ statisticÀ» printÇØ disk load balance¸¦ ÃøÁ¤
        Çϴµ¥ µµ¿òÀ» ÁØ´Ù

      % iostat 5i
             tty          sd3          cpu
        tin tout bps tps msps  us ni sy id
          0    7   8   1  0.0   1  0  2 97
          0   18   0   0  0.0   6  0  0 94
        
        . tin, tout : I/O terminal buffer¿¡ ´ë±âÁßÀÎ character¼ö
                       filesystem optimization¿¡ ¿µÇâÀ» ÁÖÁö ¾Ê´Â´Ù
        . bps       : The average number of KByte per second during the
                      previous interval
        . msps      : The average number of miliseconds per seek
                      ÀÌÇ×Àº º° ½Å·Ú¼ºÀÌ ¾ø°í ¸î¸î vendor´Â Á¦°øÇÏÁö ¾ÊÀ½
        . tps       : The average number of transfers per second during the
                      previous interval

      - System VÇÏ¿¡¼­´Â sar -d°¡ °¢ disk driver¿¡ ´ëÇÑ »óŸ¦ º¸¿©ÁÜ

   2) sadp

      - System V¿¡¼­´Â sadp toolÀ» »ç¿ë diskÀÇ »óŸ¦ gatheringÇÏ¿©
        displayÇÏ¿©ÁØ´Ù( cylinder access¸¦ histogramÀ¸·Î Ç¥½Ã)

      % sadp -h options interval reports
 
        . -d type : disk typeÀ¸·Î SCSI disk´Â sdsk, floppy´Â fdsk,
                    ±×¿Ü ´Ù¸¥ disk´Â hdsk
        . -n      : disk number·Î "3-5", "3,5,7"°ú °°ÀÌ 2°³ ÀÌ»óÀÇ disk¸¦
                    ÁöÁ¤Çϸç, ¸¸¾à »ý·«µÇ¸é ¸ðµç disk¸¦ ÁöĪÇÑ´Ù
        . intervalÀº 10ÃÊ ÀÌ»óÀ̾î¾ß Çϸç, report´Â optionÀε¥ ±âº»Àº 1 ÀÌ´Ù

      - ¿¹¸¦µé¾î, disk 2¿¡ ´ëÇØ 20ºÐ°£ÀÇ summarizingÀº

      % sadp -h -d hdsk -2 1200

7. Filesystem Buffers

   - filesystemÀº buffer cache¶ó ºÎ¸£´Â Ä¿´Ù¶õ I/O buffer cache¸¦ manageÇϴµ¥
     ÀÌ cache´Â read/write operationÀ» optimizeÇÏ¿© ÁØ´Ù

   - programÀÌ data¸¦ writeÇÒ¶§ filesystemÀº disk¿¡ Áï½Ã writeÇϱ⺸´Ù
     buffer¿¡ storeÇÏ°í, ÈÄ¿¡ systemÀÌ disk driver¿¡ À̵é data¸¦ º¸³½´Ù

   - buffer cache size´Â performance¿¡ Áß¿äÇÑ ¿µÇâÀ» ¹ÌÄ¡Áö¸¸ 
     ¸¸¾à, cache°¡ ´Ã¾î³ª¸é memory°¡ ÁÙ¾îµé¾î CPU¿Í I/O subsystem»çÀÌ¿¡
     paging°ú swapping overload°¡ ¹ß»ýÇÏ°Ô µÈ´Ù

   - System V ¿¡¼­´Â cacheÀÇ »óŸ¦  sar -b ·Î reportÇÑ´Ù

     % sar -b

8. In-memory Filesystems

   - ´ëºÎºÐÀÇ UNIX systemµéÀÌ in-memory filesystemÀ» supportÇϴµ¥,
     vendorµé¿¡ ÀÇÇØ RAMdisk¶ó°í ºÒ¸®±âµµ ÇÑ´Ù

   - in-memory filesystemÀº disk¿¡ Á¸ÀçÇÏÁö ¾Ê´Â filesystemÀ» »ý¼ºÇØ Áִµ¥
     data´Â ´ÜÁö memory¿¡ Á¸ÀçÇϸç, disk driver¿¡¼­¿Í °°ÀÌ À̸§À» Àû¿ëÇÒ¼ö ÀÖ´Ù

   - memory filesystem¿¡ÀÇ access´Â ¸Å¿ì ºü¸£¸ç, data transfer´Â disk driver³ª
     I/O busÀÇ speedº¸´Ù ÈξÀ ºü¸¥ memoryÀÇ speedÀÌ´Ù

   - in-memory filesystemÀÇ °áÁ¡

     ¨ç temporary·Î systemÀÌ rebootµÇ¸é »ç¶óÁø´Ù
     ¨è small size·Î systemÀÇ physical memoryº¸´Ù Ŭ¼ö ¾ø´Ù
     ¨é availableÇÑ physical memoryÀÇ ·®À» ÁÙÀδÙ

   - To create a memory filesystem under SunOS
     
     # mount -t tmp swap mount-point

     ¸¸¾à booting½Ã ÀÚµ¿ÀûÀ¸·Î »ý¼ºÇÏ°íÀÚ Çϸé /etc/fstab¿¡
     
     swap  mount-point tmp rw 0 0 (¿¹, swap /tmp tmp rw 0 0)

9. Stripted Filesystems

   - Disk striptingÀº process´ç disk performance¸¦ ³ôÀ̱â À§ÇÑ techniqueÀ̸ç

   - ÇϳªÀÇ striped filesystemÀº 2°³ ÀÌ»óÀÇ physical disk driverÀÇ ±¸¼ºÀÌ´Ù

   - ¿©·¯ disk¿¡ ºÐÆ÷µÇ¾î ÀÖ´Â fileµéÀº º´·Ä·Î ÀÛ¾÷À» ÇÒ¼ö Àֱ⶧¹®¿¡
     process´ç performance´Â standard ¶Ç´Â single-disk filesystemº¸´Ù ÈξÀ ³ô´Ù

   - striped filesystemÀº ¸Å¿ì Å« fileµéÀ» disk¿¡ I/OÇÏ´Â programµéÀÇ
     performance¸¦ Çâ»ó½ÃÅ°´Âµ¥ µµ¿òÀ»ÁØ´Ù

   - mini-supercomputer classÀÇ ¸¹Àº UNIX systemµéÀÌ stripingÀ» Á¦°øÇÏÁö¸¸ 
     ±âº»ÀûÀΰÍÀº ¾Æ´Ï´Ù

10. Conserving Disk Space

   1) Disk spaceÀÇ ³¶ºñ¸¦ ÁÙÀ̱â À§ÇØ

      - small block size·Î filesystemÀ» ±¸¼º(performance¿¡ ¿µÇâÀ» ¹Ìħ)

      - compress utility¸¦ »ç¿ë fileÀ» ÁÙÀÓ
        compressµÈ fileÀº 30-50% ÀÛ¾ÆÁø´Ù

      - core dump fileµî ºÒÇÊ¿äÇÑ fileµéÀ» clean out

      - ºÒÇÊ¿äÇϰųª »ç¿ëÇÏÁö ¾Ê´Â fileµéÀ» delete

   2) Disk Rationing

      - diskÀÇ ÇÒ´çÀ» À§ÇØ BSD UNIX´Â disk quota system¸¦ supportÇϸç
        ÀÌÀüÀÇ System V´Â ÀüÇô quota systemÀ» Á¦°øÇÏÁö ¾Ê¾ÒÁö¸¸ release V.4
        ¿¡¼­´Â BSD-style(UFS) filesystemÀ» À§ÇØ quota¸¦ supportÇÑ´Ù
   
      - quota´Â filesystem´ÜÀ§·Î °ü¸®ÇÑ´Ù

      - system¿¡ quota¸¦ enableÇϱâ À§ÇØ

        ¨ç super user»óÅ¿¡¼­ filesystemÀÇ root directory·Î °¡¼­
           ¸¸¾à quotas fileÀÌ ¾øÀ¸¸é "touch quotas"¸¦ ÇÏ¿© quotas fileÀ» ¸¸µç´Ù

        ¨è /etc/fstab fileÀ» editÇÏ¿© quota optionÀ» add
          
           /dev/disk1e /w 4.2 rw,quota 1 3

        ¨é °¢ userµé¿¡ quota¸¦ ÇÒ´çÇϱâ À§ÇØ
           # /etc/edquota username

           ¾î¶² user group¿¡ °°Àº quota¸¦ ÇÒ´çÇϱâ À§ÇØ
           # /etc/edquota -p user1 user2 ...

        ¨ê edquota command´Â EDITOR¸¦ invokeÇÑ´Ù

           fs /w blocks (soft=0, hard=0) inodes (soft=0, hard=0)

           ¿©±â¼­ 0´Â no limit¸¦ ÀǹÌÇϸç 0¸¦ disk block°ú file countÀÇ
           ÇÒ´çÀ» À§ÇØ ¼öÁ¤ÇÑÈÄ fileÀ» saveÇÏ°í editor·ÎºÎÅÍ exit

        ¨ë disk¿ë·®¿¡ ºÎÇÕµÇ°Ô quota¸¦ ÇÒ´çÇß´ÂÁö check
      
           # /etc/quotacheck filesystem

        ¨ì /etc/rc file¿¡ /etc/quotaon -a command¸¦ commant outÇÑÈÄ

        ¨í systemÀ» rebootingÇϰųª manual·Î /etc/quotaonÀ» ½ÇÇà

      - ³Ê¹«Å« fileÀÇ »ý¼ºÀ» ¹æÁöÇϱâ À§ÇØ limit command¸¦ »ç¿ëÇÒ ¼öµµ ÀÖ´Ù

        % limit filesize 2m (limit 2MB)

        % limit coredumpsize max-size

        % limit coredumpsize 0 (coredump fileÀÇ »ý¼ºÀ» ¹æÁö)




Revision History
Created     on Dec  22 ,1992