找回密碼
 註冊
搜索
查看: 2674|回復: 0

[教學] Swappolube from extras-devel 系統內存優化 (10/1更新)

[複製鏈接]
發表於 18-10-2010 14:29:13 | 顯示全部樓層 |閱讀模式
文章出自:
) F+ i+ B' r2 g" r9 b9 _; e(sonarsu) http://www.maemoers.com/thread-6106-1-12.html
2 n8 z9 T. H( J# P" o8 G4 shttp://discussions.europe.nokia.com/t5/Maemo-Devices/Make-your-N900-faster-with-Swappolube/m-p/764001. M# U/ [2 \# }( p  f2 w
+ P( l% ^  i* a) K$ x+ r/ k
" ?; q% \: f' Y$ C1 j+ z6 l
打開 x-terminal 執行:
7 x. J1 W3 \3 s* ^; u2 Hsudo gainroot2 I9 N3 \: u) I6 F6 q/ [
apt-get install swappolube 安裝這個軟件,但目錄底下還是請務必加上extras-devel這個來源. H! j0 U% A& Q, [% A; x' ]

  T3 @) v; x$ g  G第一次發帖,很多事情沒考慮清楚,請各位前輩多多見諒.! C( _0 C4 Y& }: v* H
1.安裝完畢後,會出現這個程序 swappolube,您打開後您會發現原先是0 \1 L/ s# y, X
100 Swappiness  }  H' J6 B; t
40 Dirty Ratio
/ T6 O9 ~  T" D: S5 P10 dirty BGD ratio
5 I/ k+ d& \. d7 J6 W" a' D" ?500 Dirty Expire Centisecs
: Z; M$ R1 I$ h  e8 m1 i" W1 A500 Dirty Writeback Centisecs
& w3 q5 `7 S6 f% {) b$ V8 I5 Page-Cluster
3 t7 y* \$ a. k右方顯示0等等資訊
6 X1 }; y; A" z) j8 F" b& B& t( \
2 `  n8 h1 C2 F1 n: D0 Z) y* d6 s* C6 ~
最快速的調整參數請參照,這樣調整就可以了! _$ q1 b% v0 e5 N" ^& ^9 ^

1 a, x# O$ s) J順序為 1.proposed  2.apply  3.store  ,  4.開機後重新打開程序看有沒有跑掉參數
; l) O6 l0 v* R2 V8 M$ ^# H0 F0 g' c- P9 q3 A4 p
圖中select是要改變時勾選
5 n' c" N  w2 @- U1 b7 I0 b1 Y+ W  ~: K
建議還是以NOKIA SUPPORT上面的參數來設定,簡單明瞭/ d" y0 ^2 X; M! R4 E6 I8 [& `+ J/ a

2 x% n( o3 B3 w8 }好處是:5 T( N; D" _4 X* w% N8 L: S, f
1.不必超頻就可以讓系統內存最佳化,跑得飛快,不必那麼卡卡的,誰說N900笨重又慢的?
% L# o, i  x! o5 q: h2.耗電量測試的結果,比起未安裝前只有多那麼一點點,也不會像是超頻這麼熱,效果卻是不錯的,沒跑3D Game的情況下,這個優化效果不錯,但是這裡需要強調是並非萬靈丹,有某些程式你不跑超頻光靠內存的排擠與優化還是跑不順,建議適當的超頻運用起來更好(2010-10-08修正)  b% J- I' {. x5 Z$ _( c
3.對網路瀏覽優化,一,系統會背地裡幫大家做好,瀏覽更順了0 R) k9 J! ]; c" m2 f' U, s+ H2 @! n
' @; ~& R. ]3 k" A* k
疑問回答:
1 Q& ~! q- z. \4 f4 d  }1.電池的電力不會變得耗電,測試過三天跟之前無明顯變化,不會特別耗電
# M- ^. C$ b4 _7 ~$ E2.rootfs太低也不會使得系統快到哪裡去,只好期待新的韌體更新,多多用conky注意安裝軟件時佔用rootfs的狀況,沒依照規範寫的程式就別裝了,會拖慢系統
: S  F& Z% P* f, l3.更改後 apply->store 重開機再來看看有沒有儲存進去以下提供手動方法,利用xterm輸入或包裝成script執行6 h. G* d3 D/ t3 t
echo "30" > /proc/sys/vm/swappiness        
/ N: x$ \7 n8 b- C" pecho "0" > /proc/sys/vm/page-cluster        " j2 V2 j  o9 b1 p$ L
echo "1" > /proc/sys/vm/laptop_mode        7 [/ U. N9 B- E/ D. E. Z
echo "1" > /proc/sys/vm/oom_kill_allocating_task        & i0 f" f4 ~% {0 g1 T
echo "0" > /proc/sys/vm/dirty_expire_centisecs        
( C, C9 l) n5 P4 @: G) a: ^: uecho "0" > /proc/sys/vm/dirty_writeback_centisecs      
1 E0 W  `9 {  y& ^0 X- {( jecho "60" > /proc/sys/vm/dirty_background_ratio        
0 I% o: d0 E9 ]! Oecho "95" > /proc/sys/vm/dirty_ratio        ( k5 M( ?: E* s+ L4 @& Z' B
echo "0" > /proc/sys/net/ipv4/tcp_timestamps        ( ?1 C9 d) O6 z  k' [9 m
echo "1" > /proc/sys/net/ipv4/tcp_no_metrics_save* A+ l# X6 }% [8 X& v3 E; [% ^- Q/ y; ^. r
利用 cat指令 看看有沒有寫入 例如:cat  /proc/sys/vm/swappiness 2 c0 Z4 r8 u" G5 [: j
4.這個參數部分可以自己亂試,你愛改多少就改多少,可以去感受一下差異,並不會危及任何硬體及設定
$ I1 @  q5 P; J% m2 f2 s7 T5.這個軟件是針對快取來優化,可以明顯感受速度的差異在於瀏覽時的捲動及關閉程序的速度
) R( E4 R: P7 k; `2 K, S( |針對很頻繁對硬碟快取得非常有效,前輩們可以去測試例如 word to go ,abiword等文書軟件,或針對瀏覽器的捲動及資料顯現來測試有無差異/ T/ P0 S$ K7 V
6.有些軟件本身啟動上就很慢,例如firefox,測試後差異並不明顯,但資料上呈現還是快些,網路讀取還是要取決於當時網絡狀況
: [& n" i- s3 o9 m# V我本身是使用台灣3.5G,狀況還可以,有感覺變快了,我很難回答大家有沒有對照測試,機器上大家的軟件都安裝的不同,甚至超頻情況有無都不同,僅能在此致歉:opera ,nokia網絡套件開啟時的速度變化來看看差異
1 n7 U* v" f, w  \" R! D3 n$ T4 i( B. u# m) e/ T; V
當然這個優化程序可以利用指令去修改,以下參數討論給大家參考用,讓高手可以進一步去討論與調整; G& F" I2 r4 i6 U6 m* \
here are the settings and what they are changed from (the default on the N900) and to(From Nokia Support :cpitchford)
7 \, f+ p4 j6 gFrom To Setting
1 `; w2 P+ X" j- A4 a100 30 /proc/sys/vm/swappiness
- M/ Y3 l. T+ I4 A* d  S# P. s- l5 0 /proc/sys/vm/page-cluster6 f( w4 @9 c0 K1 S  A- I0 I1 ]
0 1 /proc/sys/vm/laptop_mode
0 E& W" s! k+ [9 c+ \0 1 /proc/sys/vm/oom_kill_allocating_task$ w& O9 p' q* J- g: n2 L
500 0 /proc/sys/vm/dirty_expire_centisecs
: ]% `2 n. f7 H& w* P500 0 /proc/sys/vm/dirty_writeback_centisecs. ?# Z; y3 s3 x  E0 _$ c. C; o
10 60 /proc/sys/vm/dirty_background_ratio8 X1 S- j' b; H: c% Y
40 95 /proc/sys/vm/dirty_ratio
# y7 S* _4 b, p+ H3 t1 0 /proc/sys/net/ipv4/tcp_timestamps1 d+ m3 y  }. F6 Y& E
0 1 /proc/sys/net/ipv4/tcp_no_metrics_save
+ R" e; z0 ^0 `* Q
% i9 ?5 V9 `* J- k7 z2 V8 m% D" \) l* ]  a& ~
0 F: F% G. Z. t; b$ x' g
I believe this value changes how the system swaps. Memory is in use, in swap, free or disk-cache (more or less) if this value is high, it will push in use memory onto swap to keep the cache large.. if it is low, it will sacrifice cache to keep application in use memory available.. I think
% Y0 h( a2 S5 l  A. W4 l3 N/ E* j. l4 c% i7 a
/proc/sys/vm/page-cluster
) `3 t# O9 i" v1 X& L7 X4 k) o% o% W1 b' q3 M3 C
This controls how big a chunk of memory is moved into swap in one go. Changing from 5 to 0 reduces the size by 32! This means very small chunks can now be put into swap memory, which gives greater control over what is swapped out* [* Q( w- S9 B" b/ H

( L/ F. X8 q. {; p  i- Q, U/proc/sys/vm/laptop_mode$ k7 l) V+ D4 E3 N
# x8 S) Z; |2 q5 I+ V" F
Laptop mode is about stopping a linux machine spinning up a laptop hard disk unncessarily. When this value is set to one, when something starts writing to the disk (actually the emmc) any page flushing will happen at the same time.. things get moved to swap when other stuff is writing to disk.. Since writing to disk introduces latency, its better to bunch this stuff up.." T3 B/ X- e. e
, O7 q& e) e  M  q+ P2 A
/proc/sys/vm/oom_kill_allocating_task( D, C- O+ J, l, I

# j9 ~3 a. g/ s4 KSeems a bit drastic.. When a process asks for more memory, if the system is full it would normally look for a process to kill (to free up its resources which can then be re-used). When this is change, the system will simply shoot ANY process that tries to request memory when the system is full..
7 @6 k  Z9 w+ j* v. e6 P" K/ l* p3 @/ `: C! \4 l* z/ C( G
/proc/sys/vm/dirty_expire_centisecs" v9 h% N1 u3 q; h! j( q

1 j) Z6 R0 P1 H; W/ \$ fHow long stuff can sit in the disk cache before it is written to disk.. 0 means NOW!
- Y( N8 k2 Q: q! p4 O+ ]3 H4 l) Z' j  n1 J' E& Z' V
/proc/sys/vm/dirty_writeback_centisecs
& f# c4 Q% A- y2 |8 |. B* h
! g% U" W1 f4 R- k# u/ BHow long stuff can sit in the disk cache before it writes stuff to disk.. kind of meaningless now since /proc/sys/vm/dirty_expire_centisecs is set to zero so nothing is going to sit there anyway
2 E% I0 K4 \. t4 X6 s% @" g3 H% o# `) c& R8 V3 X( B
/proc/sys/vm/dirty_background_ratio
  A' z  B/ d( b0 W/proc/sys/vm/dirty_ratio  A3 e1 o2 v4 ?& r4 u1 \6 W

9 Q4 @; ?, v$ F+ lStuff must be written to disk when 60% of the memory is used by disk write cache. Either after a delay or when the process running tries to writing to disk cache- r; A8 L; k% }& d" R7 X+ @* S

! u5 P8 g. G( q3 r4 a/proc/sys/net/ipv4/tcp_timestamps' H2 Z, u8 G2 D9 z3 r" C3 ?
TCP packets are sent include the time they are sent when this is enabled.. Turning it off allows more data to be sent in each packet (as none is now wasted by the timestamp) This is bad for very fast links..
9 h) q& S: V1 n/ Y6 N- h# H5 Y/ h8 `5 J5 l  J; k1 c
/proc/sys/net/ipv4/tcp_no_metrics_save0 b2 c& ?! H( y# }# m$ \
This stops the kernel remembering information about past TCP connections. As well as gaining free memory by disabling this, it also stops the kernel remembering details when the link was congested (eg you went out of 3G coverage for a moment) that might alter how the system communicates in the future..
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

Archiver|手機版|小黑屋|歡迎光臨 Julybee Club

GMT+8, 26-11-2024 17:57 , Processed in 0.207010 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回復 返回頂部 返回列表