[opensuse-ruby] rails 3 performance
Hi, Now that I have the initial port of obs api to rails 3 finished, I consider staying forever on rails2 :) I have this little benchmark that I initially wrote to check if it's worth talking to the API in json instead of the usual XML: prjs = DbProject.find :all x = Benchmark.realtime { prjs.each { |p| p.expand_flags.to_json } } y = Benchmark.realtime { prjs.each { |p| p.to_axml('flagdetails') } puts "#{x} #{y}" And indeed with rails 2.3.14, it shows json is good: 0.108472093 0.379935258 But now with rails 3.2.1 both are slower ;( 0.515888469 1.334631859 Both are with ruby 1.9.3 Greetings, Stephan -- To unsubscribe, e-mail: opensuse-ruby+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-ruby+owner@opensuse.org
On Tue, 20 Mar 2012 14:00:17 +0100 Stephan Kulow <coolo@suse.de> wrote:
Hi,
Now that I have the initial port of obs api to rails 3 finished, I consider staying forever on rails2 :)
I have this little benchmark that I initially wrote to check if it's worth talking to the API in json instead of the usual XML:
Usually using different xml implementation then rexml in rails help a lot.
prjs = DbProject.find :all x = Benchmark.realtime { prjs.each { |p| p.expand_flags.to_json } } y = Benchmark.realtime { prjs.each { |p| p.to_axml('flagdetails') } puts "#{x} #{y}"
And indeed with rails 2.3.14, it shows json is good: 0.108472093 0.379935258
But now with rails 3.2.1 both are slower ;( 0.515888469 1.334631859
Interesting, I think this deserve investigation why it is. Do you have identic scenario? Could you profile run? Josef
Both are with ruby 1.9.3
Greetings, Stephan
-- To unsubscribe, e-mail: opensuse-ruby+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-ruby+owner@opensuse.org
On 20.03.2012 14:06, Josef Reidinger wrote:
On Tue, 20 Mar 2012 14:00:17 +0100 Stephan Kulow <coolo@suse.de> wrote:
Hi,
Now that I have the initial port of obs api to rails 3 finished, I consider staying forever on rails2 :)
I have this little benchmark that I initially wrote to check if it's worth talking to the API in json instead of the usual XML:
Usually using different xml implementation then rexml in rails help a lot.
prjs = DbProject.find :all x = Benchmark.realtime { prjs.each { |p| p.expand_flags.to_json } } y = Benchmark.realtime { prjs.each { |p| p.to_axml('flagdetails') } puts "#{x} #{y}"
With rexml it was be like 7 seconds - we left that behind with OBS 2.0 :)
Greetings, Stephan -- To unsubscribe, e-mail: opensuse-ruby+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-ruby+owner@opensuse.org
On 20.03.2012 14:06, Josef Reidinger wrote:
On Tue, 20 Mar 2012 14:00:17 +0100 Stephan Kulow <coolo@suse.de> wrote:
Hi,
Now that I have the initial port of obs api to rails 3 finished, I consider staying forever on rails2 :)
I have this little benchmark that I initially wrote to check if it's worth talking to the API in json instead of the usual XML:
Usually using different xml implementation then rexml in rails help a lot.
prjs = DbProject.find :all x = Benchmark.realtime { prjs.each { |p| p.expand_flags.to_json } } y = Benchmark.realtime { prjs.each { |p| p.to_axml('flagdetails') } puts "#{x} #{y}"
And indeed with rails 2.3.14, it shows json is good: 0.108472093 0.379935258
But now with rails 3.2.1 both are slower ;( 0.515888469 1.334631859
Interesting, I think this deserve investigation why it is. Do you have identic scenario? Could you profile run?
Between the runs I only switch branch, both are working against the same set of fixtures against the same database. Attached are two perftools pictures - the rails32 sample has 62% GC, which appears like madness to me. Greetings, Stephan
On 20.03.2012 14:17, Stephan Kulow wrote:
On 20.03.2012 14:06, Josef Reidinger wrote:
On Tue, 20 Mar 2012 14:00:17 +0100 Stephan Kulow <coolo@suse.de> wrote:
Hi,
Now that I have the initial port of obs api to rails 3 finished, I consider staying forever on rails2 :)
I have this little benchmark that I initially wrote to check if it's worth talking to the API in json instead of the usual XML:
Usually using different xml implementation then rexml in rails help a lot.
prjs = DbProject.find :all x = Benchmark.realtime { prjs.each { |p| p.expand_flags.to_json } } y = Benchmark.realtime { prjs.each { |p| p.to_axml('flagdetails') } puts "#{x} #{y}"
And indeed with rails 2.3.14, it shows json is good: 0.108472093 0.379935258
But now with rails 3.2.1 both are slower ;( 0.515888469 1.334631859
Interesting, I think this deserve investigation why it is. Do you have identic scenario? Could you profile run?
Between the runs I only switch branch, both are working against the same set of fixtures against the same database.
Attached are two perftools pictures - the rails32 sample has 62% GC, which appears like madness to me.
As expected, a GC.disable before the test "improves" performance GC.disable: 0.258863653 0.552205324 normal with GC 0.579500092 1.455681835 now on to C on rails :) Greetings, Stephan -- To unsubscribe, e-mail: opensuse-ruby+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-ruby+owner@opensuse.org
On 03/20/2012 04:12 PM, Stephan Kulow wrote:
As expected, a GC.disable before the test "improves" performance GC.disable: 0.258863653 0.552205324
normal with GC 0.579500092 1.455681835
Have you tried tweaking the GC settings? We are using a patched 1.8.7 Ruby binary with the following tweaks to improve GC: #!/bin/sh # defaults # export RUBY_HEAP_MIN_SLOTS=10000 # export RUBY_HEAP_SLOTS_INCREMENT=10000 # export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1.8 # export RUBY_GC_MALLOC_LIMIT=8000000 # export RUBY_HEAP_FREE_MIN=4096 # twitter export RUBY_HEAP_MIN_SLOTS=500000 export RUBY_HEAP_SLOTS_INCREMENT=250000 export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1 export RUBY_GC_MALLOC_LIMIT=50000000 exec "/usr/bin/ruby.org" "$@" Not sure if this helps 1.9. James T. -- To unsubscribe, e-mail: opensuse-ruby+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-ruby+owner@opensuse.org
On 20.03.2012 16:21, James Tan wrote:
On 03/20/2012 04:12 PM, Stephan Kulow wrote:
As expected, a GC.disable before the test "improves" performance GC.disable: 0.258863653 0.552205324
normal with GC 0.579500092 1.455681835
Have you tried tweaking the GC settings?
We are using a patched 1.8.7 Ruby binary with the following tweaks to improve GC:
I don't intend to patch ruby for rails - rails 2 and rails 3 use the same ruby version. Greetings, Stephan -- To unsubscribe, e-mail: opensuse-ruby+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-ruby+owner@opensuse.org
Am Dienstag 20 März 2012 16:28:09 schrieb Stephan Kulow:
On 20.03.2012 16:21, James Tan wrote:
On 03/20/2012 04:12 PM, Stephan Kulow wrote:
As expected, a GC.disable before the test "improves" performance GC.disable: 0.258863653 0.552205324
normal with GC 0.579500092 1.455681835
Have you tried tweaking the GC settings?
We are using a patched 1.8.7 Ruby binary with the following tweaks to improve GC:
I don't intend to patch ruby for rails - rails 2 and rails 3 use the same ruby version.
Greetings, Stephan
Maybe you should give it a try... The patch we use is this one: https://github.com/patshaughnessy/ruby187gc which is a port from ruby186gc.patch from https://github.com/skaes/railsbench. There is also a ruby 1.9 version available. For Studio the performance increase was huge, ~30-50% on susestudio.com and 50% for the test suite. Andre -- To unsubscribe, e-mail: opensuse-ruby+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-ruby+owner@opensuse.org
Am Dienstag, 20. März 2012, 16:28:09 schrieb Stephan Kulow:
I don't intend to patch ruby for rails - rails 2 and rails 3 use the same ruby version.
Greetings, Stephan
So what do you intend to do? - live with it being slower? - disable GC? - sprinkle some executive powder on it? Regards, Dominik -- To unsubscribe, e-mail: opensuse-ruby+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-ruby+owner@opensuse.org
On 20.03.2012 16:33, Dominik Bamberger wrote:
Am Dienstag, 20. März 2012, 16:28:09 schrieb Stephan Kulow:
I don't intend to patch ruby for rails - rails 2 and rails 3 use the same ruby version.
Greetings, Stephan
So what do you intend to do? - live with it being slower? - disable GC? - sprinkle some executive powder on it?
Stay with rails 2 till ruby 3.17 finally solves the problem? Greetings, Stephan -- To unsubscribe, e-mail: opensuse-ruby+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-ruby+owner@opensuse.org
Am Dienstag, 20. März 2012, 16:34:49 schrieb Stephan Kulow:
On 20.03.2012 16:33, Dominik Bamberger wrote:
Am Dienstag, 20. März 2012, 16:28:09 schrieb Stephan Kulow:
I don't intend to patch ruby for rails - rails 2 and rails 3 use the same ruby version.
Greetings, Stephan
So what do you intend to do? - live with it being slower? - disable GC? - sprinkle some executive powder on it?
Stay with rails 2 till ruby 3.17 finally solves the problem?
Greetings, Stephan
I don't see that happening. But if staying with Rails 2 (and therefore backporting security patches and such) is possible for you, it might be a valid option after all. If project however has a certain size, you might wanna give the GC patch at least a try. Otherwise you'll just end up with a lot of tedious work. All the best, Dominik -- To unsubscribe, e-mail: opensuse-ruby+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-ruby+owner@opensuse.org
On 20.03.2012 16:21, James Tan wrote:
On 03/20/2012 04:12 PM, Stephan Kulow wrote:
As expected, a GC.disable before the test "improves" performance GC.disable: 0.258863653 0.552205324
normal with GC 0.579500092 1.455681835
Have you tried tweaking the GC settings?
We are using a patched 1.8.7 Ruby binary with the following tweaks to improve GC:
#!/bin/sh # defaults # export RUBY_HEAP_MIN_SLOTS=10000 # export RUBY_HEAP_SLOTS_INCREMENT=10000 # export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1.8 # export RUBY_GC_MALLOC_LIMIT=8000000 # export RUBY_HEAP_FREE_MIN=4096
# twitter export RUBY_HEAP_MIN_SLOTS=500000 export RUBY_HEAP_SLOTS_INCREMENT=250000 export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1 export RUBY_GC_MALLOC_LIMIT=50000000
exec "/usr/bin/ruby.org" "$@"
Not sure if this helps 1.9.
BTW: 1.9.3 has this patch already in, but for some reason I don't yet understand, setting these variables don't really make a difference in how often the GC kicks in. I'm feeling paranoid :) Greetings, Stephan -- To unsubscribe, e-mail: opensuse-ruby+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-ruby+owner@opensuse.org
On 21.03.2012 09:47, Stephan Kulow wrote:
BTW: 1.9.3 has this patch already in, but for some reason I don't yet understand, setting these variables don't really make a difference in how often the GC kicks in. I'm feeling paranoid :)
OK, after a lot of patching ruby I finally can make sense out of it. The environment variables don't matter to my test case as the trigger for the GC run is mysql. For whatever reason the mysql gem has a builtin tick, every 20 queries it will call rb_gc(). If I set that to 2000 I'm back with ~ rails 2 performance. Why the problem wasn't triggered by rails 2 is unclear to me though. In case studio is doing a lot of SQL too, you should try patching rubygem-mysql :) Greetings, Stephan -- To unsubscribe, e-mail: opensuse-ruby+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-ruby+owner@opensuse.org
On 21.03.2012 12:20, Flavio Castelli wrote:
On 03/21/2012 12:19 PM, Stephan Kulow wrote:
In case studio is doing a lot of SQL too, you should try patching rubygem-mysql :)
We use postgresql :)
This is something I seriously consider for OBS too - if just migrating the data wouldn't be a bit problematic for the existant installations ;( Greetings, Stephan -- To unsubscribe, e-mail: opensuse-ruby+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-ruby+owner@opensuse.org
On 03/20/2012 02:00 PM, Stephan Kulow wrote:
Now that I have the initial port of obs api to rails 3 finished, I consider staying forever on rails2 :)
I have this little benchmark that I initially wrote to check if it's worth talking to the API in json instead of the usual XML:
prjs = DbProject.find :all x = Benchmark.realtime { prjs.each { |p| p.expand_flags.to_json } } y = Benchmark.realtime { prjs.each { |p| p.to_axml('flagdetails') } puts "#{x} #{y}"
And indeed with rails 2.3.14, it shows json is good: 0.108472093 0.379935258
But now with rails 3.2.1 both are slower ;( 0.515888469 1.334631859
Both are with ruby 1.9.3
We saw a drop in performance as well in susestudio.com after switching from Rails 2.3 to Rails 3.1, on Ruby 1.8.7. Although in our case it seems to be related to more to the database/ActiveRecord. Don't have any numbers though. In your case, maybe you should look at other JSON and XML libraries if you haven't already done so. Cheers, James T. -- To unsubscribe, e-mail: opensuse-ruby+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-ruby+owner@opensuse.org
participants (6)
-
Andre Duffeck
-
Dominik Bamberger
-
Flavio Castelli
-
James Tan
-
Josef Reidinger
-
Stephan Kulow