I'm looking at PostGIS geometry GiST index build times and try to optimize withing the current GiST framework. The function that shows a lot on my flame graphs is penalty.
I spent weekend rewriting PostGIS penalty to be as fast as possible.
However I cannot get any meaningfully faster build time. Even when I strip it to "just return edge extension" index build time is the same.
Is there a way to inline the penalty into above "choose subtree" loop somehow? That would also let us stop bit-fiddling floats to simulate a more complex choosing scheme.