Repository navigation
Conversation
|
Thanks @nviennot ! This looks awesome. I'll review it either today or Monday. Could you fill out the CLA (http://rethinkdb.com/community/cla/) if you haven't already? I agree we should seriously consider making the backtraces an optional feature you can turn on (or maybe they could default to on when you call |
|
I wasn't sure if I filled the CLA, so I did it. How can backtrace be turned on/off (globally)?
The repl thing is not a good idea I think, because you don't need a backtrace in a repl, you just typed the query, you know where it's coming from. If it was up to me, I'd remove the funky backtrace feature entirely. Not worth the trouble. The benefits are really small IMHO. |
Depends a lot on your usage pattern. I frequently find myself doing things like this: def get_date_range(tbl, left, right)
tbl.between(r.epoch_time(left), r.epoch_time(right), index:'date')
end
def complete_entry_p(entry)
entry['field1'] & entry['field2'] & entry['field3'] & entry['field4']
end
get_date_range(r.table('test'), t1, t2).filter{|row| r.not(complete_entry_p(row))}If you're writing code like that, it helps a lot to have the backtrace tell you whether the error occured in the part of the query constructed in I would believe that most RethinkDB users don't do this, though, so it's probably worth turning it off by default. |
|
@mlucy -- would you mind opening a separate proposal for turning off backtraces since it's not a part of this pull request? (Also, I'd like to talk about it in person for a few mins to make sure I understand all implications of what's going on) |
|
Actually, an argument for removing it entirely is that no other drivers (including the Python and JS drivers) have picked it up. |
|
Sure. Let's move discussion of the backtrace issue to #1843 . |
|
I did some benchmarking here. The backtraces seem to materially impact performance, but nviennot@f627a73 doesn't seem to change much. Using Daniel's RubyDatabaseBenchmarks in Ruby 2.0 on Electro, it seems to affect the benchmark by <1% (and possibly not at all; it certainly has a smaller effect than the variance between runs). I think the extra .03ms it saves isn't noticeable under normal conditions right now. Since it makes the logic more complicated (and uses As for the backtraces, I think we should just drop them entirely (see #1843 ). |
|
I'm fine with that decision. On the long run I think we should have all the |
|
Closing; backtraces will be removed entirely as part of #1843 . |
I'm trying to optimize the Ruby driver due to its poor performance: #1798
One of the issue is that building queries is really long.
Consider this benchmark:
On my machine with ruby2.0p353:
On the
nextbranch, the average time to build the query is0.55ms.With the "don't parse the backtrace all the time" commit, it drops to
0.31ms.With the "Refactored the RQL methods" commit, which precompiles all the RQL commands, it drops to
0.27ms.If we were to make no calls to
callerto retrieve the backtrace, it would drop to0.18ms.Having the backtrace is nice (which is only used in the case of an error), but is ridiculously expensive.
Note that this test is running with a very small backtrace, but on a real application, the backtrace will be much larger. It's not uncommon to see a backtrace depth of 100 functions in a web application when hitting a controller with instrumentation all around the place.
Taking the
0.27msbaseline (with the two commits merged in), when I run the benchmark in a fresh Ruby-on-Rails console instead of its own process, the average time jumps to1.2ms. This is really sad.When removing references to
caller, it goes down to0.58mswhich is still sad. I don't understand why I'm not getting the previous0.18ms, it's probably due to all the crap that gets injected in some core classes.Regardless, I think the nice to have backtrace feature is not worth the
0.6msof overhead.It might even be worth considering some sort of query caching, perhaps like redis: http://redis.io/commands/evalsha or postgresql: http://www.postgresql.org/docs/9.2/static/sql-prepare.html