Roadmap for a faster time-to-first-plot?

  1. If you can, make your code infer. That makes it compile a lot faster.
  2. If it doesn’t infer, don’t put abstract types over things. Handling calculations with “how abstract it should be” is one of the slowest things. Just make inference call it Any.
  3. If you can, use things in the system image. Dict{Symbol,MyType{T}} where T will require compiling all of the little parts, while Dict{Any,Any} is used in Julia so it won’t.
  4. Avoid dictionaries if you can. Dictionaries are the devil’s type.
  5. Try to avoid putting Tuple in a bunch of types. Accidentally putting ::Tuple into a type adds an abstract type into a struct, which breaks (2), but then every size tuple will need to specialize a ton. If you don’t need type covariance… make it a Vector{T}.

That’s what the current state is. I’ll keep talking with the compiler people to see if there’s anything that could be helpful to make it less crucial for users to “follow the rules”. I think making type inference give up easier is probably the real solution here. @nospecialize doesn’t seem to do enough: I want a @compiler_please_give_up_or_the_entire_internet_will_hate_me macro.

17 Likes