julia
julia copied to clipboard
[v3] Implement new Concept Exercise: performance
This issue describes how to implement the performance concept exercise for the Julia track.
Goal
The goal of this exercise is to teach the student how to avoid common performance gotchas by refactoring slow code.
Motivation
It is very common that people try out Julia, convert Python or Matlab code to it, and then wonder why they aren't seeing the promised performance benefits. Most of these issues are due to a handful of common mistakes. By teaching about these, this frustrating experience can be avoided.
Things to teach
- Avoiding global variables
- Avoiding containers with abstract type parameters
- Avoiding type-unstable code
- How to identify performance issues
- Why the above should be avoided
Things not to teach
- Microoptimisations such as using
@inbounds,muladdetc.
Concepts
performanceperformance-analysisprofilingcode-inspectiontype-stabilityscopesabstract-types
Prerequisites
This exercise likely fits best towards the end of the track, so you can assume all concepts are known. Please list them explicitely after implementing the exercise.
Additional notes
The testsuite should ensure that the refactored solution still works. However, automatically testing if all performance issues have been found is likely impossible. The student should instead be provided with reference values for how much of a speed up can be reached, e.g. the original solution takes 1000x longer than the improved solution. The after.md file should provide a list of all issues that could be found as well as an example solution, so that the student can check themselves if they found everything.
Resources to refer to
- Julia Manual Performance Tips
- Julia slower than Matlab & Python? No
- Searching the Julia Discourse for terms like
slow,slower than Pythonetc.
Hints
- List tools that the student can use to identify performance problems, e.g. Profilers, Traceur.jl,
@code_warntype
Implementing
Help
If you have any questions while implementing the exercise, please post the questions as comments in this issue.