Memory latency for application software developers
Introduction
About memory latency
How latency impacts performance - part 1
How latency impacts performance - part 2
Cache alignment
Cache prefetching
Next Steps
Memory latency for application software developers
Who is this for?
This is an introductory topic for Arm developers who want to learn about memory latency and cache usage in application programming.
What will you learn?
Upon completion of this Learning Path, you will be able to:
- Explain the importance of memory latency and how to reduce its impact
- Identify how cache alignment impacts performance
- Use cache prefetching to improve performance
Prerequisites
Before starting, you will need the following:
- An Arm computer running Linux with recent versions of Clang or GCC installed.
Summary
This summary was drafted with an approved AI-assisted workflow and reviewed by Arm contributors before publication. Human technical review remains part of the process so the final page reflects engineering rigor, accuracy, and Arm editorial standards.
You’ll explore memory latency with a small C workload on Arm Linux. First, you’ll modify the application in stages: add an allocator for locality, adjust structure layout and cache alignment, and add prefetching to bring data closer to the CPU. Then, you’ll build and run each version. You’ll compare relative runtime trends, choose an effective alignment, and tune the prefetch distance to overlap memory access with computation.
Frequently asked questions
These FAQs were drafted with an approved AI-assisted workflow and reviewed by Arm contributors before publication. Human technical review remains part of the process so the final page reflects engineering rigor, accuracy, and Arm editorial standards.
Differences are expected because processor and system details vary. Confirm that you built and ran the intended source file for each version, then compare relative changes rather than exact numbers.
Verify that the new allocator code is present and that you build
memory-latency2.c. Run the program and confirm that it completes without the allocator error message from the source.Apply the changes shown in the steps, then test the provided alternatives and compare runtime behavior. Keep the version that performs better on your Arm system.
Prefetch a few iterations ahead. Prefetching only the next iteration is often insufficient with typical RAM latency of about 100 ns. Adjust the distance empirically and keep the setting that improves runtime trends.
Build each variant, run it under the same conditions, and compare runtimes or other observable behavior. A consistent improvement across multiple runs indicates that the change benefits your system.