[Linux] 使用noatime屬性優化文件系統讀取性能

博客原文:
**hackershell**html

當文件被建立,修改和訪問時,Linux系統會記錄這些時間信息,當訪問足夠頻繁將會是很大的開銷,由於每次訪問都會記錄時間,因此 咱們今天使用bonnie++來簡單測試咱們修改noatime給咱們帶來的性能提高有多少,咱們先下載最新版本的bonnie++shell

# tar xf bonnie++-1.97.tgz
# cd bonnie++-1.97.1
# make

編譯好以後就能夠使用了vim

注:測試數據最好爲內存的2倍dom

因此在沒修改noatime以前,咱們先測試文件系統的性能工具

./bonnie++ -s 31896 -d /export/ -u root -q >> file.csv

運行結果以下:性能

Version  1.97       ------Sequential Output------ --Sequential Input- --Random-
Concurrency   1     -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
Machine        Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP  /sec %CP
localhost    31896M   458  99 189663  52 82909  21  2487  98 214994  26 823.4  56
Latency             32591us     566ms     705ms   11924us     252ms     122ms
Version  1.97       ------Sequential Create------ --------Random Create--------
localhost           -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--
              files  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP
                 16 16300  79 +++++ +++ +++++ +++ 14745  74 +++++ +++ 18007  32
Latency             10929us     478us     521us     493us     134us     374us

接下來咱們修改掛載的/export,從新測試一遍測試

# vim /etc/fstab
UUID=d41182b5-5092-4f2f-88a3-be619feef512 /export                 ext4    defaults,noatime        1 2

設置當即生效.net

mount -o remount /export

執行命令:code

./bonnie++ -s 31896 -d /export/ -u root -q >> file.csv

運行結果爲:htm

Version  1.97       ------Sequential Output------ --Sequential Input- --Random-
Concurrency   1     -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
Machine        Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP  /sec %CP
localhost    31896M   497  99 171760  35 93152  21  2276  97 240294  28 755.6  45
Latency             18716us     661ms     539ms   29368us     263ms   79468us
Version  1.97       ------Sequential Create------ --------Random Create--------
localhost           -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--
              files  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP
                 16 18605  93 +++++ +++ +++++ +++ 20520  96 +++++ +++ +++++ +++
Latency              1186us     379us    1297us    1288us     127us    1443us

可能這樣的結果不直觀,咱們能夠

cat file.csv | ./bon_csv2html > result.html

網頁打開爲:

<img src="http://hackershell.cn/image/noatime2.png&quot; alt="noatime_test1" align=center />

能夠看出214MBps提高到了240MBps,雖然這只是一次測試,可是理論上來講仍是會有性能上的提高,在總體的集羣環境下,仍是有益提高集羣性能的。

參考資料:

測試工具Bonnie++的使用

相關文章
相關標籤/搜索