《system performance》&《BPF PerformanceTools》读书笔记(六)Disks

背景及概念

1.Block I/O stack

读写请求经过文件系统转换为IO请求,进入block层。IO在block层可能会被转发,拆分,合并,排序等一系列处理,最终提交给物理驱动层。

2.I/O elevator & schedulers

电梯算法负责将IO合并及排序,目的是为了适配rotation disk的IO特性以提高其性能。后续又加入了各种调度器,用于平衡IO吞吐量和IO延时,并提供了针对进程的IO优先级设置,以及均衡策略。

3.Disk I/O performance

系统统计的IO延时主要可分为两部分,Wait Time表示IO在block层调度队列等待处理的时间,Service Time表示驱动层及磁盘处理IO请求的时间。分析IO性能时可优先确认这两者比例,以定位性瓶颈的范围,blktrace+btt工具可方便测得该数据。

4.IOwait

一个比较点迷的参数,表示CPU idle时并且有进程在等待IO的时间,CPU压力也会严重影响IOwait。可参考IOwait 到底在wait什么

 

分析方法及策略

1.USE 分析

利用率:设备在处理IO的时间百分比

checklist:

iostat -xz 1,sar -d 1    //%util

/proc/PID/sched    //se.statistics.iowait_sum

饱和度:IO在队列里等待时间

checklist:

iostat -xz 1,sar -d 1     //avgqu-sz > 1 , wait 过高

biolatency     //bpf tool, io延时分布

fileslower      //bpf tool, vfs_read vfs_write 延时统计

2.负载/性能描述

checklist:

iostat -xz 1,sar -d 1    //iops , bandwidth , io size ,await ,read/write 比例 

bitesize    //bpf tool, 各进程 io size 分布

seeksize    //bpf tool, 提交io 的随机程度

biopattern    //bpf tool, 完成io 的随机程度

biostacks    //bpf tool, io调用栈及延时

3.延时分析

利用blktrace、内核跟踪等手段,对IO延时进行drill-down分析, 定位延时主因,调度器,controller,驱动,磁盘等等。

4.是否存在IO放大

应用请求的数据,与磁盘实际IO的差异,可利用动态跟踪工具同时统计应用进程在fs层与block层的IO带宽,对比差异。

 

监测工具

1.传统工具

iostat ,iotop, blktrace

2.BPF 工具

biolatency

统计IO延时的分布,(BCC 支持-Q -D ,单独统计IOqueue 和disk 延时)

biosnoop

列出运行期间每次IO的对应进程及延时,(BCC 支持-Q -D ,单独统计IOqueue 和disk 延时)

bitsize

统计各进程提交IO的size分布

seeksize

统计各进程提交IO需要seek的size分布,可反映各进程IO请求的随机程度

biopattern

统计磁盘实际IO随机/连续程度,与seeksize区别是biopattern统计IO完成时的数据,加入调度器电梯算法排序的效果。

biostack

统计每种IO调用stack 的延时分布,可用于定位哪种IO操作延时最大。

bioerr

列出运行期间发生的IO错误

mdflush 

列出software RAID flush调用

iosched

统计IO请求在调度器queue内的延时分布

scsilatency

统计scsi 各cmd的执行延时

scsiresult

统计scsi 个cmd的执行结果

nvmelatency

统计nvme 设备各CMD的执行延时

 

调整方法

1. IO优先级(bfq/cfq)

只有在调度器选择bfq或者cfq时配置进程的IO优先级才有效,配置方法有两种

  • ionice 命令

  • cgroup io.weight , cgroup中的进程可使用io.weight参数配置IO优先级,ionice命令对cgroup内的进程不生效。

2.调度器选择及参数调整

3.block 设备参数

queue_len,block_size , readahead ....

4.Cgroup资源限制

 

 

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
BPF and related observability tools give software professionals unprecedented visibility into software, helping them analyze operating system and application performance, troubleshoot code, and strengthen security. BPF Performance Tools: Linux System and Application Observability is the industry’s most comprehensive guide to using these tools for observability. Brendan Gregg, author of the industry’s definitive guide to system performance, introduces powerful new methods and tools for doing analysis that leads to more robust, reliable, and safer code. This authoritative guide: Explores a wide spectrum of software and hardware targets Thoroughly covers open source BPF tools from the Linux Foundation iovisor project’s bcc and bpftrace repositories Summarizes performance engineering and kernel internals you need to understand Provides and discusses 150+ bpftrace tools, including 80 written specifically for this book: tools you can run as-is, without programming — or customize and develop further, using diverse interfaces and the bpftrace front-end You’ll learn how to use BPF (eBPF) tracing tools to analyze CPUs, memory, disks, file systems, networking, languages, applications, containers, hypervisors, security, and the Linux kernel. You’ll move from basic to advanced tools and techniques, producing new metrics, stack traces, custom latency histograms, and more. It’s like having a superpower: with Gregg’s guidance and tools, you can analyze virtually everything that impacts system performance, so you can improve virtually any Linux operating system or application.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值