I put together this presentation on how to design software that scales on multicores.
It uses examples in Java, yet the basic learning is same in all languages. (In fact, I learned it in C++).
(Original video on YouTube is: https://www.youtube.com/watch?v=op2Fh-iiKoA ).
Here's the summaries:
Basic multicore scalability (in Java)
- Parallelize with threads and thread pools
- Use enough threads (but not too many)
- Thread pools assure execution on multiple cores
- Keep same objects on same cores (as much as possible)
- Avoid having multiple tasks working on the same data
- Avoid locks (ex. attribute synchronized)
- Avoid cache line contention
Patterns to manage lock conflicts
- Structured parallelism
- Non-blocking data structures
- Immutable or purely functional data structures
Patterns to manage core affinity
- Tasks last as long as program
- Tasks last as long as service they implement
- Tasks
are
dynamically extended