《性能之巅第2版》阅读笔记(五)--file-system监测

《System Performance: Enterprise and the Cloud, 2nd Edition (2020)》阅读笔记简要记录

8. 文件系统file systems

8.2 模型
8.2.1 文件系统缓存

在这里插入图片描述

缓存命中,从主存中读取;

缓存未命中,从磁盘读取;

8.3 概念
8.3.1 文件系统延时

File system latency is the primary metric of file system performance, measured as the time from a logical file system request to its completion.It includes time spent in the file system and disk I/O subsystem, and waiting on disk devices—the physical I/O.包含:

  • 花在文件系统本身的时间
  • 磁盘I/O子系统时间
  • 磁盘等待物理I/O时间
8.3.2 缓存caching

文件系统使用主存(RAM)来做缓存,以提高性能,这样应用程序可以从RAM中进行读写,而不是物理磁盘,减少了logical I/O latency。

8.3.3 随机与顺序I/O

在这里插入图片描述

8.3.4 预取prefetch

大量文件顺序I/O时,可能数据量太大放不进缓存,这样缓存命中率偏低,影响性能。

预取是检查当前和上一个I/O的文件偏移量,可以检测出当前是否是顺序读负载,并且做出预测,在应用程序请求前向磁盘发出读命令,以填充文件系统缓存。
在这里插入图片描述

8.3.5 预读read-ahead

就是prefetch,Linux中新增了系统调用readadhead(2)允许应用显示预热文件系统缓存。

8.3.6 回写缓存write-back caching

Write-back caching is commonly used by file systems to improve write performance. It works by treating writes as completed after the transfer to main memory, and writing them to disk sometime later, asynchronously.

8.3.7 同步写

A synchronous write completes only when fully written to persistent storage (e.g., disk devices), which includes writing any file system metadata changes that are necessary. 同步写比异步写(写回缓存)要慢的多。

8.3.8 裸I/O和直接I/O(raw and direct)

裸I/O:绕过文件系统,直接发给磁盘地址。比如数据库软件。

直接I/O:允许app绕过缓存使用文件系统,有点类似同步写(但缺少O_SYNC选项提供的保证)。

8.3.9 非阻塞I/O

open()调用时传入O_NONBLOCK或者O_NDELY选项使用非阻塞I/O。

8.3.10 内存映射文件memory-mapped files

对于某些应用程序和负载,通过吧文件映射到进程地址空间,并直接读取内存地址,可以提高文件系统I/O性能。

系统调用mmap()创建,munmap()销毁。映射可以用madvise()调整。

8.4 架构
8.4.1 I/O栈

在这里插入图片描述

8.4.2 VFS

VFS (the virtual file system interface) provides a common interface for different file system types.
在这里插入图片描述

8.4.3 文件系统缓存

在这里插入图片描述

buffer cache缓冲区高速缓存Linux used a buffer cache at the block device interface to cache disk device blocks.
The size of the buffer cache is dynamic and is observable from /proc.
page cache页缓存It cached virtual memory pages, including mapped file system pages, improving the performance of file and directory I/O. It was more efficient for file access than the buffer cache, which required translation from file offset to disk offset for each lookup.
dentry cache目录缓存The dentry cache (Dcache) remembers mappings from directory entry (struct dentry) to VFS inode, similar to an earlier Unix directory name lookup cache (DNLC).
inode cacheinode缓存This cache contains VFS inodes (struct inodes), each describing properties of a file system object, many of which are returned via the stat(2) system call.
8.4.5 文件系统类型
FFSfast file system (FFS)
ext3
ext4
XFSXFS is supported by most Linux distributions and can be used for the root file system.
ZFScombining the file system with the volume manager and including numerous enterprise features, making it an attractive choice for file servers (filers).
btrfsThe B-tree file system (btrfs) is based on copy-on-write B-trees. This is a modern file system and volume manager combined architecture, similar to ZFS, and is expected to eventually offer a similar feature set.
8.4.6 卷和池volumes and pools

在这里插入图片描述

文件系统一直以来建立在一块磁盘后者一个磁盘分区上,卷和池可以使文件系统建立在多块磁盘上,并可以使用不同的RAID策略。

卷把多块磁盘组合成一块虚拟磁盘,在此之上建立文件系统。卷管理软件:Logical volume manager,LVM。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值