在reddit中,看評論區出現這個軟件,于是打算嘗試一下,應該能對不使用電源時筆記本的省電起到一定的作用。
https://github.com/AdnanHodzic/auto-cpufreq?tab=readme-ov-file#why-do-i-need-auto-cpufreq
作用
One of the problems with Linux today on laptops is that the CPU will run in an unoptimized manner which will negatively impact battery life. For example, the CPU may run using the “performance” governor with turbo boost enabled regardless of whether it’s plugged into a power outlet or not.
These issues can be mitigated by using tools like indicator-cpufreq or cpufreq, but those still require manual action from your side which can be daunting and cumbersome.
Tools like TLP (which I used for numerous years) can help extend battery life, but may also create their own set of problems, such as losing turbo boost.
Given all of the above, I needed a simple tool that would automatically make CPU frequency-related changes and save battery life, but let the Linux kernel do most of the heavy lifting. That’s how auto-cpufreq was born.
Please note: auto-cpufreq aims to replace TLP in terms of functionality, so after you install auto-cpufreq it’s recommended to remove TLP. Using both for the same functionality (i.e., to set CPU frequencies) will lead to unwanted results like overheating. Hence, only use both tools in tandem if you know what you’re doing.
One tool/daemon that does not conflict with auto-cpufreq in any way, and is even recommended to have running alongside, is thermald.
Supported architectures and devices
Only devices with an Intel, AMD, or ARM CPU are supported. This tool was developed to improve performance and battery life on laptops, but running it on desktops/servers (to lower power consumption) should also be possible.
AI提煉
該軟件 auto-cpufreq 的作用主要有以下幾點:
- 自動進行與 CPU 頻率相關的更改,優化 CPU 運行方式,避免其以未優化的方式運行,從而延長電池壽命。 讓 Linux
- 內核承擔大部分繁重工作,在不依賴過多手動操作(如使用 indicator-cpufreq 或 cpufreq 工具那樣)的情況下,實現對
- CPU 頻率的優化調整。 在功能上可替代 TLP,避免因同時使用 TLP 和 auto-cpufreq 設置 CPU頻率而導致如過熱等不良結果。
- 除了適用于筆記本電腦提升性能和延長電池壽命外,也可運行在臺式機或服務器上,達到降低功耗的目的。
大概就是通過調節CPU的頻率達到省電的作用,不過電腦的功耗大頭不僅僅只有CPU,提升有但有限吧
過程解讀
systemctl status power-profiles-daemon
與gnome下的power-profiles-daemon.service產生了沖突,也不奇怪,因為這個就是用來調節cpu的運行狀態的。
長這樣:
下面是警告(也就是說不是報錯),意思是說兩者不能共存,在安裝auto-cpufreq為daemon service時會將power-profiles-daemon禁用,卸載時重新啟用power-profiles-daemon服務。
ying@192 ~/p/auto-cpufreq (master)> sudo auto-cpufreq --monitor----------------------------------- Warning -----------------------------------Detected running GNOME Power Profiles daemon service!This daemon might interfere with auto-cpufreq and will be automatically
disabled when auto-cpufreq daemon is installed and
it will be re-enabled after auto-cpufreq is removed.Only necessary to be manually done on Snap package installs!
Steps to perform this action using auto-cpufreq: power_helper script:
git clone https://github.com/AdnanHodzic/auto-cpufreq.git
python3 -m auto_cpufreq.power_helper --gnome_power_disableReference: https://github.com/AdnanHodzic/auto-cpufreq#configuring-auto-cpufreq
press Enter to continue or Ctrl + c to exit...^C?
回車查看詳情信息
這個命令應該是臨時啟用 auto-cpufreq,如何看情況在安裝為daemon service,重啟配置就失效。
sudo auto-cpufreq --live
ok,給哥們主頻最大頻率砍了一般,稍微動動cpu占用就上去了。和輕薄本沒兩樣了吧!
我嘗試一下,可不可以退出這個監視界面,一直開著也較為礙事。
sudo auto-cpufreq --monitor
監控發現,配置基本沒變。
謹慎起見,再查看
systemctl status power-profiles-daemon
可以看到這個服務還是在跑,不過嘗試更改,會發現主頻最高仍然是2300,所以也算是禁用了。
不過目測續航也并沒有多少提高。
安裝
git clone https://github.com/AdnanHodzic/auto-cpufreq.git
cd auto-cpufreq && sudo ./auto-cpufreq-installer
sudo auto-cpufreq --install
其他
它是有一個GUI程序可以圖形化的管理操作,但是好像我安裝過程中出了些問題,這個程序無法打開,但是命令行仍然可用。
安裝之后
auto-cpufreq --stats
//To disable and remove auto-cpufreq daemon, run:
sudo auto-cpufreq --remove
內存占用不大,大概25M
systemctl status auto-cpufreq
其他
在插入電源后打開virtualbox測試,發現最大頻率會波動,虛擬機也卡卡的感覺,也不知道是不是錯覺。
You can configure separate profiles for the battery and power supply. These profiles will let you pick which governor to use, as well as how and when turbo boost is enabled. The possible values for turbo boost behavior are always, auto, and never. The default behavior is auto, which only activates turbo during high load.
這里有個問題,只有在高負載下會啟用,那也就是說如果環境在高低負載交替的場景,可能會有明顯卡頓。
作者也給出了配置的方法,可以通過配置文件來控制使用電源和電源適配器時不同的睿頻調節方案。
配置文件并沒有默認創建,可能需要手動創建。
在sudo auto-cpufreq --monitor的顯示中可以看到電源適配器的插入狀態,還有電池充電開始和停止的閾值,但是作者明確指出只適配聯想設備,因為我是華碩所有我也就不嘗試配置了,github中還有一些電源管理方案可以供選擇,還有gnome插件的方案,不過需要指出,gnome插件需要在開機后登錄進入桌面才會啟用,也就是說這段時間內,電池會持續充電。
在安裝為daemon后會關閉gnome的性能調節service
ying@192 ~> systemctl status power-profiles-daemon
○ power-profiles-daemon.serviceLoaded: masked (Reason: Unit power-profiles-daemon.service is masked.)Active: inactive (dead)
附一個我的配置文件
sudo vim /etc/auto-cpufreq.conf
在插入電源時一直啟用turbo,在使用電池時auto,電池充電閾值那里還沒開始搞,現在使用的gnome插件,雖然有點缺陷但可以使用,不過作者的reference我沒有刪除,感興趣的可以去摸索一下,另外這個配置文件修改完保存就會生效。
# settings for when connected to a power source
[charger]
governor = performance
energy_performance_preference = performance
turbo = always# settings for when using battery power
[battery]
governor = powersave
energy_performance_preference = power# turbo boost setting (always, auto, or never)
turbo = auto# battery charging threshold
# reference: https://github.com/AdnanHodzic/auto-cpufreq/#battery-charging-thresholds
#enable_thresholds = true
#start_threshold = 20
#stop_threshold = 80
本篇內容有點亂