Difference between revisions of "Optimizing BoofCV"

From BoofCV
Jump to navigationJump to search
m
m
Line 7: Line 7:
== Speed: Native Code ==
== Speed: Native Code ==


While it is possible to speed up BoofCV by replacing parts of it with native code, it's often not worth it and certainly not the lowest hanging fruit. Typically, low level operations, such as image convolution, benefit the most and if you write hand optimized SIMD code you can probably beat what's in BoofCV by 2x. For higher level operations which aren't SIMD friendly there is unlikely to any improvement in fact the code could very well be slower until you spend a lot of time learning how to optimize the data structures or deal with cache issues effectively.


Internally, some operations in BoofCV allow you to plug in 3rd party alternatives. The best place to learn how to do that is with BoofCPP. That was an attempt to plug in C++ code and get things to run faster. Primary reason it hasn't been updated is that the real world performance boost was about ~10% and not worth the additional development effort.


https://github.com/lessthanoptimal/BoofCPP


== Jar Size ==
== Jar Size ==
Occasionally comments are made about BoofCV requiring a "massive" number of disk space for simple tasks. For the developers of BoofCV that's a bit of a surprise since it's core components have very few external dependencies.

Revision as of 08:29, 6 October 2021

This page discusses how you can optimize BoofCV for your specific application. This includes tips on speed, reducing the size of a jar, and avoiding common mistakes.

Speed: Warming Up Java

One common mistake that people make when dealing with Java in general is not allowing it time to warm up. Basically all modern virtual machine language (like Java) optimize at runtime to make things run faster. Often people who are used to C++ expect the code to be highly optimized and provide a constant runtime. In most real world applications this is a non issue as you aren't constantly starting and stopping the JVM. So if you want to get the most performance keep the JVM running and ignore the first few times it processes an image as it will be 2x or 3x slower.

Speed: Native Code

While it is possible to speed up BoofCV by replacing parts of it with native code, it's often not worth it and certainly not the lowest hanging fruit. Typically, low level operations, such as image convolution, benefit the most and if you write hand optimized SIMD code you can probably beat what's in BoofCV by 2x. For higher level operations which aren't SIMD friendly there is unlikely to any improvement in fact the code could very well be slower until you spend a lot of time learning how to optimize the data structures or deal with cache issues effectively.

Internally, some operations in BoofCV allow you to plug in 3rd party alternatives. The best place to learn how to do that is with BoofCPP. That was an attempt to plug in C++ code and get things to run faster. Primary reason it hasn't been updated is that the real world performance boost was about ~10% and not worth the additional development effort.

https://github.com/lessthanoptimal/BoofCPP

Jar Size

Occasionally comments are made about BoofCV requiring a "massive" number of disk space for simple tasks. For the developers of BoofCV that's a bit of a surprise since it's core components have very few external dependencies.