What do @inbounds and @inline do?

question
#1

These two macros – @inbounds and @inline – get thrown around a lot when performance comes up.

  • What exactly do they do?
  • When should you use them?
  • When should you not use them?

Also, are there other useful performance macros that people should be aware of?

// asking b/c I’m trying to sprinkle some speedups throughout a codebase


edit: this is the explain-like-im-five version of:

https://docs.julialang.org/en/v1/manual/performance-tips/

0 Likes

#2

Just making sure you saw the section on performance annotations? I was going to write something, but I don’t think I can explain it any better than this:

https://docs.julialang.org/en/latest/manual/performance-tips/#man-performance-annotations-1

There’s also this similar topic; a bit old, but still relevant I think:

6 Likes

#3

The performance documentation is quite extensive and written to be useful for normal (non-expert) julia users. It would be easier to help you if you pointed out specifically what parts you had troubles understanding.

3 Likes