TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

ARel 2.0: Active Record Performance in Rails 3.0.2

85 pointsby mudgemeisterover 14 years ago

10 comments

glebover 14 years ago
This is awesome work. I've been following these commits on GitHub and it's great to see AR being optimized.<p>Unfortunately there is not enough info in these benchmarks to tell whether for a large production app 3.0 might be 10 times slower than 2.3 for that particular find you are benchmarking. Or 10 times faster. Or the same.<p>Here's why -- for MRI the time spent on each GC run is a function of total process size/# loaded objects, which is mainly a function of your code size. In a trivial test case you can run GC in a few milliseconds. In a production app it's 100ms+. Simply by loading more code into the benchmark it's possible that we can change results completely.<p>When benchmarking ruby code it's better to keep runtime, # of memory allocations and size of memory allocation separate and report all 3. Meaning you run the test with GC off and patch the interpreter to get the memory allocation info.<p>Different users will have different tradeoffs between runtime costs vs GC costs depending on the app size, ruby interpreter used, GC tuning parameters, available RAM, etc. It's certainly valuable to also come up with general "5x" number, but that should assume and state some reasonable values for the above.
texelover 14 years ago
Admit it: you just wanted to use an AST so that you could easily convert SQL to and from XML for an upcoming talk.
评论 #1792746 未加载
joevandykover 14 years ago
Are there tests in the ActiveRecord code base to prevent performance regressions?
mattknoxover 14 years ago
technical erratum: if each node in the list adds all the previous nodes as new objects, then with 4 nodes, the total number of objects is 10, not 24, and the overall order of the operation is O(n^2). It's still cool that he is faster, and cooler that it is using an AST, which seems to me like the right solution.
评论 #1792960 未加载
tonycocoover 14 years ago
Great work. This is why the Rails community is so damn solid.
stephencelisover 14 years ago
I think 3.0.2 is a typo, as 3.0.1 is referenced later in the article, and was just tagged here:<p><a href="http://github.com/rails/rails/tree/v3.0.1" rel="nofollow">http://github.com/rails/rails/tree/v3.0.1</a><p>(And released! It's available via `gem update'.)
评论 #1792695 未加载
评论 #1792692 未加载
rnicholsonover 14 years ago
Why is<p>attr_reader :foo<p>faster than<p>def foo;@foo;end<p>Is this in 1.9.x? or 1.8.x? or both?
评论 #1793090 未加载
ambertchover 14 years ago
haha! I didn't know this guy had a blog. I've heard Aaron Patterson speak, he is crazy and awesome at the same time, IE crawesome. Or, awezy (aussie?)
评论 #1794882 未加载
heresyover 14 years ago
Good article, though there's a hint of "I just had my coffee" in it.<p>Do programmers dream of O(n!) sheep?
cannikinover 14 years ago
Release date?