News for hackers. Stuff that matters.
Re:Ruby 3.3's YJIT: Faster While Using Less Memory by dalyons on Monday December 18, 2023 @04:43PM (#38688766)
I’m curious why you think constraints are such a problem? I’ve worked on quite a few large rails apps, and whilst you’re not wrong, the extra traffic from checking constraints has always been a tiny negligible part of overall db traffic.
Re:Ruby 3.3's YJIT: Faster While Using Less Memory by schneems on Monday December 18, 2023 @05:21PM (#38689220)
It takes two seconds to add a “validated uniqueness” and now for every save or update instead of one SQL command to commit the data you’ve got 2 (multiplied by the number of validations). Plus this validation is weak in that it cannot protect from actual duplicate data.

These check queries are individually fast but put a tremendous load on a running app’s database. If you halve the number of queries the database has to process you’ll see more resources to process the slow queries in addition to each commit being faster.

It ultimately depends on the read/write patterns of the app, but most non-trivial rails apps do a bunch of writing AND reading.

My suggestion is less a “this will change the world forever” and more a “fairly clear win, we just have to do it”.

In a prior life I talked Sgrif into implementing it before David caused them to drop Active Record maintenance work.

I know the broad strokes but don’t have the need or mandate to implement it, plus the active record internals are pretty gnarly. Tons of modules, very little encapsulation. Very hard to know the correct place to put stuff, so stuff goes wherever. It’s gotten better from some of the work of Yehudah, Aaron, and Sage but AFAIK there’s no one on core who wants to own it right now. Eileen has done a lot of work recently, but I don’t think it’s her primary focus.

Re:Ruby 3.3's YJIT: Faster While Using Less Memory by byroot on Monday December 18, 2023 @05:37PM (#38689400)
> but AFAIK there’s no one on core who wants to own it right now.

Active Record is probably the "most owned" part of Rails, that's the one with the most core members and committers with deep knowledge of it.

As for your feature request, there's https://github.com/Shopify/activerecord-rescue_from_duplicat..., and we'd like to attempt to upstream that capability in Rails next year (but as everything it may or may not happen).

Re:Ruby 3.3's YJIT: Faster While Using Less Memory by dalyons on Monday December 18, 2023 @05:40PM (#38689426)
I guess I’ve just never seen the combination of lots of writes AND lots of validates_uniqueness(or whatever db validation) AND the writes are updating the unique fields (due to dirty attributes / partial updates). So it’s never really been an issue.

If that’s been a problem for you I totally believe you, and everything you say about a fix all makes sense.

Re:Ruby 3.3's YJIT: Faster While Using Less Memory by schneems on Monday December 18, 2023 @06:42PM (#38689935)
I work at Heroku and see a lot of different apps.
Re:Ruby 3.3's YJIT: Faster While Using Less Memory by dalyons on Monday December 18, 2023 @08:07PM (#38690548)
That makes sense! Sorry, you said that but I didnt connect the dots