{"action":"created","issue":{"url":"https://api.github.com/repos/jruby/jruby/issues/3662","repository_url":"https://api.github.com/repos/jruby/jruby","labels_url":"https://api.github.com/repos/jruby/jruby/issues/3662/labels{/name}","comments_url":"https://api.github.com/repos/jruby/jruby/issues/3662/comments","events_url":"https://api.github.com/repos/jruby/jruby/issues/3662/events","html_url":"https://github.com/jruby/jruby/issues/3662","id":133371577,"number":3662,"title":"Performance in 1.7.23 vs 9.0.5.0","user":{"login":"creddy","id":593138,"avatar_url":"https://avatars.githubusercontent.com/u/593138?v=3","gravatar_id":"","url":"https://api.github.com/users/creddy","html_url":"https://github.com/creddy","followers_url":"https://api.github.com/users/creddy/followers","following_url":"https://api.github.com/users/creddy/following{/other_user}","gists_url":"https://api.github.com/users/creddy/gists{/gist_id}","starred_url":"https://api.github.com/users/creddy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/creddy/subscriptions","organizations_url":"https://api.github.com/users/creddy/orgs","repos_url":"https://api.github.com/users/creddy/repos","events_url":"https://api.github.com/users/creddy/events{/privacy}","received_events_url":"https://api.github.com/users/creddy/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jruby/jruby/labels/performance","name":"performance","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/jruby/jruby/milestones/47","html_url":"https://github.com/jruby/jruby/milestones/JRuby%209.1.0.0","labels_url":"https://api.github.com/repos/jruby/jruby/milestones/47/labels","id":1422177,"number":47,"title":"JRuby 9.1.0.0","description":"","creator":{"login":"headius","id":10135,"avatar_url":"https://avatars.githubusercontent.com/u/10135?v=3","gravatar_id":"","url":"https://api.github.com/users/headius","html_url":"https://github.com/headius","followers_url":"https://api.github.com/users/headius/followers","following_url":"https://api.github.com/users/headius/following{/other_user}","gists_url":"https://api.github.com/users/headius/gists{/gist_id}","starred_url":"https://api.github.com/users/headius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/headius/subscriptions","organizations_url":"https://api.github.com/users/headius/orgs","repos_url":"https://api.github.com/users/headius/repos","events_url":"https://api.github.com/users/headius/events{/privacy}","received_events_url":"https://api.github.com/users/headius/received_events","type":"User","site_admin":false},"open_issues":37,"closed_issues":83,"state":"open","created_at":"2015-11-20T18:01:26Z","updated_at":"2016-04-20T06:35:09Z","due_on":null,"closed_at":null},"comments":22,"created_at":"2016-02-12T23:46:32Z","updated_at":"2016-04-20T16:33:58Z","closed_at":null,"body":"I'm hoping for some help in understanding the performance difference I'm seeing when using JRuby 1.7.23 vs 9.0.5.0. During testing, our rails app with its many dependencies showed the difference, but I've worked to distill the example down. The simulated load is from computing a Fibonacci series. \r\n\r\n#### Results\r\nBaseline - JRuby 9.0.5.0 - nothing required\r\n```\r\n➜  testing [jruby-9.0.5.0]  irb\r\nirb(main):001:0> load \"fib.rb\"\r\nCalculating -------------------------------------\r\n              fib up   804.000  i/100ms\r\n-------------------------------------------------\r\n              fib up      8.116k (± 4.3%) i/s -    243.612k\r\n=> true\r\n```\r\nJRuby 1.7.23 - activerecord-jbcsqlite3-adapter required\r\n```\r\n➜  testing [jruby-1.7.23]  irb\r\nirb(main):001:0> require \"activerecord-jdbcsqlite3-adapter\"\r\n=> true\r\nirb(main):002:0> load \"fib.rb\"\r\nCalculating -------------------------------------\r\n              fib up   476.000  i/100ms\r\n-------------------------------------------------\r\n              fib up      4.861k (± 4.5%) i/s -    145.656k\r\n=> true\r\n```\r\nJRuby 9.0.5.0 - activerecord-jbcsqlite3-adapter required\r\n```\r\n➜  testing [jruby-9.0.5.0]  irb\r\nirb(main):001:0> require \"activerecord-jdbcsqlite3-adapter\"\r\n=> true\r\nirb(main):002:0> load \"fib.rb\"\r\nCalculating -------------------------------------\r\n              fib up   389.000  i/100ms\r\n-------------------------------------------------\r\n              fib up      3.883k (± 4.8%) i/s -    116.311k\r\n=> true\r\n```\r\n\r\n#### Setup [https://github.com/creddy/jruby-bench]\r\nJRUBY_OPTS\r\n```\r\n➜  testing [jruby-9.0.5.0]  echo $JRUBY_OPTS\r\n--server -J-Xmx2048m\r\n```\r\njruby info\r\n```\r\n➜  testing [jruby-9.0.5.0]  jruby --version\r\njruby 9.0.5.0 (2.2.3) 2016-01-26 7bee00d Java HotSpot(TM) 64-Bit Server VM 25.60-b23 on 1.8.0_60-b27 +jit [darwin-x86_64]\r\n➜  testing [jruby-1.7.23]  jruby --version\r\njruby 1.7.23 (1.9.3p551) 2015-11-24 f496dd5 on Java HotSpot(TM) 64-Bit Server VM 1.8.0_60-b27 +jit [darwin-x86_64]\r\n```\r\n\r\ngems\r\n```\r\ngem install benchmark-ips --version 2.3.0\r\ngem install activerecord-jdbcsqlite3-adapter\r\n```\r\nfib.rb\r\n```ruby\r\ndef fibonacci(n)\r\n  return n if (0..1).include?(n)\r\n  (fibonacci(n - 1) + fibonacci(n - 2))\r\nend\r\n \r\nrequire 'benchmark/ips'\r\n \r\nBenchmark.ips do |x|\r\n  x.config(time: 30, warmup: 60)\r\n \r\n  x.report(\"fib up\") {\r\n    fibonacci(15)\r\n  }\r\n \r\n  x.compare!\r\nend\r\n```\r\n\r\nI included the results from 9.0.5.0 without the require since it's a curiosity. My interest is primarily in the difference between the two versions, but it is interesting none the less. \r\n\r\nI'm excited to leverage the impressive work that you all have done to bring us 9k and I am happy to provide any additional information or refine my benchmark. Thank you"},"comment":{"url":"https://api.github.com/repos/jruby/jruby/issues/comments/212503472","html_url":"https://github.com/jruby/jruby/issues/3662#issuecomment-212503472","issue_url":"https://api.github.com/repos/jruby/jruby/issues/3662","id":212503472,"user":{"login":"headius","id":10135,"avatar_url":"https://avatars.githubusercontent.com/u/10135?v=3","gravatar_id":"","url":"https://api.github.com/users/headius","html_url":"https://github.com/headius","followers_url":"https://api.github.com/users/headius/followers","following_url":"https://api.github.com/users/headius/following{/other_user}","gists_url":"https://api.github.com/users/headius/gists{/gist_id}","starred_url":"https://api.github.com/users/headius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/headius/subscriptions","organizations_url":"https://api.github.com/users/headius/orgs","repos_url":"https://api.github.com/users/headius/repos","events_url":"https://api.github.com/users/headius/events{/privacy}","received_events_url":"https://api.github.com/users/headius/received_events","type":"User","site_admin":false},"created_at":"2016-04-20T16:33:58Z","updated_at":"2016-04-20T16:33:58Z","body":"Ok, here's my findings. I had not noticed the unusual condition (creating a new Range and calling `Range#include?`) in the benchmark, which created a lot of object overhead and confused me a bit.\r\n\r\nFirst off, performance with or without Fixnum reopening guards was about the same as you report, with 9k w/ require performing half as well as 9k w/o require.\r\n\r\n9k w/o require on original bench:\r\n```\r\njruby -Xcompile.invokedynamic fib_bench.rb \r\nWarming up --------------------------------------\r\n              fib up   894.000  i/100ms\r\nCalculating -------------------------------------\r\n              fib up      9.155k (± 5.7%) i/s -    273.564k\r\n```\r\n\r\n9k w/ require on original bench\r\n```\r\nWarming up --------------------------------------\r\n              fib up   367.000  i/100ms\r\nCalculating -------------------------------------\r\n              fib up      3.831k (± 4.8%) i/s -    114.871k\r\n```\r\n\r\nIf I modify the benchmark to use `< 2` rather than the `Range#include?` call, however, things look very different:\r\n\r\nJRuby w/o require:\r\n```\r\nWarming up --------------------------------------\r\n              fib up   145.428k i/100ms\r\nCalculating -------------------------------------\r\n              fib up     20.510M (±13.6%) i/s -    598.727M\r\n```\r\n\r\nJRuby w/ require\r\n```\r\nWarming up --------------------------------------\r\n              fib up   119.957k i/100ms\r\nCalculating -------------------------------------\r\n              fib up     19.632M (±13.7%) i/s -    572.315M\r\n```\r\n\r\nJRuby w/ require but Fixnum reopening guards disabled:\r\n```\r\n[] ~/projects/jruby $ jruby -Xcompile.invokedynamic -r active_record -r activerecord-jdbcsqlite3-adapter fib_bench.rb \r\nWarming up --------------------------------------\r\n              fib up   142.976k i/100ms\r\nCalculating -------------------------------------\r\n              fib up     19.890M (±13.4%) i/s -    580.626M\r\n```\r\n\r\nThis tells me that the Fixnum reopening is likely only having a small impact here, but that `Range#include?` bit seems to be much slower when Rails is loaded."}}