【新聞內容】接觸固態硬盤的應該都會關心耐用性、壽命這樣的指標,這源於閃存存儲的特質。現代智能手機、平板機使用的基本也是閃存,但因為日常負載都是輕量級的,所以很少碰到類似問題,但也有例外。
Nexus 7(舊版)就是比較突出的一個,它本身的存儲I/O性能就不太夠,影響系統流暢性,特別是隨著時間的流逝、應用的增多,很容易會變得非常慢,大大影響了人們對這款平板的評價。
新版的Nexus 7大大提升了存儲性能,而且借助新的安卓4.3,耐用性問題也得到了解決。事實上,所有的Nexus設備都能享受這種福利!
其實就是我們常說的TRIM,只不過後者是Windows系統的,它則是Linux系統的。它們的原理是相同的:在主控和閃存之間建立一個通信通道,操作系統籍此告知SSD/eMMC主控某些閃存區塊已經不再使用,無需繼續追踪,可以執行垃圾回收了。
這對維持閃存存儲長時間性能穩定是至關重要的。要知道,在閃存設備上刪除軟件的時候,執行的只是一個軟件標記,讓用戶看起來空間釋放了,但物理存儲並未發生變化,在主控看來響應的區塊還在使用中,仍舊有正常數據。
比如說,你向手機存儲中拷貝了一部3GB的電影,看完了刪了,3GB空間看起來解放了,但在你重新向這些區塊寫入數據之前,在主控眼裡,電影還在那兒。
安卓4.3對此是這麼處理的:系統框架發出一個“start idle maintenance window”(開始空閒維護窗口)的事件,MountService系統服務接聽到 之後,便通過磁盤管理進程vold聯繫fstrim文件系統,執行清理。
不過這一系列操作是需要滿足一定前提條件才會觸發的:設備未使用超過一個小時、過往24小時沒有空閒維護窗口事件、電池剩餘電量不低於80%、設備正在充電且電量不低於30 %。
如果你習慣每天晚上插上充電,fstrim會大概每24小時執行一次。
驗證fstrim是否工作也很簡單,只要在ADB中執行以下命令:
adb logcat -d | grep -i fstrim
下邊就是輸出示例(系統都是4.3):
Nexus 7 (2013):
┌─[brianklug@MBP] - [~/Downloads/APKs] - [Mon Jul 29, 03:30]
└─[$] <> ./adb logcat -d | grep -i fstrim
I/fstrim ( 172): Starting fstrim work...
I/fstrim ( 172): Invoking FITRIM ioctl on /cache
I/fstrim ( 172): Trimmed 564789248 bytes on /cache
I/fstrim ( 172): Invoking FITRIM ioctl on /data
I/fstrim ( 172 ): Trimmed 25105637376 bytes on /data
I/fstrim ( 172): Invoking FITRIM ioctl on /persist
I/fstrim ( 172): Trimmed 0 bytes on /persist
I/fstrim ( 172): Finished fstrim work.
I/fstrim ( 172 ): Starting fstrim work...
I/fstrim ( 172): Invoking FITRIM ioctl on /cache
I/fstrim ( 172): Trimmed 0 bytes on /cache
I/fstrim ( 172): Invoking FITRIM ioctl on /data
I/fstrim ( 172): Trimmed 1045696512 bytes on /data
I/fstrim ( 172): Invoking FITRIM ioctl on /persist
I/fstrim ( 172): Trimmed 0 bytes on /persist
I/fstrim ( 172): Finished fstrim work.
Nexus 7 (2012):
┌─[brianklug@MBP] - [~/Downloads/APKs] - [Mon Jul 29, 03:46]
└─[$] <> ./adb logcat -d | grep -i fstrim
I/fstrim ( 122): Starting fstrim work...
I/fstrim ( 122): Invoking FITRIM ioctl on /cache
I/fstrim ( 122): Trimmed 122961920 bytes on /cache
I/fstrim ( 122): Invoking FITRIM ioctl on /data
I/fstrim ( 122 ): Trimmed 1087574016 bytes on /data
E/fstrim ( 122): Cannot stat mount point /radio
I/fstrim ( 122): Finished fstrim work.
I/fstrim ( 122): Starting fstrim work...
I/fstrim ( 122 ): Invoking FITRIM ioctl on /cache
I/fstrim ( 122): Trimmed 118923264 bytes on /cache
I/fstrim ( 122): Invoking FITRIM ioctl on /data
I/fstrim ( 122): Trimmed 782077952 bytes on /data
E/fstrim ( 122): Cannot stat mount point /radio
I/fstrim ( 122): Finished fstrim work.
Nexus 4:
┌─[brianklug@MBP] - [~/Downloads/APKs] - [Mon Jul 29, 03:47]
└─[$] <> ./adb logcat -d | grep -i fstrim
- waiting for device -
I/ fstrim ( 169): Starting fstrim work...
I/fstrim ( 169): Invoking FITRIM ioctl on /cache
I/fstrim ( 169): Trimmed 115343360 bytes on /cache
I/fstrim ( 169): Invoking FITRIM ioctl on /data
I/fstrim ( 169): Trimmed 888254464 bytes on /data
I/fstrim ( 169): Invoking FITRIM ioctl on /persist
I/fstrim ( 169): Trimmed 0 bytes on /persist
I/fstrim ( 169): Finished fstrim work.
I/fstrim ( 169): Starting fstrim work...
I/fstrim ( 169): Invoking FITRIM ioctl on /cache
I/fstrim ( 169): Trimmed 113246208 bytes on /cache
I/fstrim ( 169): Invoking FITRIM ioctl on /data
I/fstrim ( 169): Trimmed 1431195648 bytes on /data
I/fstrim ( 169): Invoking FITRIM ioctl on /persist
I/fstrim ( 169): Trimmed 0 bytes on /persist
I/fstrim ( 169): Finished fstrim work.
如果你的設備經歷著性能倒退的問題,升級到4.3之後讓sftrim工作幾次應該就能滿血復活了。至於究竟能恢復多少,請等測試。
| |
|