1992.12.22
SUBJECT: Memory Management
STATUS OF THIS MEMO:
System Performance Tuning과 관련하여 MEMORY Management를 위한
utility를 정리한 것임
CONTENTS:
1. Memory Performance
1) How to tell if your system is paging
2) Using vmstat (System V 에서는 sar -w & sar -p)
2. Managing the Swap Area
1) Swap area로 /dev/disk2b를 Add할 경우
2) Filesystem Paging
3) Swap Area Size
3. Computing Memory Requirements
1) Estimating Memory for BSD Systems
2) Estimating Memory for System V
4. Shared Memory
DESCRIPTION:
1. Memory Performance
1) How to tell if your system is paging
- BSD에서 vmstat command를 사용하여 Memory check (vmstat -s)
- page ins : pages moved from disk to memory
- page outs : ,, from memory to disk
- swap ins : processes moved form disk to memory
- swap outs : ,, ,, from memory to disk
2) Using vmstat (System V 에서는 sar -w & sar -p)
% vmstat n m n초 간격으로 m번을 실행 report
% vmstat 2 3
procs memory page disk faults cpu
r b w avm fre re at pi po fr de s0 d1 d2 in sy cs us sy id
0 0 0 0 2504 0 1 1 0 0 0 1 0 0 7 47 6 1 2 97
0 0 0 0 2504 0 0 0 0 0 0 0 0 0 6 62 4 2 2 96
0 0 0 0 2460 0 0 0 0 0 0 0 0 0 3 48 3 2 1 97
- r : The number of runnable processes during the interval
- b : external event나 high-speed I/O를 위해 대기중인 procedss의 수
- w : swapped out된 runnable process의수로 만약, 이 field가
0 이 아니면 이 system은 memory의 부족을 느낀다
- avm : The total amount of active virtual memory
- fre : The number of pages currently on the free list,
the amount of physiacl memort in KByte
- pi : The number of 1-KB pages per second that have ben paged in
- po : ,, ,, ,, ,, ,, paged out since
the last report
- de : memory 부족을 나타내며, 만약 이 field가 0 이 아니면
memory의 부족이 심각함을 의미한다
- s0, d1, d2
The number of disk operations per second on each disk drive
- sy : system상태에서 소요된 total CPU time의 percentage
- us : user상태에서 ,, ,, ,,
- id : idle상태의 total CPU time의 percentage
위에서 가장 중요한 field는 po(page-out)와 w(the number of swapped-
out processes)이다
2. Managing the Swap Area
1) Swap area로 /dev/disk2b를 Add할 경우
- 모든 file system들을 backup한후 /dev/disk2b partition을 newfs
- Build a new kernel that can use /dev/disk2b for swapping
config vmunix swap on disk0b and disk2b
- Modify /etc/fstab to reflect the disk's new organization
/dev/disk2b swap swap rw 0 0 # Systems that support NFS
/dev/disk2b:swap:sw:0:0 # Systems that don't support NFS
- Check /etc/rc & the command /etc/swapon -a enable
* in case System V
# swap -a dev low len
dev : The special file for your swapping partition
low : The starting address of the swapping area within
the swapping partition
len : The size of the swapping partition, in 512-byte disk blocks
- /etc/rc2.d file에 다음과 같이 swap srea를 기술
swap /dev/dsk/ls2 0 29984
2) Filesystem Paging
- Under SunOS
# mkfile size filename
# /usr/etc/swapon filename
- Under System V
# swap filename
3) Swap Area Size
% pstat -s # shows you how mush of your swap space is in use
% /etc/swap -l # in case System V
% sar -r # To get a long-term picture of swap usage
3. Computing Memory Requirements
1) Estimating Memory for BSD Systems
% ps -avx
PID TT STAT TIME SL RE PAGEIN SIZE RSS LIM %CPU %MEM COMMAND
142 p1 R 0:05 0 13 2 296 928 -8 10.3 3.2 cmdtool
167 p1 R 0:00 0 1 0 360 824 -8 7.7 2.8 ps
148 p3 S 0:28 13 36 14 296 720 -8 0.0 2.5 cmdtool
165 p3 S 0:00 17 36 0 432 552 -8 0.0 1.9 vi
- SIZE : The total amount of virtual memory allocated to the
program's data & stack segments, in KByte
- RSS : Resident sets; The total amount of physical memory allocated
to the program's data & stack segments, in KByte
- LIM : The limit applied, if any, to the program's resedent size
- TSIZ : Text size; the total amount of virtual memory allocated to
the program's text segment, in KByte
- TRS : Text resident set; the total amount of virtual memory
allocated to the program's text segment, in KByte
% size /bin/ls # Under SunOS
text data bss dec hex
12560 2536 2552 17648 44f0 ( size in KByte )
2) Estimating Memory for System V
% size /usr/local/bin/myprog
% ps -el
4. Shared Memory
- application의 필요에 의해 shared memory를 사용할수 있으며 SHMMAX나 SHMSIZE
configuration parameter의 수정에 의해 shared memory size를 변경할수 있고
기본은 1 MB이다
- shared memory를 사용하고자 하면 kernel configue file에서 System V IPC
facility를 사용하기위해 option IPCSHMEM 부분을commant out하여 enable하고
/sys/sys/shm.h file에서 SHMMAX나 SHMSIZE 값을 변경한후 kernel build
- shared memory 사용량의 측정은 "ipcs -a"를 사용하여 report
- shared memory의 사용은 application에서 shmget function을 call하여 사용
Revision History
Created on Dec 22 ,1992