요즘(?) 리눅스는 언젠가 부터 그냥 냅두면 메모리를 야곰야곰 먹으면서 file system을 캐싱하는데
page cache를 위해서 free 메모리를 자꾸 갉아먹는다.
[링크 : https://jujupapa.tistory.com/31]
slabtop이라는걸 통해서 캐싱되고 있는 페이지를 확인할 수 있다는데 봐도 무슨 소리이지 모르겠고..
$ slabtop fopen /proc/slabinfo: 허가 거부 $ sudo cat /proc/slabinfo slabinfo - version: 2.1 # name <active_objs> <num_objs> <objsize> <objperslab> <pagesperslab> : tunables <limit> <batchcount> <sharedfactor> : slabdata <active_slabs> <num_slabs> <sharedavail> nf_conntrack 856 1248 256 32 2 : tunables 0 0 0 : slabdata 39 39 0 ovl_inode 44 44 728 22 4 : tunables 0 0 0 : slabdata 2 2 0 i915_dependency 256 256 128 32 1 : tunables 0 0 0 : slabdata 8 8 0 $ sudo slabtop -o 활성 / 총 개체 수 (사용 %) : 3102305 / 3121463 (99.4%) 활성 / 총 slab 수 (사용 %) : 87745 / 87745 (100.0%) 활성 / 총 캐시 수 (사용 %) : 130 / 178 (73.0%) 활성 / 총 크기 (사용 %) : 748809.62K / 753765.53K (99.3%) 최소 / 평균 / 최대 개체 수: 0.01K / 0.24K / 9.00K 활성 개체 사용개체크기 SLAB 개체/SLAB 캐시 크기 이름 994617 994553 99% 0.10K 25503 39 102012K buffer_head 463407 463082 99% 0.19K 22067 21 88268K dentry 342720 342595 99% 0.05K 4032 85 16128K shared_policy_node 268299 268294 99% 1.16K 9937 27 317984K ext4_inode_cache $ sudo slabtop M-m~Y~\M-l~DM-1 / M-lM-4~] M-jM-0~\M-lM-2M-4 M-l~H~X (M-l~BM-,M-l~ZM-) %) : 3099702 / 3121184 (99.3%) M-m~Y~\M-l~DM-1 / M-lM-4~] slab M-l~H~X (M-l~BM-,M-l~ZM-) %) : 87736 / 87736 (100.0%) M-m~Y~\M-l~DM-1 / M-lM-4~] M-lM-:~PM-l~K~\ M-l~H~X (M-l~BM-,M-l~ZM-) %) : 130 / 178 (73.0%) M-m~Y~\M-l~DM-1 / M-lM-4~] M-m~AM-,M-jM-8M-0 (M-l~BM-,M-l~ZM-) %) : 748420.12K / 753805.55K (99.3%) M-lM-5~\M-l~F~L / M-m~O~IM-jM-7M- / M-lM-5~\M-k~L~@ M-jM-0~\M-lM-2M-4 M-l~H~X: 0.01K / 0.24K / 9.00K M-m~Y~\M-l~DM-1 M-jM-0~\M-lM-2M-4 M-l~BM-,M-l~ZM-)M-jM-0~\M-lM-2M-4M-m~AM-,M-jM-8M-0 SLAB M-jM-0~\M-lM-2M-4/SLAB M-lM-:~PM-l~K~\ M-m~AM-,M-jM-8M-0 M-l~]M-4M-kM-&~D 995397 995397 99% 0.10K 25523 39 102092K buffer_head 463407 462914 99% 0.19K 22067 21 88268K dentry 342720 342468 99% 0.05K 4032 85 16128K shared_policy_node |
[링크 : https://linux.die.net/man/1/slabtop]
glusterFS 쪽에서 나오는 문서.
아무튼 커널에 의해서 캐싱된 내용을 어떻게 유지할 지 등에 대한 설정이 sysfs에 존재한다.
vm.vfs_cache_pressure This option controls the tendency of the kernel to reclaim the memory which is used for caching of directory and inode objects. At the default value of vfs_cache_pressure=100 the kernel will attempt to reclaim dentries and inodes at a "fair" rate with respect to pagecache and swapcache reclaim. Decreasing vfs_cache_pressure causes the kernel to prefer to retain dentry and inode caches. When vfs_cache_pressure=0, the kernel will never reclaim dentries and inodes due to memory pressure and this can easily lead to out-of-memory conditions. Increasing vfs_cache_pressure beyond 100 causes the kernel to prefer to reclaim dentries and inodes. With GlusterFS, many users with a lot of storage and many small files easily end up using a lot of RAM on the server side due to 'inode/dentry' caching, leading to decreased performance when the kernel keeps crawling through data-structures on a 40GB RAM system. Changing this value higher than 100 has helped many users to achieve fair caching and more responsiveness from the kernel. |
To free pagecache: (페이지케쉬 클리어) # echo 1 > /proc/sys/vm/drop_caches To free dentries and inodes: (트리와 아이노드 클리어) # echo 2 > /proc/sys/vm/drop_caches To free pagecache, dentries and inodes: (1번과 2번 모두 클리어) # echo 3 > /proc/sys/vm/drop_caches |
'Linux' 카테고리의 다른 글
systemd 지연된 시작 (0) | 2024.02.29 |
---|---|
btrfs fsck (0) | 2024.02.13 |
multitail / tail (2) | 2023.10.18 |
top 로그로 남기기 (0) | 2023.10.17 |
tcpdump (0) | 2023.09.04 |