algebra
algebra copied to clipboard
Explore more advanced config-based compilation
Frankly, I think using features is very limited. Rather, using cfgs which can hold parameters would be preferable. For instance, with regards to optimisation level, rust offers 3 levels, so it's not a binary option.
Using a cfg like memory_use_level = low/medium/high would then become an option. Still, as mentioned elsewhere it is difficult to have a single widespread setting that is optimised across the whole library, sadly. But this way, at the very least an external optimiser can be used. This requires quite a lot of compute. But if you care about the performance a lot, it's relatively cheap to spin up lots of machines to optimise the compilation settings.
I would be very interested to pioneer this machine-learning (bayesian opt) based autotuning in rust. It would be a cargo app.
The idea is that we define a new cfg file optimiser.cfg. We can define new cfgs there which are instrumented by a build file. This build file is generated by the cargo app on running. We also then instrument our benchmarks with #[optimizer_objective], or we have specialised benchmarks written to conform to the optimizer's requirements, for instance a cost function involving the performance of the various benchmarks.
Then we call cargo optimize. What it does is it sequentially compiles the library while performing a search over the config. Simple. Scaling this to be a parallel search across a fleet of homogeneous machines is more challenging, however.