dotnet / infer

Infer.NET is a framework for running Bayesian inference in graphical models
https://dotnet.github.io/infer/
MIT License
1.56k stars 230 forks source link

Micro-optimize StringAutomaton.Product and StringTransducer.ProjectSource #411

Closed lazy closed 2 years ago

lazy commented 2 years ago

In our project these 2 methods are very hot. They are near-optimal algorithmically but implementation wasn't efficient due to use of convenient abstractions and JIT in netframework4.7.2 being not very sophisticated. (dotnet7 optimizes original code a lot better, but due to various reasons we can't migrate to it yet).

List of micro-optimizations in no particular order:

This PR speeds up methods mentioned in PR title by about 30%.