5 ms·
> It's the Rails convenience stuff which slows things down massively. Yeah no kidding.. https://samsaffron.com/archive/2018/06/01/an-analysis-of-memory-bloat
by codinghorror 8y ago
> It's the Rails convenience stuff which slows things down massively.
Yeah no kidding.. https://samsaffron.com/archive/2018/06/01/an-analysis-of-memory-bloat-in-active-record-5-2 https://samsaffron.com/archive/2018/06/01/an-analysis-of-mem...
- ksec 8y agoOr Specifically Active Record. Are we going to get Turbo Record soon? :)
- jashmatthews 8y agoActiveSupport also monkey-patches to_json with a recursive Ruby function, completely nerfing JSON performance by 50x in a lot of cases. Unfortunately, it's what makes 'render json: @model' just... work.
- vinceguidry 8y agoAny time I personally ever want to generate JSON in Ruby, I want recursive tree traversal. It's just too painful to expect primitive types on everything. You'd have to pay that 50x doing it explicitly with a recursive function before you turn it into JSON anyway. Ideally, you'd serialize directly from the database, bypassing the application entirely. Easily doable in ActiveRecord, but it's an explicit action, not the default. Not even sure if it's available in other databases besides PostgreSQL.
- jashmatthews 8y agoIt's not required at all! Rails adds a completely avoidable massive overhead because of the way it overrides to_json see: https://twitter.com/jashmatthews/status/967423661908070401 https://twitter.com/jashmatthews/status/967423661908070401
- vinceguidry 8y agoHave you ever used Ruby's JSON.dump? The second it runs into anything that it can't convert, you get "#<Object:0x00007fab05133078>" everywhere in your output.
- jashmatthews 8y agoOf course! We use Oj.dump in Rails compatibility mode in production at ChartMogul.