{"action":"opened","number":1327,"pull_request":{"url":"https://api.github.com/repos/sensu/sensu-go/pulls/1327","id":182261322,"html_url":"https://github.com/sensu/sensu-go/pull/1327","diff_url":"https://github.com/sensu/sensu-go/pull/1327.diff","patch_url":"https://github.com/sensu/sensu-go/pull/1327.patch","issue_url":"https://api.github.com/repos/sensu/sensu-go/issues/1327","number":1327,"state":"open","locked":false,"title":"Optimize dynamic unmarshaling","user":{"login":"echlebek","id":1633772,"avatar_url":"https://avatars0.githubusercontent.com/u/1633772?v=4","gravatar_id":"","url":"https://api.github.com/users/echlebek","html_url":"https://github.com/echlebek","followers_url":"https://api.github.com/users/echlebek/followers","following_url":"https://api.github.com/users/echlebek/following{/other_user}","gists_url":"https://api.github.com/users/echlebek/gists{/gist_id}","starred_url":"https://api.github.com/users/echlebek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/echlebek/subscriptions","organizations_url":"https://api.github.com/users/echlebek/orgs","repos_url":"https://api.github.com/users/echlebek/repos","events_url":"https://api.github.com/users/echlebek/events{/privacy}","received_events_url":"https://api.github.com/users/echlebek/received_events","type":"User","site_admin":false},"body":"## What is this change?\r\n\r\n```\r\n    Optimize dynamic unmarshaling.\r\n    \r\n    * Use sync.Pool in several places to optimize allocations.\r\n    * Use a wrapper type and json.RawMessage to reduce work needed in\r\n    unmarshaling dynamic attributes.\r\n    * Use a slice instead of a map for getJSONFields.\r\n    \r\n    This commit substantially reduces runtime and allocations for\r\n    dynamic json unmarshaling.\r\n    \r\n    Before:\r\n    [15:34 eric ~/.../sensu-go/types ((6cfa8e40...) $%)]$ go test -bench=. -benchmem\r\n    goos: linux\r\n    goarch: amd64\r\n    pkg: github.com/sensu/sensu-go/types\r\n    BenchmarkCheckRequestMarshal-4            300000              3915 ns/op            3624 B/op         30 allocs/op\r\n    BenchmarkCheckRequestUnmarshal-4           30000             44284 ns/op           39002 B/op        386 allocs/op\r\n    BenchmarkCheckConfigMarshal-4             500000              2399 ns/op            2056 B/op         19 allocs/op\r\n    BenchmarkCheckConfigUnmarshal-4            30000             40347 ns/op           37340 B/op        358 allocs/op\r\n    PASS\r\n    ok      github.com/sensu/sensu-go/types 5.901s\r\n    \r\n    After:\r\n    [15:35 eric ~/.../sensu-go/types (perf/optimize-check-unmarshal $%)]$ go test -bench=. -benchmem\r\n    goos: linux\r\n    goarch: amd64\r\n    pkg: github.com/sensu/sensu-go/types\r\n    BenchmarkCheckRequestMarshal-4            300000              3520 ns/op            3416 B/op         29 allocs/op\r\n    BenchmarkCheckRequestUnmarshal-4          100000             14693 ns/op            5715 B/op        185 allocs/op\r\n    BenchmarkCheckConfigMarshal-4             500000              2204 ns/op            1848 B/op         18 allocs/op\r\n    BenchmarkCheckConfigUnmarshal-4           200000             10317 ns/op            4046 B/op        157 allocs/op\r\n    PASS\r\n    ok      github.com/sensu/sensu-go/types 6.508s\r\n    \r\n    Before:\r\n    [15:32 eric ~/.../types/dynamic ((6cfa8e40...) $%)]$ go test -bench=. -benchmem\r\n    goos: linux\r\n    goarch: amd64\r\n    pkg: github.com/sensu/sensu-go/types/dynamic\r\n    BenchmarkQueryGovaluateSimple-4          1000000              1322 ns/op             320 B/op         18 allocs/op\r\n    BenchmarkQueryGovaluateComplex-4          300000              4431 ns/op            1160 B/op         66 allocs/op\r\n    BenchmarkUnmarshal-4                      200000              9686 ns/op            7656 B/op         82 allocs/op\r\n    BenchmarkMarshal-4                        300000              4783 ns/op            6528 B/op         43 allocs/op\r\n    PASS\r\n    ok      github.com/sensu/sensu-go/types/dynamic 6.277s\r\n    \r\n    After:\r\n    [15:32 eric ~/.../types/dynamic (perf/optimize-check-unmarshal $%)]$ go test -bench=. -benchmem\r\n    goos: linux\r\n    goarch: amd64\r\n    pkg: github.com/sensu/sensu-go/types/dynamic\r\n    BenchmarkQueryGovaluateSimple-4          1000000              1311 ns/op             320 B/op         18 allocs/op\r\n    BenchmarkQueryGovaluateComplex-4          300000              4334 ns/op            1160 B/op         66 allocs/op\r\n    BenchmarkUnmarshal-4                      500000              2752 ns/op            1163 B/op         48 allocs/op\r\n    BenchmarkMarshal-4                        500000              2402 ns/op            5647 B/op         38 allocs/op\r\n    PASS\r\n    ok      github.com/sensu/sensu-go/types/dynamic 5.337s\r\n```\r\n\r\n## Why is this change necessary?\r\n\r\nUnlike dynamic marshaling, dynamic unmarshaling cannot be avoided. Therefore, we must take steps to optimize it as much as possible to avoid performance problems under load. Dynamic unmarshaling is necessary for every CheckRequest, and cannot be avoided in normal operation. These operations generate many allocations, leading to high GC pressure. This commit substantially reduces these allocations to a more manageable level.\r\n\r\n## Does your change need a Changelog entry?\r\n\r\nYes","created_at":"2018-04-17T18:52:17Z","updated_at":"2018-04-17T18:52:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/sensu/sensu-go/pulls/1327/commits","review_comments_url":"https://api.github.com/repos/sensu/sensu-go/pulls/1327/comments","review_comment_url":"https://api.github.com/repos/sensu/sensu-go/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sensu/sensu-go/issues/1327/comments","statuses_url":"https://api.github.com/repos/sensu/sensu-go/statuses/7d92ec74aabcf52606f98d8c74a495f4581b72ca","head":{"label":"sensu:perf/optimize-check-unmarshal","ref":"perf/optimize-check-unmarshal","sha":"7d92ec74aabcf52606f98d8c74a495f4581b72ca","user":{"login":"sensu","id":1648901,"avatar_url":"https://avatars2.githubusercontent.com/u/1648901?v=4","gravatar_id":"","url":"https://api.github.com/users/sensu","html_url":"https://github.com/sensu","followers_url":"https://api.github.com/users/sensu/followers","following_url":"https://api.github.com/users/sensu/following{/other_user}","gists_url":"https://api.github.com/users/sensu/gists{/gist_id}","starred_url":"https://api.github.com/users/sensu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sensu/subscriptions","organizations_url":"https://api.github.com/users/sensu/orgs","repos_url":"https://api.github.com/users/sensu/repos","events_url":"https://api.github.com/users/sensu/events{/privacy}","received_events_url":"https://api.github.com/users/sensu/received_events","type":"Organization","site_admin":false},"repo":{"id":82981995,"name":"sensu-go","full_name":"sensu/sensu-go","owner":{"login":"sensu","id":1648901,"avatar_url":"https://avatars2.githubusercontent.com/u/1648901?v=4","gravatar_id":"","url":"https://api.github.com/users/sensu","html_url":"https://github.com/sensu","followers_url":"https://api.github.com/users/sensu/followers","following_url":"https://api.github.com/users/sensu/following{/other_user}","gists_url":"https://api.github.com/users/sensu/gists{/gist_id}","starred_url":"https://api.github.com/users/sensu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sensu/subscriptions","organizations_url":"https://api.github.com/users/sensu/orgs","repos_url":"https://api.github.com/users/sensu/repos","events_url":"https://api.github.com/users/sensu/events{/privacy}","received_events_url":"https://api.github.com/users/sensu/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sensu/sensu-go","description":"Open source monitoring tool for ephemeral infrastructure & distributed applications.","fork":false,"url":"https://api.github.com/repos/sensu/sensu-go","forks_url":"https://api.github.com/repos/sensu/sensu-go/forks","keys_url":"https://api.github.com/repos/sensu/sensu-go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sensu/sensu-go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sensu/sensu-go/teams","hooks_url":"https://api.github.com/repos/sensu/sensu-go/hooks","issue_events_url":"https://api.github.com/repos/sensu/sensu-go/issues/events{/number}","events_url":"https://api.github.com/repos/sensu/sensu-go/events","assignees_url":"https://api.github.com/repos/sensu/sensu-go/assignees{/user}","branches_url":"https://api.github.com/repos/sensu/sensu-go/branches{/branch}","tags_url":"https://api.github.com/repos/sensu/sensu-go/tags","blobs_url":"https://api.github.com/repos/sensu/sensu-go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sensu/sensu-go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sensu/sensu-go/git/refs{/sha}","trees_url":"https://api.github.com/repos/sensu/sensu-go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sensu/sensu-go/statuses/{sha}","languages_url":"https://api.github.com/repos/sensu/sensu-go/languages","stargazers_url":"https://api.github.com/repos/sensu/sensu-go/stargazers","contributors_url":"https://api.github.com/repos/sensu/sensu-go/contributors","subscribers_url":"https://api.github.com/repos/sensu/sensu-go/subscribers","subscription_url":"https://api.github.com/repos/sensu/sensu-go/subscription","commits_url":"https://api.github.com/repos/sensu/sensu-go/commits{/sha}","git_commits_url":"https://api.github.com/repos/sensu/sensu-go/git/commits{/sha}","comments_url":"https://api.github.com/repos/sensu/sensu-go/comments{/number}","issue_comment_url":"https://api.github.com/repos/sensu/sensu-go/issues/comments{/number}","contents_url":"https://api.github.com/repos/sensu/sensu-go/contents/{+path}","compare_url":"https://api.github.com/repos/sensu/sensu-go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sensu/sensu-go/merges","archive_url":"https://api.github.com/repos/sensu/sensu-go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sensu/sensu-go/downloads","issues_url":"https://api.github.com/repos/sensu/sensu-go/issues{/number}","pulls_url":"https://api.github.com/repos/sensu/sensu-go/pulls{/number}","milestones_url":"https://api.github.com/repos/sensu/sensu-go/milestones{/number}","notifications_url":"https://api.github.com/repos/sensu/sensu-go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sensu/sensu-go/labels{/name}","releases_url":"https://api.github.com/repos/sensu/sensu-go/releases{/id}","deployments_url":"https://api.github.com/repos/sensu/sensu-go/deployments","created_at":"2017-02-23T23:38:08Z","updated_at":"2018-04-17T18:21:22Z","pushed_at":"2018-04-17T18:52:01Z","git_url":"git://github.com/sensu/sensu-go.git","ssh_url":"git@github.com:sensu/sensu-go.git","clone_url":"https://github.com/sensu/sensu-go.git","svn_url":"https://github.com/sensu/sensu-go","homepage":"https://sensuapp.org","size":29622,"stargazers_count":118,"watchers_count":118,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"archived":false,"open_issues_count":172,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":14,"open_issues":172,"watchers":118,"default_branch":"master"}},"base":{"label":"sensu:master","ref":"master","sha":"98485c3df6950fcbbcb7dda5d18c63e48b50f7d5","user":{"login":"sensu","id":1648901,"avatar_url":"https://avatars2.githubusercontent.com/u/1648901?v=4","gravatar_id":"","url":"https://api.github.com/users/sensu","html_url":"https://github.com/sensu","followers_url":"https://api.github.com/users/sensu/followers","following_url":"https://api.github.com/users/sensu/following{/other_user}","gists_url":"https://api.github.com/users/sensu/gists{/gist_id}","starred_url":"https://api.github.com/users/sensu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sensu/subscriptions","organizations_url":"https://api.github.com/users/sensu/orgs","repos_url":"https://api.github.com/users/sensu/repos","events_url":"https://api.github.com/users/sensu/events{/privacy}","received_events_url":"https://api.github.com/users/sensu/received_events","type":"Organization","site_admin":false},"repo":{"id":82981995,"name":"sensu-go","full_name":"sensu/sensu-go","owner":{"login":"sensu","id":1648901,"avatar_url":"https://avatars2.githubusercontent.com/u/1648901?v=4","gravatar_id":"","url":"https://api.github.com/users/sensu","html_url":"https://github.com/sensu","followers_url":"https://api.github.com/users/sensu/followers","following_url":"https://api.github.com/users/sensu/following{/other_user}","gists_url":"https://api.github.com/users/sensu/gists{/gist_id}","starred_url":"https://api.github.com/users/sensu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sensu/subscriptions","organizations_url":"https://api.github.com/users/sensu/orgs","repos_url":"https://api.github.com/users/sensu/repos","events_url":"https://api.github.com/users/sensu/events{/privacy}","received_events_url":"https://api.github.com/users/sensu/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sensu/sensu-go","description":"Open source monitoring tool for ephemeral infrastructure & distributed applications.","fork":false,"url":"https://api.github.com/repos/sensu/sensu-go","forks_url":"https://api.github.com/repos/sensu/sensu-go/forks","keys_url":"https://api.github.com/repos/sensu/sensu-go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sensu/sensu-go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sensu/sensu-go/teams","hooks_url":"https://api.github.com/repos/sensu/sensu-go/hooks","issue_events_url":"https://api.github.com/repos/sensu/sensu-go/issues/events{/number}","events_url":"https://api.github.com/repos/sensu/sensu-go/events","assignees_url":"https://api.github.com/repos/sensu/sensu-go/assignees{/user}","branches_url":"https://api.github.com/repos/sensu/sensu-go/branches{/branch}","tags_url":"https://api.github.com/repos/sensu/sensu-go/tags","blobs_url":"https://api.github.com/repos/sensu/sensu-go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sensu/sensu-go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sensu/sensu-go/git/refs{/sha}","trees_url":"https://api.github.com/repos/sensu/sensu-go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sensu/sensu-go/statuses/{sha}","languages_url":"https://api.github.com/repos/sensu/sensu-go/languages","stargazers_url":"https://api.github.com/repos/sensu/sensu-go/stargazers","contributors_url":"https://api.github.com/repos/sensu/sensu-go/contributors","subscribers_url":"https://api.github.com/repos/sensu/sensu-go/subscribers","subscription_url":"https://api.github.com/repos/sensu/sensu-go/subscription","commits_url":"https://api.github.com/repos/sensu/sensu-go/commits{/sha}","git_commits_url":"https://api.github.com/repos/sensu/sensu-go/git/commits{/sha}","comments_url":"https://api.github.com/repos/sensu/sensu-go/comments{/number}","issue_comment_url":"https://api.github.com/repos/sensu/sensu-go/issues/comments{/number}","contents_url":"https://api.github.com/repos/sensu/sensu-go/contents/{+path}","compare_url":"https://api.github.com/repos/sensu/sensu-go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sensu/sensu-go/merges","archive_url":"https://api.github.com/repos/sensu/sensu-go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sensu/sensu-go/downloads","issues_url":"https://api.github.com/repos/sensu/sensu-go/issues{/number}","pulls_url":"https://api.github.com/repos/sensu/sensu-go/pulls{/number}","milestones_url":"https://api.github.com/repos/sensu/sensu-go/milestones{/number}","notifications_url":"https://api.github.com/repos/sensu/sensu-go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sensu/sensu-go/labels{/name}","releases_url":"https://api.github.com/repos/sensu/sensu-go/releases{/id}","deployments_url":"https://api.github.com/repos/sensu/sensu-go/deployments","created_at":"2017-02-23T23:38:08Z","updated_at":"2018-04-17T18:21:22Z","pushed_at":"2018-04-17T18:52:01Z","git_url":"git://github.com/sensu/sensu-go.git","ssh_url":"git@github.com:sensu/sensu-go.git","clone_url":"https://github.com/sensu/sensu-go.git","svn_url":"https://github.com/sensu/sensu-go","homepage":"https://sensuapp.org","size":29622,"stargazers_count":118,"watchers_count":118,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"archived":false,"open_issues_count":172,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":14,"open_issues":172,"watchers":118,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sensu/sensu-go/pulls/1327"},"html":{"href":"https://github.com/sensu/sensu-go/pull/1327"},"issue":{"href":"https://api.github.com/repos/sensu/sensu-go/issues/1327"},"comments":{"href":"https://api.github.com/repos/sensu/sensu-go/issues/1327/comments"},"review_comments":{"href":"https://api.github.com/repos/sensu/sensu-go/pulls/1327/comments"},"review_comment":{"href":"https://api.github.com/repos/sensu/sensu-go/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sensu/sensu-go/pulls/1327/commits"},"statuses":{"href":"https://api.github.com/repos/sensu/sensu-go/statuses/7d92ec74aabcf52606f98d8c74a495f4581b72ca"}},"author_association":"CONTRIBUTOR","merged":false,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":false,"commits":6,"additions":223,"deletions":153,"changed_files":12}}
{"actor":{"display_login":"echlebek"}}