{"action":"created","issue":{"url":"https://api.github.com/repos/getsentry/raven-ruby/issues/480","repository_url":"https://api.github.com/repos/getsentry/raven-ruby","labels_url":"https://api.github.com/repos/getsentry/raven-ruby/issues/480/labels{/name}","comments_url":"https://api.github.com/repos/getsentry/raven-ruby/issues/480/comments","events_url":"https://api.github.com/repos/getsentry/raven-ruby/issues/480/events","html_url":"https://github.com/getsentry/raven-ruby/pull/480","id":140308304,"number":480,"title":"Optimizations","user":{"login":"zanker","id":323517,"avatar_url":"https://avatars.githubusercontent.com/u/323517?v=3","gravatar_id":"","url":"https://api.github.com/users/zanker","html_url":"https://github.com/zanker","followers_url":"https://api.github.com/users/zanker/followers","following_url":"https://api.github.com/users/zanker/following{/other_user}","gists_url":"https://api.github.com/users/zanker/gists{/gist_id}","starred_url":"https://api.github.com/users/zanker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zanker/subscriptions","organizations_url":"https://api.github.com/users/zanker/orgs","repos_url":"https://api.github.com/users/zanker/repos","events_url":"https://api.github.com/users/zanker/events{/privacy}","received_events_url":"https://api.github.com/users/zanker/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":12,"created_at":"2016-03-11T22:30:34Z","updated_at":"2016-07-03T16:50:47Z","closed_at":"2016-03-21T14:59:04Z","pull_request":{"url":"https://api.github.com/repos/getsentry/raven-ruby/pulls/480","html_url":"https://github.com/getsentry/raven-ruby/pull/480","diff_url":"https://github.com/getsentry/raven-ruby/pull/480.diff","patch_url":"https://github.com/getsentry/raven-ruby/pull/480.patch"},"body":"Hey, we were noticing some performance issues with the Raven gem. I dug in and optimization a bunch of the major hotspots I found. All numbers below are base vs optimization, rather than cumulative of all optimizations done.\r\n\r\nI added an option to use `JSON` instead of `OkJson`. `JSON` has a native C client which is much much faster. This was a 35% improvement.\r\n\r\nEach `Backtrace::Line` instance would cache `in_app_pattern` regex. Since nothing in that regex relies on the line data, I moved it to be cached by the `Backtrace` class instead. That was 10%.\r\n\r\nThe `modules` and `stacktrace` portions of the event are all internal data that doesn't need to be redacted normally. I added an option to let people disable redaction, as those are the biggest parts of the event hash. This was a 52% improvement.\r\n\r\nThose were the big ones, I did two smaller optimizations since they were easy. Calling `resolve_hostname` per exception is a little excessive, I moved it to be called when `Raven::Configuration` is initialized. I also did a small optimization to `stacktrace_interface_from` by reducing the amount of lines it needed to iterate over.\r\n\r\n\r\n```\r\n                    user     system      total        real\r\nbase   3.820000   0.040000   3.860000 (  3.974137)\r\n\r\n                    user     system      total        real\r\noptimizations   0.360000   0.000000   0.360000 (  0.365436)\r\n```\r\n\r\nRubyProf traces on Ruby 2.3.0, against the latest Raven master: [pre-optimization](https://gist.github.com/zanker/683c9346af06453a8b14), [post-optimization](https://gist.github.com/zanker/5278a25a2904f7542150).\r\n\r\nIn general, I tried to preserve the existing functionality and make the improvements be optional to avoid breaking anything.\r\n\r\ncc @nerdrew"},"comment":{"url":"https://api.github.com/repos/getsentry/raven-ruby/issues/comments/230162917","html_url":"https://github.com/getsentry/raven-ruby/pull/480#issuecomment-230162917","issue_url":"https://api.github.com/repos/getsentry/raven-ruby/issues/480","id":230162917,"user":{"login":"nateberkopec","id":845662,"avatar_url":"https://avatars.githubusercontent.com/u/845662?v=3","gravatar_id":"","url":"https://api.github.com/users/nateberkopec","html_url":"https://github.com/nateberkopec","followers_url":"https://api.github.com/users/nateberkopec/followers","following_url":"https://api.github.com/users/nateberkopec/following{/other_user}","gists_url":"https://api.github.com/users/nateberkopec/gists{/gist_id}","starred_url":"https://api.github.com/users/nateberkopec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nateberkopec/subscriptions","organizations_url":"https://api.github.com/users/nateberkopec/orgs","repos_url":"https://api.github.com/users/nateberkopec/repos","events_url":"https://api.github.com/users/nateberkopec/events{/privacy}","received_events_url":"https://api.github.com/users/nateberkopec/received_events","type":"User","site_admin":false},"created_at":"2016-07-03T16:50:47Z","updated_at":"2016-07-03T16:50:47Z","body":"@zanker Could you provide your original benchmark here?"}}
{"actor":{"display_login":"nateberkopec"}}