~40% boost in text diff flow just by facilitating compiler optimization

189 points beingAnubhab 41 comments

Sharing yet another optimization success story that surprised me.. Inspired by u/shnatsel's blogs on bound checks I experimented with the `Diff` flow in my implementation of Myers' diff algorithm (diff-match-patch-rs)..

While I couldn't get auto vectorization to work, the time to diff has nearly halved making it almost the fastest implementation out there.

Here's the writeup documenting the experiment, the code and the crate.

Would love to hear your thoughts, feedback, critique ... Happy new year all!