大多数现代Linux系统都有一个或多个磁盘驱动。如果它们是IDE驱动,那么常常将被命名为hda、hdb、hdc等;而SCSI驱动则常常被命名为sda、sdb、sdc等。磁盘通常要分为多个分区,分区设备名称的创建方法是在基础驱动名称的后面直接添加分区编号。比如,系统中首个IDE硬驱动的第二个分区通常被标记为/dev/hda2。一般每个独立分区要么包含一个文件系统,要么包含一个交换分区。这些分区被挂载到Linux根文件系统,该系统由/etc/fstab指定。这些被挂载的文件系统包含了应用程序要读写的文件。
当一个应用程序进行读写时,Linux内核可以在其高速缓存或缓冲区中保存文件的副本,并且可以在不访问磁盘的情况下返回被请求的信息。但是,如果Linux内核没有在内存中保存数据副本,那它就向磁盘I/O队列添加一个请求。若Linux内核注意到多个请求都指向磁盘内相邻的区域,它会把它们合并为一个大的请求。这种合并能消除第二次请求的寻道时间,以此来提高磁盘整体性能。当请求被放入磁盘队列,而磁盘当前不忙时,它就开始为I/O请求服务。如果磁盘正忙,则请求就在队列中等待,直到该设备可用,请求将被服务。
vmstat可以提供系统整体上的I/O性能情况。
usage: vmstat [-n] [DELAY [COUNT]]
Print virtual memory statistics, repeating each DELAY seconds, COUNT times.
(With no DELAY, prints one line. With no COUNT, repeats until killed.)
Show processes running and blocked, kilobytes swapped, free, buffered, and
cached, kilobytes swapped in and out per second, file disk blocks input and
output per second, interrupts and context switches per second, percent
of CPU time spent running user code, system code, idle, and awaiting I/O.
First line is since system started, later lines are since last line.
-n Display the header only once
vmstat中与IO相关的字段包括bi(file disk blocks input per second)、bo(file disk blocks output per second)、wa(percent of CPU time spent awaiting I/O)。
下面是vmstat 1 10的输出。

iostat是一个专门用于显示磁盘I/O子系统统计信息的工具。
Usage: iostat [-c] [-d] [-t] [-z] [-k|-m] [ALL|BLOCKDEV...] [INTERVAL [COUNT]]
Report CPU and I/O statistics
-c Show CPU utilization
-d Show device utilization
-t Print current time
-z Omit devices with no activity
-k Use kb/s
-m Use Mb/s
下面是iostat的默认输出。

iotop根据IO使用情况进行排序。
Usage: iotop [-h] [-P] [-d ] [-n ] [-s ]
-a Show byte count instead of rate
-d Set the delay between refreshes in seconds.
-h Display this help screen.
-m Set the number of processes or threads to show
-n Set the number of refreshes before exiting.
-P Show processes instead of the default threads.
-s Set the column to sort by:
pid, read, write, total, io, swap, sched, mem or delay.
下面是iotop -d 1 -m 5 -n 3的输出。

lsof提供了一种方法来确定哪些进程打开了一个特定的文件。
usage: lsof [-lt] [-p PID1,PID2,...] [FILE...]
List all open files belonging to all active processes, or processes using
listed FILE(s).
-l list uids numerically
-p for given comma-separated pids only (default all pids)
-t terse (pid only) output
下面是lsof -p pid_surfaceflinger的部分输出。

Android中dumpsys diskstats命令可以查看当前用户数据分区的使用情况。
下面是dumpsys diskstats的输出。

在网络层次结构的最低几层,Linux可以侦测到流经链路层的数据流量的速率。链路层,通常是以太网,以帧序列的形式将信息发送到网络上。即便是其上层次的信息片段的大小比帧大很多,链路层也会将它们分割为帧,再发送到网络上。数据帧的最大尺寸被称为最大传输单位(MTU)。你可以使用网络配置工具,如ip或ifconfig来设置MTU。对以太网而言,最大大小一般为1500字节,虽然有些硬件支持的巨型帧可以高达9000字节。MTU的大小对网络效率有直接影响。链路层上的每一个帧都有一个小容量的头部,因此,使用大尺寸的MTU就提高了用户数据对开销(头部)的比例。但是,使用大尺寸的MTU,每个数据帧被损坏或丢弃的几率会更高。对清洁物理链路来说,大尺寸MTU通常会带来更好的性能,因为它需要的开销更小;反之,对嘈杂的链路来说,更小的MTU则通常会提升性能,因为,当单个帧被损坏时,它要重传的数据更少。
在物理层,帧流经物理网络,Linux内核可以收集大量有关帧数量和类型的不同统计数据:
ifconfig
ip
netsat
ping
iptables
tcpdump
Android Studio Profiler