{"action":"created","issue":{"url":"https://api.github.com/repos/bundler/bundler/issues/3997","labels_url":"https://api.github.com/repos/bundler/bundler/issues/3997/labels{/name}","comments_url":"https://api.github.com/repos/bundler/bundler/issues/3997/comments","events_url":"https://api.github.com/repos/bundler/bundler/issues/3997/events","html_url":"https://github.com/bundler/bundler/pull/3997","id":107014728,"number":3997,"title":"Allocate the \"ruby\" and \"\\0\" Strings once.","user":{"login":"jrafanie","id":19339,"avatar_url":"https://avatars.githubusercontent.com/u/19339?v=3","gravatar_id":"","url":"https://api.github.com/users/jrafanie","html_url":"https://github.com/jrafanie","followers_url":"https://api.github.com/users/jrafanie/followers","following_url":"https://api.github.com/users/jrafanie/following{/other_user}","gists_url":"https://api.github.com/users/jrafanie/gists{/gist_id}","starred_url":"https://api.github.com/users/jrafanie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrafanie/subscriptions","organizations_url":"https://api.github.com/users/jrafanie/orgs","repos_url":"https://api.github.com/users/jrafanie/repos","events_url":"https://api.github.com/users/jrafanie/events{/privacy}","received_events_url":"https://api.github.com/users/jrafanie/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-09-17T15:47:56Z","updated_at":"2015-09-24T15:26:41Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/bundler/bundler/pulls/3997","html_url":"https://github.com/bundler/bundler/pull/3997","diff_url":"https://github.com/bundler/bundler/pull/3997.diff","patch_url":"https://github.com/bundler/bundler/pull/3997.patch"},"body":"Index#search is called many times so this change is worth it.\r\n\r\nWith a single gem in your Gemfile, this change drops the string\r\nallocations by nearly 30,000.\r\n\r\nScript:\r\n\r\n```ruby\r\nrequire 'allocation_tracer'\r\n\r\nObjectSpace::AllocationTracer.setup(%i{path line type})\r\n\r\nresult = ObjectSpace::AllocationTracer.trace do\r\n  begin\r\n    require 'bundler/inline'\r\n  rescue LoadError => e\r\n    $stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'\r\n    raise e\r\n  end\r\n\r\n  gemfile(true) do\r\n    source 'https://rubygems.org'\r\n    gem 'benchmark-ips'\r\n  end\r\nend\r\n\r\nresult.sort_by{|k, v| k}.each{|k, v|\r\n  puts ([v[0]]+k).join(\"\\t\")\r\n}\r\n```\r\n\r\n**String allocations before**:\r\n\r\n```\r\n$ruby benchmark_allocations.rb | grep T_STRING | sort -nr | head -n 10\r\n65461 /Users/joerafaniello/.rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb  54  T_STRING\r\n64982 /Users/joerafaniello/.rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/version.rb  163 T_STRING\r\n29986 /Users/joerafaniello/.gem/ruby/2.2.3/gems/bundler-1.10.6/lib/bundler/index.rb 71  T_STRING\r\n22142 /Users/joerafaniello/.gem/ruby/2.2.3/gems/bundler-1.10.6/lib/bundler/spec_set.rb  111 T_STRING\r\n20457 /Users/joerafaniello/.rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/version.rb  225 T_STRING\r\n5280  /Users/joerafaniello/.gem/ruby/2.2.3/gems/bundler-1.10.6/lib/bundler/index.rb 87  T_STRING\r\n4848  /Users/joerafaniello/.rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/requirement.rb  92  T_STRING\r\n4708  /Users/joerafaniello/.gem/ruby/2.2.3/gems/bundler-1.10.6/lib/bundler/lockfile_parser.rb 54  T_STRING\r\n4608  /Users/joerafaniello/.rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/version.rb  282 T_STRING\r\n4561  /Users/joerafaniello/.gem/ruby/2.2.3/gems/bundler-1.10.6/lib/bundler/index.rb 19  T_STRING\r\n```\r\n\r\n**String allocations after**:\r\n\r\n```\r\n$ ruby benchmark_allocations.rb | grep T_STRING | sort -nr | head -n 10\r\n65479 /Users/joerafaniello/.rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb  54  T_STRING\r\n64143 /Users/joerafaniello/.rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/version.rb  163 T_STRING\r\n22142 /Users/joerafaniello/.gem/ruby/2.2.3/gems/bundler-1.10.6/lib/bundler/spec_set.rb  111 T_STRING\r\n20407 /Users/joerafaniello/.rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/version.rb  225 T_STRING\r\n5280  /Users/joerafaniello/.gem/ruby/2.2.3/gems/bundler-1.10.6/lib/bundler/index.rb 90  T_STRING\r\n4916  /Users/joerafaniello/.rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/requirement.rb  92  T_STRING\r\n4730  /Users/joerafaniello/.gem/ruby/2.2.3/gems/bundler-1.10.6/lib/bundler/lockfile_parser.rb 54  T_STRING\r\n4608  /Users/joerafaniello/.rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/version.rb  282 T_STRING\r\n4561  /Users/joerafaniello/.gem/ruby/2.2.3/gems/bundler-1.10.6/lib/bundler/index.rb 22  T_STRING\r\n3334  /Users/joerafaniello/.gem/ruby/2.2.3/gems/bundler-1.10.6/lib/bundler/spec_set.rb  134 T_STRING\r\n```"},"comment":{"url":"https://api.github.com/repos/bundler/bundler/issues/comments/142962847","html_url":"https://github.com/bundler/bundler/pull/3997#issuecomment-142962847","issue_url":"https://api.github.com/repos/bundler/bundler/issues/3997","id":142962847,"user":{"login":"homu","id":10212162,"avatar_url":"https://avatars.githubusercontent.com/u/10212162?v=3","gravatar_id":"","url":"https://api.github.com/users/homu","html_url":"https://github.com/homu","followers_url":"https://api.github.com/users/homu/followers","following_url":"https://api.github.com/users/homu/following{/other_user}","gists_url":"https://api.github.com/users/homu/gists{/gist_id}","starred_url":"https://api.github.com/users/homu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/homu/subscriptions","organizations_url":"https://api.github.com/users/homu/orgs","repos_url":"https://api.github.com/users/homu/repos","events_url":"https://api.github.com/users/homu/events{/privacy}","received_events_url":"https://api.github.com/users/homu/received_events","type":"User","site_admin":false},"created_at":"2015-09-24T15:26:41Z","updated_at":"2015-09-24T15:26:41Z","body":":pushpin: Commit e20d286 has been approved by `segiddins`\n\n<!-- @homu r=segiddins e20d286f310bbefbf7dcdbe62ddef47807c61b22 -->"}}