Ok, looks like we have a winner… 🏆 #RustLang, run directly from #Ruby as a native module, using this tool: https://github.com/matsadler/magnus. Should give me a 2-4x total speedup (regex matching is 15x faster, but some of that time is reading data from SQLite & ActiveRecord). JS via mini_racer works ok too.
The #RustLang module code is actually super short, just two short functions, less than a page total. I'll try to wrap it into a gem at some point, because it's totally generic and could be used in other projects to speed up regex matching 🦀 The configs to build it took me a while to figure out though since I've never made a native gem before.
(One small caveat though is that it doesn't support regexps with "lookbehind" sections, I had to work around that a bit on the #Ruby side)
Add comment