当前位置:网站首页>Ways to improve the performance of raspberry pie
Ways to improve the performance of raspberry pie
2022-07-07 13:27:00 【Jia ming】
List of articles
- Preface
- Hardware and system configuration
- Programming aspect
Preface
Raspberry pie installation raspi-config Tools (ubuntu And other unofficial raspberry pie systems )
Installation dependency :
sudo apt install whiptail parted lua5.1 alsa-utils psmisc
from Raspberrypi Download the latest deb Installation package :
wget http://archive.raspberrypi.org/debian/pool/main/r/raspi-config/raspi-config_20200707_all.deb
install Deb Installation package :
sudo dpkg -i raspi-config_20200707_all.deb
function raspi-config:
sudo raspi-config
Hardware and system configuration
1. Reduce GPU Memory usage
How to view GPU Memory ?
adopt cat /proc/meminfo
Judge the memory capacity .
Raspberry pie
The memory on the raspberry pie is allocated to CPU use , Give some to GPU With ,GPU The default of occupation is 76M(1GB above ),rpi4 On ,GPU Of 3D The component has its own memory management unit , Use Linux Dynamically allocated memory in .
Method 1 :
modify config.txt:gpu_mem=16
,16MB Is the minimum .
Before the change :
After modification :
Method 2 :
function raspi-config
, Select the allocation size .
2. Ban L2 cache
disable_l2cache=1
prohibit CPU Yes GPU Of L2 cache The interview of .BCM2835 The default value is 0. stay BCM2836、BCM2837 and BCM2711 On , The default value is 1.
3. Increase the operating frequency
Method 1 :
The two generation raspi-config Overclocking setting options reference :
Modify the configuration file .config:
arm_freq/arm_freq_min
: Set up CPU frequency , With MHZ In units of .1500/600,1800 if arm_boost=1( With pi4 give an example , The same below ).
arm_boost
: take arm_freq
Increase to the highest frequency supported by hardware ,set 1.
gpu_freq/gpu_freq_min
: Provide more detailed setting options * /250
*core_freq/core_freq_min
: Set up GPU frequency ,MHz, It will affect CPU Performance of , Because they share L2 cache And memory bus ( Each version of raspberry pie is shared ?).500/200
*h264_freq/h264_freq_min
: hardware video block,MHz, Cover gpu_freq.500/250
*isp_freq/isp_freq_min
: image sensor pipeline block,MHz, Cover gpu_freq.500/250
*v3d_freq/v3d_freq_min
: 3D block,MHz, Cover gpu_freq.500/250
*hevc_freq/hevc_freq_min
: High Efficiency Video Codec block,MHz, Cover gpu_freq,rpi4 proper .500
sdram_freq
: SDRAM frequency ,rpi4 Memory frequency overclocking is not supported ,MHz.3200(pi4)
over_voltage/over_voltage_min
: CPU/GPU Upper voltage limit , Range [-16,8]=[0.95,1.55], step 0.025V,force_turbo=1
when , The allowable value is greater than 6( Greater than 1.5V),over_voltage
Also set .0
over_voltage_sdram
: Provide more detailed setting options * 0
*over_voltage_sdram_c
: SDRAM Controller voltage ,[-16,8]=[0.8V,1.4V], step 0.025V.0
*over_voltage_sdram_i
: SDRAM I/O voltage , ditto .0
*over_voltage_sdram_p
: SDRAM phy voltage , ditto .0
The firmware uses adaptive voltage scaling (AVS) To determine by over_voltage and over_voltage_min The best in the defined range CPU/GPU voltage .
force_turbo
: mandatory turbo Pattern ( Ultimate overclocking mode ) Even if ARM Nuclear idle , Will be set over_voltage_*
value .
initial_turbo
: From start to turbo Pattern , Set a buffer time . Maximum 60s.0 Secs
temp_limit
: Overheating protection . When SoC At this point ( In degrees Celsius ) when , This will set the clock and voltage to the default values .85
Check the running frequency :
Conclusion :
- Raspberry pie 4B I won't support it SDRAM Overclock , Default 3200MHz
- Comment fields
arm_boost=1
. force_turbo=1
Force the maximum frequency , Set up CPU、GPU、 Memory frequency 、 as well asover_voltage_*
Value .temp_limit=85
Set overheat protection , Set the frequency and voltage to default values , Nominal temperature -40~85.
Before the change :
After modification :
Method 2 :
https://blog.csdn.net/weixin_39589455/article/details/123073227?utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2aggregatepagefirst_rank_ecpm_v1~rank_v31_ecpm-2-123073227-null-null.pc_agg_new_rank&utm_term=%E6%A0%91%E8%8E%93%E6%B4%BEcpu%E9%A2%91%E7%8E%87&spm=1000.2123.3001.4430
Installation tools :sudo apt-get install cpufrequtils
Check the current operating frequency :sudo cpufreq-info -w -m
Method 3 :
raspi-config
Medium overclock Options , Only for pi1 and pi2.
4. cpu Isolation
modify cmdline.txt, Add kernel startup parameters isolcpus=3
Isolation section 4 individual CPU.
Write a test program , A total of 4 A process , After load balancing, it is spread to each CPU.
[email protected]:~/high_performance_rpi$ cat multiprocess.c
#include <stdlib.h>
void main()
{
fork();
fork();
while(1);
}
After operation , see htop
, Indeed, the task was shared equally :
modify cmdline.txt, Isolation CPU4:
Run the program , see htop
, Indeed, it was quarantined , User space processes cannot run on it .
adopt taskset
command , Bind tasks to isolated CPU 3 Up operation :
Will be the task of CPU Affinity from [0-2] It is amended as follows 3,htop View results :
Conclusion :isolcpu
User processes can be isolated .
5. Interrupt isolation
5.1 General peripheral interrupt
https://www.cnblogs.com/linhaostudy/p/14498098.html
Check the affinity of peripheral interrupts , The value is 7(0b0111), except 4 Number CPU blocked .
Conclusion : For ordinary peripherals ,isolcpu Parameters can be masked , about timer tick、IPI no way .
5.2 timer tick
Conventional tick The mechanism will still produce periodic interrupts when the system enters the idle state , This frequent interruption forces CPU Unable to enter deeper sleep . If you let go of this restriction , Stop when the system is idle tick, Resume when there is work tick, Achieve complete freedom , Generate as needed tick The mechanism of , You can make CPU Get more sleep opportunities and deeper sleep , So as to further save energy .dynamic tick Appearance , Is to completely replace the cyclical tick Mechanism .
————————————————
Copyright notice : This paper is about CSDN Blogger 「lee_xin_gml」 The original article of , follow CC 4.0 BY-SA Copyright agreement , For reprint, please attach the original source link and this statement .
Link to the original text :https://blog.csdn.net/lee_xin_gml/article/details/7866206
In general ,Linux Configured with IDLE State of NO_HZ tickless, namely ,CPU4 When there is no task on , The timer The value will not increase , But when it comes to CPU4 When there is a task on ,CPU4 Of timer The number will increase ,timer tick This thread will be frequently interrupted , Cause a lot of context switching .
When you want to run a task , Can also not increase timer tick value , Need to recompile kernel , set an option Full dynticks system(tickless)
:
Conclusion : about IDLE State of CPU, Generally, it will not be affected by timer tick Disturb , If you want to be in CPU A task running on will not be disturbed , You need to set kernel options , Also specify kernel parameters ,nohz_full=3
, bring CPU3 Support NO_HZ_FULL.
5.3 Set interrupt affinity irqaffinity
Kernel startup parameters :irqaffinity=0,1,2
, Default by core 0 nucleus 1 nucleus 2 Handle Linux interrupt , Ensure real-time verification 3 Not subject to linux Interrupt request from non real time device .
5.4 Ban irqbalance
linux irqbalance Used to optimize interrupt allocation , It automatically collects system data to analyze usage patterns , Hardware interrupts are distributed to each according to the system load CPU Core processing .
Kernel startup parameters :noirqbalance
And run :
sudo systemctl stop irqbalance.service
sudo systemctl disable irqbalance.service
5.5 close nmi_watchdog
NMI Watchdog Contained in the soft lockup detector and hard lockup detector, The raspberry pie kernel does not enable the watchdog function (Pi Zero、Pi 1), When the kernel goes down, it goes into the panic state , Will not restart the system . If you need to configure the watchdog function , Reference resources https://blog.csdn.net/ling_lang/article/details/116268623.
Kernel startup parameters :nmi_watchdog=0
And run :
echo '0' > /proc/sys/kernel/nmi_watchdog
6. Ban soft-lockup detector , Deadlock related
Kernel configuration :
SOFTLOCKUP_DETECTOR=n
BOOTPARAM_SOFTLOCKUP_PANIC=n
7. offload RCU(Read-Copy Update) callback
about HPC And real-time workloads are useful , To be RCU Protected shared data structures , Readers do not need locks to access , The writer needs to copy a copy when accessing , Modify... On the copy , Then notify the CPU Exit and point to the new modified data (call-back), Don't use call-back, Use kernel threads instead , Reduce CPU shake .
Kernel configuration :CONFIG_RCU_NOCB_CPU = y
8. Other kernel configuration options
CONFIG_MIGRATION=n, It is not allowed to move the location of the corresponding physical memory page while keeping the virtual memory page address unchanged .
CONFIG_PREEMPT=y, Open preemption
CONFIG_CPU_FREQ =n, Prohibit the processor from dynamically adjusting the frequency .
CONFIG_CPU_IDLE =n
Programming aspect
- Use static compilation language
- Write high-performance code
- Try to make the branches regular , Use likely()/unlikely() Or write branchless code
- utilize cache Locality principle , Prevent fake sharing
- Reasonably assign task priorities
- Try to use static libraries
- Avoid dynamic memory allocation in real-time tasks
- Driver interrupt handling as short as possible, etc
边栏推荐
猜你喜欢
DETR介绍
How to make join run faster?
PACP学习笔记一:使用 PCAP 编程
日本政企员工喝醉丢失46万信息U盘,公开道歉又透露密码规则
[learning notes] agc010
centso7 openssl 报错Verify return code: 20 (unable to get local issuer certificate)
提升树莓派性能的方法
About how appium closes apps (resolved)
线程池拒绝策略最佳实践
Fast development board pinctrl and GPIO subsystem experiment for itop-imx6ull - modify the device tree file
随机推荐
My "troublesome" subordinates after 00: not bad for money, against leaders, and resist overtime
Final review notes of single chip microcomputer principle
Differences between MySQL storage engine MyISAM and InnoDB
学习突围2 - 关于高效学习的方法
The difference between cache and buffer
JS判断一个对象是否为空
Vscode编辑器ESP32头文件波浪线不跳转彻底解决
MongoDB复制(副本集)总结
High end for 8 years, how is Yadi now?
DETR介绍
Signal strength (RSSI) knowledge sorting
Go language learning notes - structure
Summary of import, export, backup and recovery of mongodb
LeetCode_ Binary search_ Medium_ 153. Find the minimum value in the rotation sort array
服务器到服务器 (S2S) 事件 (Adjust)
[Presto profile series] timeline use
Unity build error: the name "editorutility" does not exist in the current context
Cinnamon 任务栏网速
Vscade editor esp32 header file wavy line does not jump completely solved
迅为iTOP-IMX6ULL开发板Pinctrl和GPIO子系统实验-修改设备树文件