Rewriting from Ruby to Go, some benchmarks for calculating long streaks showed going from ~5 sec to ~0.04 sec [2].
Conjure's habits use the iCalendar Recurrence Rule format (RRULE [3]) for their frequency, along with one or two other considerations (like Habit Completion Types and streak effects), which makes evaluating streaks more expensive (as you have to work backwards through habit completions one by one based on the next occurrence).
Data is still fetched from Postgres in Rails and passed to the compiled Go library and Ruby/Rails handles the results (persisting, notifying over web sockets, etc)[4]. I modified Conjure's Heroku buildpack to install Go and build on deploy.
No doubt there is further optimizations that can be made, but this approach has allowed me to sprinkle Go into a Rails app and progressively optimize certain things when needed.
[1] https://conjure.so/ [2] https://twitter.com/Whelton/status/1370482793558458370 [3] https://icalendar.org/iCalendar-RFC-5545/3-8-5-3-recurrence-... [4] https://jondot.medium.com/ruby-and-go-sitting-in-a-tree-38c1...