Closed jacobusmmsmit closed 4 months ago
My take on teaching performance is basically the same as yours. We need to rephrase everything in terms of types and allocations. See https://gdalle.github.io/IntroJulia/performance.html for my latest tutorial on this.
I think that requires a very brief summary at the start on the compilation model and the memory management. Then I would like to see our page more focused on the tooling than the actual rules, but maybe a summary with links such as the one I wrote could make sense
I didn't know that you'd written that, nice. I like your idea from the 2nd paragraph. Give people the knowledge to understand what's going on, the tools to diagnose and solve problems, and link to some specific problems they will probably encounter.
Closed by #106
When I was first starting Julia, coming from Matlab and Python, I looked at the performance tips page and thought "how the hell am I supposed to remember all of those rules?". We should educate readers on the underlying principles that guide these specific examples.
"Principles" currently the first section in the "optimising your code" page and I believe it should be this way. There are two ideas that capture the essence of what the performance tips page says in specifics: type stability and allocations. Fast Julia code is type stable and minimises allocations. Good Julia code is also modular, follows a style guide, and potentially uses libraries like Agents.jl instead of writing everything from scratch to make code easier to share, but we're just talking about speed here.
I don't think we can overstate how fundamental type stability and minimising allocations is to readers, especially those coming from Python, which doesn't have either of these as concepts, and to a lesser extent MATLAB, which doesn't use types like Julia does. Knowing about these concepts helps you understand the performance of Julia code at a fundamental level, and the more you know the more you understand it.
Why write functions? Because of the "function barrier" which helps the Julia compiler specialise on types. Why avoid globals? Because we're terrified of boxes, heaps, and instability Why avoid containers with abstract type parameters? Etc.
How do we talk about it?
Do we talk about the compilation model of specialisation? Do we explain what the stack and heap are? How much do we talk about concrete/abstract types? What examples can we give, do we give any, and what of?
Sorry about the malformedness of this issue, my eyes hurt from staring at my screen and I want to get this out of my head.