软件性能测试(连载13)

查看inode和目录项缓存

[28] slabLinux 操作系统的一种内存分配机制,slab 分配算法采用cache 存储内核对象。slab 缓存、从缓存中分配和释放对象然后销毁缓存的过程必须要定义一个kmem_cache 对象,然后对其进行初始化这个特定的缓存包含32 字节的对象。可以通过运行cat /proc/slabinfo |grep -E ‘^#|dentry|inode’ 命令来查看所有目录项和各种文件系统索引节点的缓存情况。

# cat/proc/slabinfo | grep -E ‘^#|dentry|inode’ # name <active_objs> <num_objs> <objsize> <objperslab><pagesperslab> : tunables <limit> <batchcount><sharedfactor> : slabdata <active_slabs> <num_slabs><sharedavail> btrfs_inode0 0 1144 28 8 : tunables 0 0 0: slabdata 0 0 0 ufs_inode_cache0 0 808 40 8 : tunables 0 0 0 : slabdata 0 0 0 qnx4_inode_cache0 0 680 48 8 : tunables 0 0 0 : slabdata 0 0 0 hfs_inode_cache0 0 832 39 8 : tunables 0 0 0 : slabdata 0 0 0 minix_inode_cache0 0 672 48 8 : tunables 0 0 0 : slabdata 0 0 0 ntfs_big_inode_cache0 0 960 34 8: tunables 0 0 0 : slabdata 0 0 0 ntfs_inode_cache0 0 296 55 4 : tunables 0 0 0 : slabdata 0 0 0 xfs_inode0 0 960 34 8 : tunables 0 0 0 : slabdata 0 0 0 mqueue_inode_cache34 34 960 34 8 : tunables 0 0 0 : slabdata 1 1 0 fuse_inode117 117 832 39 8 : tunables 0 0 0 : slabdata 3 3 0 ecryptfs_inode_cache0 0 1024 32 8 : tunables 0 0 0 : slabdata 0 0 0 fat_inode_cache0 0 744 44 8 : tunables 0 0 0 : slabdata 0 0 0 squashfs_inode_cache22954 22954 704 46 8 : tunables 0 0 0 : slabdata 499 499 0 ext4_inode_cache105930 105930 1088 30 8 : tunables 0 0 0 : slabdata 3531 3531 0 hugetlbfs_inode_cache104 104 624 52 8 : tunables 0 0 0 : slabdata 2 2 0 sock_inode_cache2313 2484 704 46 8 : tunables 0 0 0 : slabdata 54 54 0 shmem_inode_cache1840 1840 712 46 8 : tunables 0 0 0 : slabdata 40 40 0 proc_inode_cache7315 10944 680 48 8 : tunables 0 0 0 : slabdata 228 228 0 inode_cache40236 40439 608 53 8 : tunables 0 0 0 : slabdata 763 763 0 dentry214030 214242 192 42 2 : tunables 0 0 0: slabdata 5101 5101 0

其中dentry 行表示目录项缓存,inode_cache 行表示VFS 索引节点缓存,而其他的是各种文件系统的索引节点缓存。除了使用slabinfo 命令查看slab 信息,也可以使用slabtop 命令来查看。

# slabtop Active/ Total Objects (% used) : 539715 / 542626 (99.5%) Active/Total Slabs (% used) : 11100 / 11100(100.0%) Active/Total Caches (% used) : 81 / 109(74.3%) Active/Total Size (% used) : 142659.64K /143801.37K (99.2%) Minimum/Average / Maximum Object : 0.01K / 0.26K / 8.00K OBJSACTIVE USE OBJ SIZE SLABS OBJ/SLAB CACHESIZE NAME 4444054422740% 0.10K 11395 39 45580K buffer_head 1558201444690% 0.19K 3710 42 29680K dentry 70230691050% 1.06K 2341 30 74912K ext4_inode_cache 6090060900100% 0.13K 1015 60 8120K kernfs_node_cache 4043940286 0% 0.59K 763 53 24416K inode_cache

在这里,目录项(dentry )占用了29680K Cache inode inode_cache )的Cache 24416K

③ 查看进程的I/O

查看进程的I/O 情况,使用pidstat -d 参数。

#pidstat -d 1 Average: UID PID kB_rd/s kB_wr/s kB_ccwr/s iodelay Command Average: 0 331 0.00 0.57 0.00 2 jbd2/sda1-8 Average: 0 6353 0.00 3066.10 0.00 0 snapd

其中参数含义如下。

?UID/PID

用户ID/ 进程ID

?kB_rd/s

每秒读取的数据大小,单位是KB

?kB_wr/s

每秒写请求数据大小,单位是KB

?kB_ccwr/s

每秒取消的写请求数据大小,单位是KB

?I/O 延迟(iodelay )。

包括等待同步块I/O 和换入块I/O 结束的时间,单位是时钟周期。

磁盘top 工具

iotop 命令是一个用来监视磁盘I/O 使用状况的top 类工具。使用iotop 需要在unbutu 下另行安装,命令为apt-get install iotop 。图3-31 iotop 的执行情况。

3-31 iotop命令

扩展阅读:磁盘分类

按照存储介质来分,磁盘可以分为机械磁盘与固态磁盘。

?机械磁盘(Hard Disk Driver HDD ):机械磁盘是根据磁头寻道和盘片旋转而获取数据的,最小读写单位是扇区,每个扇区为512B

?固态磁盘(Solid State Disk SSD ):固态磁盘采取“先擦除再写入”的原则,速度比机械抽盘快,但是会产生大量的垃圾。最小读写单位是页,通常大小是4KB 8KB 等。

不管是机械磁盘还是固态磁盘,离散的数据读写比性能连续的要低。

按照接口来分类,可以把硬盘分为。

?IDE Integrated Drive Electronics ):前缀为hd

?SCSI Small Computer System Interface ):前缀为sd

?SAS Serial Attached SCSI )。

?SATA Serial ATA ):前缀为sd

?FC Fibre Channel )。

多块同类型的磁盘,可以按照a b c… 的字母顺序来编 /dev/sda /dev/sdb 。还可以划分为不同的逻辑分区,每个分区再用数字进行编 。比如/dev/sda ,可以分成/dev/sda1 /dev/sda2 2 个分区。

另外也可以把多块磁盘组合成一个逻辑磁盘,构成冗余独立磁盘阵列,也就是RAID Redundant Array of Independent Disks ),从而可以提高数据访问的性能,并且增强数据存储的可靠性。具体细节可以参考3.2.1-3 里面的介绍。

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2020年1月26日
下一篇 2020年1月26日

相关推荐