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