Embedded Linux memory and Performance Optimization

Source: Internet
Author: User

I have been optimizing the memory and performance of the embedded Linux system. I tried to systematize and summarize my knowledge and experience over the past year. Something is being updated.
1. Order 6
2. Memory 7
2.1. Currently available system memory 8
2.2. process memory usage 9
2.2.1. Virtual Memory and physical memory 10
2.2.2./proc/{pid} 11
2.2.3. memory recovery 17
2.3. process 19
2.3.1. Heap 20
2.3.1.1. Small block memory allocation 23
2.3.1.2. Large Memory Allocation 26
2.3.1.3. Memory release 27
2.3.1.4. Memory holes 29
2.3.1.5. Heap Memory Manager parameter Summary 32
2.3.1.6. Memory tracking 32
2.3.1.7. heap memory optimization 34
2.3.2. Stack 34
2.3.2.1 apply for memory 35 on the stack
2.3.2.2. Stack expansion 37
2.3.2.3. Stack release 38
2.3.2.4. stack memory optimization 39
2.3.3. environment variables and parameters 39
2.3.3.1. Storage of environment variables 40
2.3.3.2. added the environment variable 41.
2.3.3.3. Modify the environment variable 43
2.3.3.4. Release environment variable 44
2.3.3.5. Optimized environment variable memory 45
2.3.4. ELF File 45
2.3.4.1. Common Tools 46
2.3.4.2. ELF File 48
2.3.4.3. Program slimming 57
2.3.4.4. program running 60
2.3.5. Data Segment 61
2.3.5.1. Differences between. BSS and. Data 61
2.3.5.2. Memory region where the variable is located 65
2.3.5.3. Data segment optimization 70
2.3.6. Code segment 74
2.3.7. Use thumb command 75
2.3.7.1. Thumb command compilation 76
2.3.7.2. Arm program and Thumb program use 77 together
2.4. Dynamic library 80
2.4.1. Data Segment 81
2.4.1.1. BSS 81 in the Shared Library
2.4.1.2. Impact of the shared library data segment on the process data segment 84
2.4.2. Code segment 87
2.4.2.1. Symbolic parsing 87
2.4.2.2. Share code segments 90
2.4.2.3. Influence of export function on code segment 90
2.4.2.4. Delete unnecessary export symbols 91
2.4.3. Dynamic library optimization 91
2.4.3.1. reduce data in BSS section 91
2.4.3.2. Useless dynamic library 91
2.4.3.3. Merge dynamic databases 92
2.4.3.4. Only one dynamic database dependent 93
2.4.3.5. Use dlopen to control the lifecycle of a dynamic library 93
2.5. Thread 96
2.5.1. Set process stack space 99
2.5.2. Set the thread stack space to 100
2.5.3. Reduce the number of threads by 101
2.6. Shared Memory 101
2.7. Memory debugging 103
2.7.1. mtrace 103
2.7.2. malloc and free hook function 104
2.7.3. Stack rollback 126
2.7.4. Convert to zero method 129
2.7.5. dmalloc 130
2.7.6. valgrind 132
2.8. Embedded System 139
2.8.1. tmpfs partition 140
2.8.2. cache and buffer 140
2.8.3. Memory switching and recovery 142
2.8.4. Reduce the number of daemon by 144
2.8.5./proc/sys/Vm/optimization 145
2.8.6. system memory analysis 147
3. Speed: 147
3.1. performance rating 147
3.2. Performance Optimization Method 148
3.3. Performance Evaluation 149
3.3.1. Proc directory 150
3.3.1.1. System related 150
3.3.1.2. process-related 151
3.3.2. Related tools 153
3.3.2.1. Top 1 153
3.3.2.2. lmbench 153
3.3.2.3. vmstat 155
3.4. Basic principles of optimization 159
3.5. shell script optimization 160
3.5.1. builts-in and applets 160
3.5.2 bash script 161
3.5.3 how to optimize the busybox bash script 161
3.5.4. Bash script optimization 161
3.6. Process startup speed: 161
3.6.1. view the dynamic library loading process 162
3.6.2. Reduce the number of dynamic databases by 163
3.6.3. Shared library search path 163
3.6.4. Dynamic library hierarchy 166
3.6.5. Dynamic library initialization 166
3.6.5.1. Dynamic library construction and destructor 167
3.6.5.2. initialize global variables 167
3.6.6. prelink 169
3.6.6.1. prelink will increase memory usage by 172
3.6.7. Increase the process startup speed by 178
3.6.7.1. Change the process to thread 178.
3.6.7.2. preload process 179
3.7. Optimization ideas 180
3.8. Search for performance bottlenecks 181
3.8.1. GPROF 181
3.8.1.1. Basic usage: 182
3.8.1.2. GPROF and dynamic library 184
3.8.1.3. GPROF and multithreading 186
3.8.2. oprofile 186
3.8.2.1. oprofile example 186
3.8.2.2 multiple files 190
3.8.2.3. oprofile and dynamic library 193
3.8.2.4. oprofile and multithreading 198
3.8.2.5. oprofile 201 in an embedded environment
3.9. optimization level 203
3.10. algorithm optimization 204
3.10.1. lookup 205
3.10.2. Use asynchronous communication instead of multithreading 207
3.11. GCC compilation optimization 213
3.11.1. Unrelated system optimization 214
3.11.2. Internal and external connections 218
3.12. program optimization 225
3.12.1. Data Type 225
3.12.2. Slow operation 227
3.12.3. If and switch performance comparison 227
3.12.4. Loop 231
3.12.5. Functions 235
3.12.6. array 238
3.12.7. Floating Point 238
3.12.7.1. soft and hard floating point 240
3.12.8. struct 242
3.12.9. Division 243
3.12.10. inline function 248
3.12.11. c 249
3.12.11.1. initialize 249 when declaring an object
3.12.11.2. constructor and constructor 249
3.12.11.3. List of constructor initialization 250
3.12.11.4. Parameters and return values: 251
3.12.12. Use MMAP to optimize large file operations 252
3.12.13. Arm architecture related 254
3.12.13.1. Arm instruction introduction 255
3.12.13.2. Arm register 257
3.12.14. Memory 257
3.12.14.1. Eliminate data relevance 261
3.12.14.2. Send multiple queries to the memory controller at the same time 262
3.12.14.3. The request reads data in an incremental manner of not less than 32 bytes 262
3.12.14.4. 262 recommended
3.12.14.5. Eliminate data relevance 263
3.12.15. cached 263
3.13. Hard acceleration 263
3.13.1. SIMD accelerated 263
3.14. Overall Optimization 264
3.14.1. Relationship between process execution speed and idle memory 264
3.14.2. Adjust process priority by 265
3.14.3. Difference Between shutdown and reboot 267
3.14.4. the start time of the device is 268.
3.14.5. The number of Damon is 269.
3.14.6. File System 270
3.14.7. Use lmbench To Check System Bottleneck 273
3.14.8. System standby time: 275
4. Appendixes 288
4.1. Differences between GCC and G 288
4.2. Code segment and data segment optimization 290
4.3. Advanced SIMD data-processing instructions 300
4.3.1. Advanced SIMD integer ALU instructions 304
4.3.2. Advanced SIMD floating-point instructions 307
4.3.3. armv6 SIMD intrinsics 309
4.3.4. note 310
I hope this document will be helpful to you.

Screen. Width * 0.7)
{This. resized = true; this. width = screen. Width * 0.7; this. Alt = 'click here
To open new window/nctrl mouse wheel to zoom in/out ';}"
Onmouseover = "If (this. width> screen. Width * 0.7) {This. resized = true;
This. width = screen. Width * 0.7; this. style. cursor = 'hand'; this. Alt = 'click'
Here to open new window/nctrl mouse wheel to zoom in/out ';}"
Onclick = "If (! This. resized) {return true;} else
{Window. Open ('HTTP: // fileicon/developer.gif ');} "onmousewheel =" Return
Imgzoom (this); "alt =" "/>

File: detailed solution for linux functionality
Size: 2056kb
Download:
Download

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.