We have noticed last week that boost serialization is adding a considerable size footprint on the binary. Therefore, I have replaced boost serialization by cereal. Cereal has several advantages over boost serialization such as being a header library with no requirement for linking. However, The major advantage is the API compatibility with boost serialization, thus making the replacement easier and less time consuming.
I have also replaced boost program option with CLI11 for the same propose of boost serialization. CLI11 have similar but not compatible API with boost serialization. It requires more effort to detect the parsing difference.
The replacement of boost program options and serialization by cereal and CLI allowed us to gain exactly 1.3 MB in binary size. Therefore reducing the size of mlpack_knn from 4.76 MB into 3.4 MB
As usual, to follow live update on the project, you can see my pull request here
There are Several points I have achieved last week:
- Finish entirely the transition from boost program option to CLI11
- A global transition from boost serialization to cereal, raw pointer are not transitioned yet.
This is an important point in reducing the size of the binary, while the final objective is to have mlpack_knn under 1 MB, there still a lot of work to do. During the next weeks, I will finish the transition for cereal, continue in looking for size reducing techniques, and writing a lit version of mlpack_knn that is intended to run on low resource devices.