Adequate Record and Perl Secrets: Aaron Patterson (Tenderlove) on Rails Internals

UGtastic Archive
Transcript Verified
The Interviewer

Mike Hall

Interviewer, community organizer at UGtastic

The Guest

Aaron Patterson

Ruby & Rails Core Team Member, Keynote Speaker

The Conversation


Mike Hall Interviewer, community organizer at UGtastic
Hi, it's Mike with UGtastic, and I'm at RailsConf 2014, and I'm standing here with Aaron Patterson. You might know him as TenderLove on Twitter and GitHub and all those social places, but he's going to be giving the footnote to the conference tonight. He can't really call it the keynote, because it's at the end. I don't know what to call it.
Aaron Patterson Ruby & Rails Core Team Member, Keynote Speaker
The anti-keynote.
Mike Hall Interviewer, community organizer at UGtastic
Yeah, the anti-keynote. Well, thank you very much for taking the time to speak with me. Can you tell me a little bit about what your talk is going to be about?
Aaron Patterson Ruby & Rails Core Team Member, Keynote Speaker
Yeah, well, first, I guess the first 30% is just going to be jokes and trolling. The second 30% is going to be some bugs and stuff with Active Record internals, and the final 50% is going to be about Adequate Record. I know that adds up to 110%, but I always like to give 110%.
Mike Hall Interviewer, community organizer at UGtastic
It's 100%. Just don't add it.
Aaron Patterson Ruby & Rails Core Team Member, Keynote Speaker
So, yeah, it's just going to be jokes, bugs, and then Adequate Record is what we're going to be talking about.
Mike Hall Interviewer, community organizer at UGtastic
What is Adequate Record?
Aaron Patterson Ruby & Rails Core Team Member, Keynote Speaker
It's a project that I've been working on for a very long time, but I didn't really have a name for it. What it is is just a set of patches on top of Active Record, specifically for performance improvements.
Mike Hall Interviewer, community organizer at UGtastic
Is it just more of a streamlining of the internals?
Aaron Patterson Ruby & Rails Core Team Member, Keynote Speaker
Basically, I've been refactoring the internals for a very long time. The main performance improvement is SQL statement generation caching. The actual string that Active Record passes to the database—it caches the generation of that. We only do that once, and your queries end up being faster.
Aaron Patterson Ruby & Rails Core Team Member, Keynote Speaker
I've been working on internal refactoring for literally years just to get to the point where I could have this particular thing, but I never had a name for it until recently.
Mike Hall Interviewer, community organizer at UGtastic
That sounds like what other database engines do where you can lean on query caching inside. You're pulling some of that capability out into the Ruby layer so it can be faster.
Aaron Patterson Ruby & Rails Core Team Member, Keynote Speaker
Yeah, Active Record already does query caching, uses prepared statements, and does cache query execution. The problem is that even though we use prepared statements, we still have to generate the SQL statement in order to look up the prepared statement. So we've always had this overhead before querying the database of building up the query. This eliminates that overhead.
Mike Hall Interviewer, community organizer at UGtastic
You've been a contributor to Rails for a while. Is Rails the first open-source project you were involved in, or how did you come to being on Rails Core?
Aaron Patterson Ruby & Rails Core Team Member, Keynote Speaker
Not at all. My very first open-source patch was probably in 2001. It was to a Perl library. Don't Google me. It's embarrassing.
Mike Hall Interviewer, community organizer at UGtastic
You don't want anybody to know you did Perl.
Aaron Patterson Ruby & Rails Core Team Member, Keynote Speaker
No! My first real major open-source stuff was with Ruby in maybe 2006, working on the Mechanize gem. That was a port of the Perl Mechanize by Andy Lester.
Mike Hall Interviewer, community organizer at UGtastic
Andy Lester! I've also interviewed him. He's from my neck of the woods.
Aaron Patterson Ruby & Rails Core Team Member, Keynote Speaker
Oh, that's awesome. I didn't actually start Mechanize. I inherited it. I was using it a lot, and the maintainer wasn't working on it so much, so I picked it up from him, and that was my first major open-source responsibility.
Mike Hall Interviewer, community organizer at UGtastic
So that's when you became a grown-up in FOSS. When did you learn about Rails?
Aaron Patterson Ruby & Rails Core Team Member, Keynote Speaker
Around the same time I was getting into Ruby and working on Mechanize for web automation. The famous 15-minute 'Build a Blog' video came out by DHH, and I saw that and was like, 'Wow, I gotta try this out.'

Critical Insights


durable
"Adequate Record is an internal performance initiative for Active Record focused on SQL statement generation caching, eliminating the overhead of string building prior to database queries."
durable
"Significant performance breakthroughs in mature open-source frameworks (like Rails) often require years of silent internal refactoring before the final optimization can be applied."
time bound
"Many prominent Ruby open-source contributors originally transitioned into the ecosystem through cross-language ports or automation tools, often migrating from Perl."
time bound
"The famous '15-minute Build a Blog' screencast by DHH was a massive catalyst for Ruby on Rails adoption, drawing early pioneers into the framework."