How A KDE Developer Used C++17 & Boost.Python For About A 8,000x Speed-Up
Open-source developer Antonio Larrosa who contributes to KDE and openSUSE has been developing a command-line music manager called Bard. He's written an interesting post about how he sped up some of his operations by around eight-thousand times faster.
In particular, Antonio was focused on speeding up the process of finding song/music duplicates in the user's local music collection. What started out as Python code was morphed into optimized C++ code. Little surprise, the C++ code once tuned was immensely faster than Python -- but the blog post is interesting for those curious about the impact of the various steps he took for tuning this implementation.
Rather than rewriting the entire program in C++, he used the Boost.Python library that allows seamless interoperability between C++ and Python code. From there he began writing C++ code where relevant. In particular, he focused on C++17 and making use of threading. Further increasing the performance was tuning of the C++ compiler flags and also switching from GCC 7.3 to GCC 8.1.
Long story short, "This commit gave the last increase of speed, to 7998x, 36680 songs/second and would fully process a music collection of 1000 songs in just 13 seconds." Those curious about the steps he pursued for this speed-up in transitioning the performance sensitive code from Python to C++ can be found via this blog post. Those interested in learning more about his Bard music manager can visit the project site.
In particular, Antonio was focused on speeding up the process of finding song/music duplicates in the user's local music collection. What started out as Python code was morphed into optimized C++ code. Little surprise, the C++ code once tuned was immensely faster than Python -- but the blog post is interesting for those curious about the impact of the various steps he took for tuning this implementation.
Rather than rewriting the entire program in C++, he used the Boost.Python library that allows seamless interoperability between C++ and Python code. From there he began writing C++ code where relevant. In particular, he focused on C++17 and making use of threading. Further increasing the performance was tuning of the C++ compiler flags and also switching from GCC 7.3 to GCC 8.1.
Long story short, "This commit gave the last increase of speed, to 7998x, 36680 songs/second and would fully process a music collection of 1000 songs in just 13 seconds." Those curious about the steps he pursued for this speed-up in transitioning the performance sensitive code from Python to C++ can be found via this blog post. Those interested in learning more about his Bard music manager can visit the project site.
59 Comments