国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Linux > 正文

Linux內核的文件預讀readahead

2024-06-28 13:19:07
字體:
來源:轉載
供稿:網友
linux內核的文件預讀readahead 2015-08-19 18:09 by 瀟湘隱者, ... 閱讀, ... 評論, 收藏, 編輯

Linux的文件預讀readahead,指Linux系統內核將指定文件的某區域預讀進頁緩存起來,便于接下來對該區域進行讀取時,不會因缺頁(page fault)而阻塞。因為從內存讀取比從磁盤讀取要快很多。預讀可以有效的減少磁盤的尋道次數和應用程序的I/O等待時間,是改進磁盤讀I/O性能的重要優化手段之一。

維基百科上關于readhead的介紹資料:

readahead is a system call of the Linux kernel that loads a file's contents into the page cache, PRoviding that way a file prefetching technology. When a file is subsequently accessed, its contents are read from the main memory (RAM) rather than from a hard disk drive (HDD), resulting in much lower file access latencies due to much higher performance of the main memory.[1][2]

Many Linux distributions use readahead on a list of commonly used files to speed up booting. In such a setup, if the kernel is booted with the profile boot parameter, it will record all file accesses during bootup and write a new list of files to be read during later boot sequences. This will make additional installed services start faster, because they are not included in the default readahead list.[3]

In Linux distributions that use systemd, readahead binary (as part of the boot sequence) is replaced by systemd-readahead.[4][5] However, support for readahead was removed from systemd in its version 219, being described as unmaintained and unable to provide expected performance benefits.[6]

Certain experimental page-level prefetching systems have been developed to further improve performance.[7]

查看、設置readhead使用命令blockdev。如下所示:

[root@localhost ~]# /sbin/blockdev
Usage:
 blockdev -V
 blockdev --report [devices]
 blockdev [-v|-q] commands devices
Available commands:
 --getsz get size in 512-byte sectors
 --setro set read-only
 --setrw set read-write
 --getro get read-only
 --getss get logical block (sector) size
 --getpbsz get physical block (sector) size
 --getiomin get minimum I/O size
 --getioopt get optimal I/O size
 --getalignoff get alignment offset
 --getmaxsect get max sectors per request
 --getbsz get blocksize
 --setbsz BLOCKSIZE set blocksize on file descriptor opening the block device
 --getsize get 32-bit sector count
 --getsize64 get size in bytes
 --setra READAHEAD set readahead
 --getra get readahead
 --setfra FSREADAHEAD set filesystem readahead
 --getfra get filesystem readahead
 --flushbufs flush buffers
 --rereadpt reread partition table

查看磁盤的預讀扇區

[root@localhost ~]# /sbin/blockdev --getra /dev/sda
256
[root@localhost ~]# /sbin/blockdev --getra /dev/sdb
256
[root@localhost ~]# 

clip_image001

設置磁盤的預讀扇區

[root@localhost ~]# /sbin/blockdev --getra /dev/sda
256
[root@localhost ~]# /sbin/blockdev --setra 2048 /dev/sda
[root@localhost ~]# /sbin/blockdev --getra /dev/sda
2048
[root@localhost ~]# /sbin/blockdev --getra /dev/sdb
256
[root@localhost ~]# /sbin/blockdev --setra 2048 /dev/sdb
[root@localhost ~]# /sbin/blockdev --getra /dev/sdb
2048
[root@localhost ~]# 

clip_image002

必須將其寫入配置文件/etc/rc.local,否則重啟就會失效。

[root@localhost ~]# echo '/sbin/blockdev --setra 2048 /dev/sda' >> /etc/rc.local
[root@localhost ~]# more /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
/sbin/blockdev --setra 2048 /dev/sda
[root@localhost ~]# echo '/sbin/blockdev --setra 2048 /dev/sdb' >> /etc/rc.local
[root@localhost ~]# more /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
/sbin/blockdev --setra 2048 /dev/sda
/sbin/blockdev --setra 2048 /dev/sdb

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 尼玛县| 布拖县| 榆树市| 宜黄县| 永昌县| 民乐县| 安西县| 理塘县| 南召县| 邓州市| 龙南县| 张家港市| 鄢陵县| 普兰店市| 商水县| 平昌县| 大城县| 黑河市| 哈尔滨市| 马公市| 阿拉善右旗| 江都市| 赣榆县| 双鸭山市| 德昌县| 江安县| 五原县| 文山县| 通榆县| 龙江县| 内丘县| 潞城市| 成安县| 河西区| 浦东新区| 津市市| 西乌珠穆沁旗| 延寿县| 龙山县| 五家渠市| 澄迈县|