Description
I learnt about TruffleRuby a few days ago and decided to give it a try on a Ruby on Rails API project.
I was interested to see if TruffleRuby could give me a performance boost on an extensive endpoint which:
- Retrieves lots of data from a PostgreSQL database (about 3500 entries)
- Does some computations on all these entries
With MRI, this endpoint takes about 0.8 second to complete split like this:
- 0.5 second for data retrieval from the DB
- 0.3 second for everything else (my computations, JSON serialization of the result, etc.)
With TruffleRuby 20.2.0 in JVM mode, the sole ActiveRecord call takes about 20 seconds to complete. Subsequent requests take at least 6 seconds for the sole ActiveRecord call. TruffleRuby in Native mode performs about the same for this specific task.
The ActiveRecord call mentioned looks like:
MyModel.all.inludes(...).to_a # .to_a to avoid lazy loading
My test environment and dataset are exactly the same between MRI and TruffleRuby.
Did I miss something or is it a known issue that TruffleRuby performs bad in this kind of situation?