Rails 8, weird bad performance on my 2 macbooks

Hi all,

Well, 2 weeks ago, I was working on a brand new Rails application with Rails 8 (I love it). At first, I didn’t pay attention at the very poor performance of my app on my Macbook Pro 2017 laptop because on production, numbers were fine. But I realized that 500ms to render a page with a couple of simple SQL requests was way too long, even on my old laptop.

So I ran some tests and I discovered strange things when hitting the “/health” endpoint. Here what I found:

Macbook PRO 2017 (Intel).

  • Ruby 3.4.1 (YJIT) / Rails 8.0.1 / My app (with a bunch of gems) :thinking:

     Completed 200 OK in 504ms (Views: 0.5ms | ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 0.0ms).
    
  • Ruby 3.4.1 (YJIT) / Rails 8.0.1 / Brand new app (no extra gems) :thinking::thinking:

    Completed 200 OK in 50ms (Views: 0.7ms | ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 0.0ms)
    
  • Ruby 3.4.1 (YJIT) / Rails 7.2.2.1 / Brand new app :ok_hand:

    Completed 200 OK in 4ms (Views: 0.9ms | ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 0.0ms)
    
  • Ruby 3.2.4 (no YJIT) / Rails 8.0.1 / My app :thinking:

    Completed 200 OK in 355ms (Views: 0.4ms | ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 0.4ms)
    
  • Ruby 3.2.4 (no YJIT) / Rails 8.0.1 / Brand new app :thinking::thinking:

    Completed 200 OK in 42ms (Views: 0.7ms | ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 0.0ms)
    

Macbook PRO M2Max

  • Ruby 3.3.6 (no YJIT) / Rails 8.0.1 / My app :thinking:

    Completed 200 OK in 307ms (Views: 0.3ms | ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 0.0ms)
    
  • Ruby 3.3.6 (no YJIT) / Rails 8.0.1 / Brand new app :thinking:

    Completed 200 OK in 56ms (Views: 0.2ms | ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 0.0ms)
    
  • Ruby 3.3.6 (no YJIT) / Rails 7.2.2.1 / Brand new app :ok_hand:

    Completed 200 OK in 1ms (Views: 0.3ms | ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 0.0ms)
    

Production server (Docker Docker Hub Container Image Library | App Containerization)

  • Ruby 3.3.5 (YJIT) / Rails 8.0.1 / My app :ok_hand:
    Completed 200 OK in 2ms (Views: 1.5ms | ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 0.0ms)
    

In short, no matter the size of the app or the Ruby version, on my 2 macbook laptops (intel + silicon), Rails 8.0.1 is slower than Rails 7.x.

In the different scenarii, the health controller performs correctly. I’ve got no idea who/what is slowing down the request. Probably a faulty middleware.

Before going deeper in the code, I wanted to know if I was the only one to have noticed this.

Thanks!

1 Like

Alright, thanks to this awesome gem GitHub - jhawthorn/vernier: 📏 next generation CRuby profiler, I was able to pin point the problem: propshaft.

The solution was in the README.md file of Propshaft → GitHub - rails/propshaft: Deliver assets for Rails

As a result, my healthcheck endpoint now responds in 2-3ms and my slowest request has gone from 1200ms to 145ms. I feel really good :slight_smile:

3 Likes

It might be worth revisiting Stop trying to configure listen by default on compatible platforms by dhh · Pull Request #42985 · rails/rails · GitHub.

Thanks so much for this thread. My attachment images loads took ages in one of my new app and I could not understand why before I arrived here.I don’t get why this was removed from default.