当前位置:网站首页>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
边栏推荐
- DHCP 动态主机设置协议 分析
- Mongodb command summary
- Write it down once Net a new energy system thread surge analysis
- Users, groups, and permissions
- 学习突围2 - 关于高效学习的方法
- JS function 返回多个值
- 高端了8年,雅迪如今怎么样?
- ESP32系列专栏
- How to continue after handling chain interruption / sub chain error removed from scheduling
- Practical example of propeller easydl: automatic scratch recognition of industrial parts
猜你喜欢
【学习笔记】AGC010
数字ic设计——SPI
Isprs2021/ remote sensing image cloud detection: a geographic information driven method and a new large-scale remote sensing cloud / snow detection data set
Cloud detection 2020: self attention generation countermeasure network for cloud detection in high-resolution remote sensing images
1、深拷贝 2、call apply bind 3、for of for in 区别
OSI 七层模型
How far can it go to adopt a cow by selling the concept to the market?
飞桨EasyDL实操范例:工业零件划痕自动识别
About the problem of APP flash back after appium starts the app - (solved)
自定义线程池拒绝策略
随机推荐
[untitled]
Write it down once Net a new energy system thread surge analysis
error LNK2019: 无法解析的外部符号
Esp32 ① compilation environment
Cinnamon Applet 入门
shell 批量文件名(不含扩展名)小写改大写
MongoDB 分片总结
数字ic设计——SPI
PHP - laravel cache
Mongodb command summary
“新红旗杯”桌面应用创意大赛2022
LeetCode_二分搜索_中等_153.寻找旋转排序数组中的最小值
Milkdown 控件图标
Go language learning notes - structure
信号强度(RSSI)知识整理
Simple and easy-to-use code specification
Awk of three swordsmen in text processing
How to reset Google browser? Google Chrome restore default settings?
LIS 最长上升子序列问题(动态规划、贪心+二分)
LED light of single chip microcomputer learning notes