Hi there, I’m working on a new module and have noticed that CPU usage is kinda high. I’d like to make it more efficient but want to where I should focus my efforts so I want to do some profiling on my code.
However, I am not very experienced in profiling and have not been able to find good resources for how to do it for Rack plugins. Does anyone have tips or pointers for how to get starter profiling my module? Is there a preferred tool? I currently build my plugin with the Rack SDK and make install it and just run my downloaded Rack app. Would I be profiling all of Rack? Is there a way to profile my module specifically?
For context, I am developing on an M1 Mac (building for x86).
Oh interesting, I was for sure assuming that developers like you would be profiling their modules. Thanks for the link, I will use that to rethink some of the likely culprits in my code.
Whats your os? I have had good luck with the dtrace profilers built into macos and linux and the wrappers around them in CLion and instruments (instruments is macos only).
If you are windows I have no help for you though!
Also I agree with squinky yu can get pretty far by knocking out blocks and doing timeit on blocks. I would say that, the peek at the assembly, the run the profiler in order is what I usually do
yeah, I run on windows, and sometimes in Linux. I don’t really want to learn how to use a new profiler, so I never have. As in never, ever, not once. I have run other tools on my modules, but never a profiler.
The documents that @LarsBjerregaard pointed you to are for sure good and correct. In general, anyway. In general it’s true you have no idea where the bottleneck is, and it’s never where you might guess.
But a VCV module is not “general”. It’s not a big program like VCV where you need a profiler. You know exactly where the bottleneck is - it’s in your process function! By definition.
If your process function is longer than 100 lines you are doing something wrong. It’s either obvious where the problems is (if you have a lot of experience), or it’s easy to find it. Like I say, if you have no idea just remove half the code. It won’t take very long to get to the very line that’s the problem.