{"action":"closed","issue":{"url":"https://api.github.com/repos/jruby/jruby/issues/3391","labels_url":"https://api.github.com/repos/jruby/jruby/issues/3391/labels{/name}","comments_url":"https://api.github.com/repos/jruby/jruby/issues/3391/comments","events_url":"https://api.github.com/repos/jruby/jruby/issues/3391/events","html_url":"https://github.com/jruby/jruby/issues/3391","id":111003896,"number":3391,"title":"define_method performance degradation ","user":{"login":"film42","id":1043908,"avatar_url":"https://avatars.githubusercontent.com/u/1043908?v=3","gravatar_id":"","url":"https://api.github.com/users/film42","html_url":"https://github.com/film42","followers_url":"https://api.github.com/users/film42/followers","following_url":"https://api.github.com/users/film42/following{/other_user}","gists_url":"https://api.github.com/users/film42/gists{/gist_id}","starred_url":"https://api.github.com/users/film42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/film42/subscriptions","organizations_url":"https://api.github.com/users/film42/orgs","repos_url":"https://api.github.com/users/film42/repos","events_url":"https://api.github.com/users/film42/events{/privacy}","received_events_url":"https://api.github.com/users/film42/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-10-12T15:52:16Z","updated_at":"2015-10-14T02:23:39Z","closed_at":"2015-10-14T02:23:39Z","body":"I noticed a performance degradation with `define_method` in jruby 9k recently. It sounds like this might have more to do with block overhead with IR in jruby 9k though (https://github.com/jruby/jruby/issues/3389#issuecomment-147416019).\r\n\r\nHere's what I found:\r\n\r\nI'm running these with `--profile.api` flag enabled.\r\n\r\n```ruby\r\nrequire 'jruby/profiler'\r\nclass Foo\r\n  define_method(:bar) do\r\n  end\r\nend\r\n\r\n# Warm the VM\r\n100_000.times { Foo.new.bar }\r\n\r\n# Profile\r\nf = Foo.new\r\nprofile_data = JRuby::Profiler.profile do\r\n  100_000.times { f.bar }\r\nend\r\n\r\nprofile_printer = JRuby::Profiler::FlatProfilePrinter.new(profile_data)\r\nputs profile_printer.printProfile(STDOUT)\r\n```\r\n\r\n#### 1.7:\r\n\r\n```\r\n     total        self    children       calls  method\r\n----------------------------------------------------------------\r\n      0.06        0.04        0.02           1  Fixnum#times\r\n      0.02        0.02        0.00      100000  Foo#bar\r\n```\r\n\r\n#### 9k:\r\n\r\n```\r\n     total        self    children       calls  method\r\n----------------------------------------------------------------\r\n      0.09        0.06        0.03           1  Fixnum#times\r\n      0.03        0.03        0.00      100000  Foo#bar\r\n```\r\n\r\nThere are some occasions where I can get 9k to run as fast as 1.7 for a single test, but the in general, 1.7 seems to be faster than 9k.\r\n\r\nBtw, I'm thinking this is block related since `#times` is also much slower on 9k."}}