{"action":"created","comment":{"url":"https://api.github.com/repos/m3db/m3/pulls/comments/232058960","pull_request_review_id":173169948,"id":232058960,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMjA1ODk2MA==","diff_hunk":"@@ -224,22 +237,30 @@ func (w *writer) Write(\n \t\tmetadata.Namespace = series.Namespace.Bytes()\n \t\tmetadata.Shard = series.Shard\n \t\tmetadata.EncodedTags = encodedTags\n-\t\tw.metadataEncoder.Reset()\n-\t\tif err := w.metadataEncoder.EncodeLogMetadata(metadata); err != nil {\n+\n+\t\tw.metadataEncoderBuff = w.metadataEncoderBuff[:0]\n+\t\tvar err error\n+\n+\t\tw.metadataEncoderBuff, err = msgpack.EncodeLogMetadataFast(w.metadataEncoderBuff, metadata)","path":"src/dbnode/persist/fs/commitlog/writer.go","position":107,"original_position":107,"commit_id":"f63a8c1c32d0aea961e11402b1e59b12b59670f0","original_commit_id":"f63a8c1c32d0aea961e11402b1e59b12b59670f0","user":{"login":"robskillington","id":339615,"node_id":"MDQ6VXNlcjMzOTYxNQ==","avatar_url":"https://avatars1.githubusercontent.com/u/339615?v=4","gravatar_id":"","url":"https://api.github.com/users/robskillington","html_url":"https://github.com/robskillington","followers_url":"https://api.github.com/users/robskillington/followers","following_url":"https://api.github.com/users/robskillington/following{/other_user}","gists_url":"https://api.github.com/users/robskillington/gists{/gist_id}","starred_url":"https://api.github.com/users/robskillington/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robskillington/subscriptions","organizations_url":"https://api.github.com/users/robskillington/orgs","repos_url":"https://api.github.com/users/robskillington/repos","events_url":"https://api.github.com/users/robskillington/events{/privacy}","received_events_url":"https://api.github.com/users/robskillington/received_events","type":"User","site_admin":false},"body":"p.s. I realized this can be collapsed somewhat to do the `[:0]` just as you pass it to the EncodeLogMetadataFast method:\r\n```go\r\nvar err error\r\nw.metadataEncoderBuff, err = msgpack.EncodeLogMetadataFast(w.metadataEncoderBuff[:0], metadata)\r\n```","created_at":"2018-11-08T21:01:20Z","updated_at":"2018-11-08T21:01:20Z","html_url":"https://github.com/m3db/m3/pull/1160#discussion_r232058960","pull_request_url":"https://api.github.com/repos/m3db/m3/pulls/1160","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/m3db/m3/pulls/comments/232058960"},"html":{"href":"https://github.com/m3db/m3/pull/1160#discussion_r232058960"},"pull_request":{"href":"https://api.github.com/repos/m3db/m3/pulls/1160"}}},"pull_request":{"url":"https://api.github.com/repos/m3db/m3/pulls/1160","id":229177424,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI5MTc3NDI0","html_url":"https://github.com/m3db/m3/pull/1160","diff_url":"https://github.com/m3db/m3/pull/1160.diff","patch_url":"https://github.com/m3db/m3/pull/1160.patch","issue_url":"https://api.github.com/repos/m3db/m3/issues/1160","number":1160,"state":"open","locked":false,"title":"Make commitlog msgpack encoder really, really fast.","user":{"login":"richardartoul","id":9171254,"node_id":"MDQ6VXNlcjkxNzEyNTQ=","avatar_url":"https://avatars1.githubusercontent.com/u/9171254?v=4","gravatar_id":"","url":"https://api.github.com/users/richardartoul","html_url":"https://github.com/richardartoul","followers_url":"https://api.github.com/users/richardartoul/followers","following_url":"https://api.github.com/users/richardartoul/following{/other_user}","gists_url":"https://api.github.com/users/richardartoul/gists{/gist_id}","starred_url":"https://api.github.com/users/richardartoul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/richardartoul/subscriptions","organizations_url":"https://api.github.com/users/richardartoul/orgs","repos_url":"https://api.github.com/users/richardartoul/repos","events_url":"https://api.github.com/users/richardartoul/events{/privacy}","received_events_url":"https://api.github.com/users/richardartoul/received_events","type":"User","site_admin":false},"body":"The basic gist of this P.R is that the old code had too many function calls. Function call overhead in Golang is small, but when every function does nothing more than write a few bytes to an array in memory, the function call overhead begins to dominate. As a result, what we do in this P.R is create a fast path that manually inlines (read: copy-pastes) a lot of the helper functions. This makes the code more verbose and more difficult to maintain, but we get an over 10x speedup in exchange which is worth it as this is the hottest code path in M3DB and bottlenecks everything else.\r\n\r\nOld path log entry\r\n```\r\ngoos: darwin\r\ngoarch: amd64\r\npkg: github.com/m3db/m3/src/dbnode/persist/fs/msgpack\r\nBenchmarkLogEntryDecoder-8   \t 3000000\t       611 ns/op\t       0 B/op\t       0 allocs/op\r\nPASS\r\nok  \tgithub.com/m3db/m3/src/dbnode/persist/fs/msgpack\t2.423s\r\nSuccess: Benchmarks passed.\r\n```\r\n\r\nNew path log entry\r\n```\r\ngoos: darwin\r\ngoarch: amd64\r\npkg: github.com/m3db/m3/src/dbnode/persist/fs/msgpack\r\nBenchmarkLogEntryEncoderFast-8   \t30000000\t        43.9 ns/op\t       0 B/op\t       0 allocs/op\r\nPASS\r\nok  \tgithub.com/m3db/m3/src/dbnode/persist/fs/msgpack\t1.381s\r\nSuccess: Benchmarks passed.\r\n```\r\n\r\nOld path log metadata\r\n```\r\ngoos: darwin\r\ngoarch: amd64\r\npkg: github.com/m3db/m3/src/dbnode/persist/fs/msgpack\r\nBenchmarkLogMetadataEncoder-8   \t 5000000\t       235 ns/op\t     130 B/op\t       0 allocs/op\r\nPASS\r\nok  \tgithub.com/m3db/m3/src/dbnode/persist/fs/msgpack\t1.526s\r\nSuccess: Benchmarks passed.\r\n```\r\n\r\nNew path log metadata\r\n```\r\ngoos: darwin\r\ngoarch: amd64\r\npkg: github.com/m3db/m3/src/dbnode/persist/fs/msgpack\r\nBenchmarkLogMetadataEncoderFast-8   \t50000000\t        31.9 ns/op\t       0 B/op\t       0 allocs/op\r\nPASS\r\nok  \tgithub.com/m3db/m3/src/dbnode/persist/fs/msgpack\t1.648s\r\nSuccess: Benchmarks passed.\r\n````","created_at":"2018-11-07T21:41:15Z","updated_at":"2018-11-08T21:01:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2946173c5cdc9a689b3da656c5710b4e58392d4b","assignee":null,"assignees":[],"requested_reviewers":[{"login":"prateek","id":199982,"node_id":"MDQ6VXNlcjE5OTk4Mg==","avatar_url":"https://avatars3.githubusercontent.com/u/199982?v=4","gravatar_id":"","url":"https://api.github.com/users/prateek","html_url":"https://github.com/prateek","followers_url":"https://api.github.com/users/prateek/followers","following_url":"https://api.github.com/users/prateek/following{/other_user}","gists_url":"https://api.github.com/users/prateek/gists{/gist_id}","starred_url":"https://api.github.com/users/prateek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prateek/subscriptions","organizations_url":"https://api.github.com/users/prateek/orgs","repos_url":"https://api.github.com/users/prateek/repos","events_url":"https://api.github.com/users/prateek/events{/privacy}","received_events_url":"https://api.github.com/users/prateek/received_events","type":"User","site_admin":false},{"login":"justinjc","id":596351,"node_id":"MDQ6VXNlcjU5NjM1MQ==","avatar_url":"https://avatars1.githubusercontent.com/u/596351?v=4","gravatar_id":"","url":"https://api.github.com/users/justinjc","html_url":"https://github.com/justinjc","followers_url":"https://api.github.com/users/justinjc/followers","following_url":"https://api.github.com/users/justinjc/following{/other_user}","gists_url":"https://api.github.com/users/justinjc/gists{/gist_id}","starred_url":"https://api.github.com/users/justinjc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justinjc/subscriptions","organizations_url":"https://api.github.com/users/justinjc/orgs","repos_url":"https://api.github.com/users/justinjc/repos","events_url":"https://api.github.com/users/justinjc/events{/privacy}","received_events_url":"https://api.github.com/users/justinjc/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/m3db/m3/pulls/1160/commits","review_comments_url":"https://api.github.com/repos/m3db/m3/pulls/1160/comments","review_comment_url":"https://api.github.com/repos/m3db/m3/pulls/comments{/number}","comments_url":"https://api.github.com/repos/m3db/m3/issues/1160/comments","statuses_url":"https://api.github.com/repos/m3db/m3/statuses/f63a8c1c32d0aea961e11402b1e59b12b59670f0","head":{"label":"m3db:ra/fast-commitlog","ref":"ra/fast-commitlog","sha":"f63a8c1c32d0aea961e11402b1e59b12b59670f0","user":{"login":"m3db","id":19937171,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5OTM3MTcx","avatar_url":"https://avatars0.githubusercontent.com/u/19937171?v=4","gravatar_id":"","url":"https://api.github.com/users/m3db","html_url":"https://github.com/m3db","followers_url":"https://api.github.com/users/m3db/followers","following_url":"https://api.github.com/users/m3db/following{/other_user}","gists_url":"https://api.github.com/users/m3db/gists{/gist_id}","starred_url":"https://api.github.com/users/m3db/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m3db/subscriptions","organizations_url":"https://api.github.com/users/m3db/orgs","repos_url":"https://api.github.com/users/m3db/repos","events_url":"https://api.github.com/users/m3db/events{/privacy}","received_events_url":"https://api.github.com/users/m3db/received_events","type":"Organization","site_admin":false},"repo":{"id":61153677,"node_id":"MDEwOlJlcG9zaXRvcnk2MTE1MzY3Nw==","name":"m3","full_name":"m3db/m3","private":false,"owner":{"login":"m3db","id":19937171,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5OTM3MTcx","avatar_url":"https://avatars0.githubusercontent.com/u/19937171?v=4","gravatar_id":"","url":"https://api.github.com/users/m3db","html_url":"https://github.com/m3db","followers_url":"https://api.github.com/users/m3db/followers","following_url":"https://api.github.com/users/m3db/following{/other_user}","gists_url":"https://api.github.com/users/m3db/gists{/gist_id}","starred_url":"https://api.github.com/users/m3db/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m3db/subscriptions","organizations_url":"https://api.github.com/users/m3db/orgs","repos_url":"https://api.github.com/users/m3db/repos","events_url":"https://api.github.com/users/m3db/events{/privacy}","received_events_url":"https://api.github.com/users/m3db/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/m3db/m3","description":"M3 monorepo - Distributed TSDB and Query Engine, Prometheus Sidecar, Metrics Platform","fork":false,"url":"https://api.github.com/repos/m3db/m3","forks_url":"https://api.github.com/repos/m3db/m3/forks","keys_url":"https://api.github.com/repos/m3db/m3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/m3db/m3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/m3db/m3/teams","hooks_url":"https://api.github.com/repos/m3db/m3/hooks","issue_events_url":"https://api.github.com/repos/m3db/m3/issues/events{/number}","events_url":"https://api.github.com/repos/m3db/m3/events","assignees_url":"https://api.github.com/repos/m3db/m3/assignees{/user}","branches_url":"https://api.github.com/repos/m3db/m3/branches{/branch}","tags_url":"https://api.github.com/repos/m3db/m3/tags","blobs_url":"https://api.github.com/repos/m3db/m3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/m3db/m3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/m3db/m3/git/refs{/sha}","trees_url":"https://api.github.com/repos/m3db/m3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/m3db/m3/statuses/{sha}","languages_url":"https://api.github.com/repos/m3db/m3/languages","stargazers_url":"https://api.github.com/repos/m3db/m3/stargazers","contributors_url":"https://api.github.com/repos/m3db/m3/contributors","subscribers_url":"https://api.github.com/repos/m3db/m3/subscribers","subscription_url":"https://api.github.com/repos/m3db/m3/subscription","commits_url":"https://api.github.com/repos/m3db/m3/commits{/sha}","git_commits_url":"https://api.github.com/repos/m3db/m3/git/commits{/sha}","comments_url":"https://api.github.com/repos/m3db/m3/comments{/number}","issue_comment_url":"https://api.github.com/repos/m3db/m3/issues/comments{/number}","contents_url":"https://api.github.com/repos/m3db/m3/contents/{+path}","compare_url":"https://api.github.com/repos/m3db/m3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/m3db/m3/merges","archive_url":"https://api.github.com/repos/m3db/m3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/m3db/m3/downloads","issues_url":"https://api.github.com/repos/m3db/m3/issues{/number}","pulls_url":"https://api.github.com/repos/m3db/m3/pulls{/number}","milestones_url":"https://api.github.com/repos/m3db/m3/milestones{/number}","notifications_url":"https://api.github.com/repos/m3db/m3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/m3db/m3/labels{/name}","releases_url":"https://api.github.com/repos/m3db/m3/releases{/id}","deployments_url":"https://api.github.com/repos/m3db/m3/deployments","created_at":"2016-06-14T20:29:45Z","updated_at":"2018-11-07T22:13:50Z","pushed_at":"2018-11-08T20:19:17Z","git_url":"git://github.com/m3db/m3.git","ssh_url":"git@github.com:m3db/m3.git","clone_url":"https://github.com/m3db/m3.git","svn_url":"https://github.com/m3db/m3","homepage":"https://m3db.io/","size":17888,"stargazers_count":1242,"watchers_count":1242,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":94,"mirror_url":null,"archived":false,"open_issues_count":188,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":94,"open_issues":188,"watchers":1242,"default_branch":"master"}},"base":{"label":"m3db:master","ref":"master","sha":"95dbe5a4ce0bbb8e32d54988856ab62a3fbe57b7","user":{"login":"m3db","id":19937171,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5OTM3MTcx","avatar_url":"https://avatars0.githubusercontent.com/u/19937171?v=4","gravatar_id":"","url":"https://api.github.com/users/m3db","html_url":"https://github.com/m3db","followers_url":"https://api.github.com/users/m3db/followers","following_url":"https://api.github.com/users/m3db/following{/other_user}","gists_url":"https://api.github.com/users/m3db/gists{/gist_id}","starred_url":"https://api.github.com/users/m3db/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m3db/subscriptions","organizations_url":"https://api.github.com/users/m3db/orgs","repos_url":"https://api.github.com/users/m3db/repos","events_url":"https://api.github.com/users/m3db/events{/privacy}","received_events_url":"https://api.github.com/users/m3db/received_events","type":"Organization","site_admin":false},"repo":{"id":61153677,"node_id":"MDEwOlJlcG9zaXRvcnk2MTE1MzY3Nw==","name":"m3","full_name":"m3db/m3","private":false,"owner":{"login":"m3db","id":19937171,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5OTM3MTcx","avatar_url":"https://avatars0.githubusercontent.com/u/19937171?v=4","gravatar_id":"","url":"https://api.github.com/users/m3db","html_url":"https://github.com/m3db","followers_url":"https://api.github.com/users/m3db/followers","following_url":"https://api.github.com/users/m3db/following{/other_user}","gists_url":"https://api.github.com/users/m3db/gists{/gist_id}","starred_url":"https://api.github.com/users/m3db/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m3db/subscriptions","organizations_url":"https://api.github.com/users/m3db/orgs","repos_url":"https://api.github.com/users/m3db/repos","events_url":"https://api.github.com/users/m3db/events{/privacy}","received_events_url":"https://api.github.com/users/m3db/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/m3db/m3","description":"M3 monorepo - Distributed TSDB and Query Engine, Prometheus Sidecar, Metrics Platform","fork":false,"url":"https://api.github.com/repos/m3db/m3","forks_url":"https://api.github.com/repos/m3db/m3/forks","keys_url":"https://api.github.com/repos/m3db/m3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/m3db/m3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/m3db/m3/teams","hooks_url":"https://api.github.com/repos/m3db/m3/hooks","issue_events_url":"https://api.github.com/repos/m3db/m3/issues/events{/number}","events_url":"https://api.github.com/repos/m3db/m3/events","assignees_url":"https://api.github.com/repos/m3db/m3/assignees{/user}","branches_url":"https://api.github.com/repos/m3db/m3/branches{/branch}","tags_url":"https://api.github.com/repos/m3db/m3/tags","blobs_url":"https://api.github.com/repos/m3db/m3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/m3db/m3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/m3db/m3/git/refs{/sha}","trees_url":"https://api.github.com/repos/m3db/m3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/m3db/m3/statuses/{sha}","languages_url":"https://api.github.com/repos/m3db/m3/languages","stargazers_url":"https://api.github.com/repos/m3db/m3/stargazers","contributors_url":"https://api.github.com/repos/m3db/m3/contributors","subscribers_url":"https://api.github.com/repos/m3db/m3/subscribers","subscription_url":"https://api.github.com/repos/m3db/m3/subscription","commits_url":"https://api.github.com/repos/m3db/m3/commits{/sha}","git_commits_url":"https://api.github.com/repos/m3db/m3/git/commits{/sha}","comments_url":"https://api.github.com/repos/m3db/m3/comments{/number}","issue_comment_url":"https://api.github.com/repos/m3db/m3/issues/comments{/number}","contents_url":"https://api.github.com/repos/m3db/m3/contents/{+path}","compare_url":"https://api.github.com/repos/m3db/m3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/m3db/m3/merges","archive_url":"https://api.github.com/repos/m3db/m3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/m3db/m3/downloads","issues_url":"https://api.github.com/repos/m3db/m3/issues{/number}","pulls_url":"https://api.github.com/repos/m3db/m3/pulls{/number}","milestones_url":"https://api.github.com/repos/m3db/m3/milestones{/number}","notifications_url":"https://api.github.com/repos/m3db/m3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/m3db/m3/labels{/name}","releases_url":"https://api.github.com/repos/m3db/m3/releases{/id}","deployments_url":"https://api.github.com/repos/m3db/m3/deployments","created_at":"2016-06-14T20:29:45Z","updated_at":"2018-11-07T22:13:50Z","pushed_at":"2018-11-08T20:19:17Z","git_url":"git://github.com/m3db/m3.git","ssh_url":"git@github.com:m3db/m3.git","clone_url":"https://github.com/m3db/m3.git","svn_url":"https://github.com/m3db/m3","homepage":"https://m3db.io/","size":17888,"stargazers_count":1242,"watchers_count":1242,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":94,"mirror_url":null,"archived":false,"open_issues_count":188,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":94,"open_issues":188,"watchers":1242,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/m3db/m3/pulls/1160"},"html":{"href":"https://github.com/m3db/m3/pull/1160"},"issue":{"href":"https://api.github.com/repos/m3db/m3/issues/1160"},"comments":{"href":"https://api.github.com/repos/m3db/m3/issues/1160/comments"},"review_comments":{"href":"https://api.github.com/repos/m3db/m3/pulls/1160/comments"},"review_comment":{"href":"https://api.github.com/repos/m3db/m3/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/m3db/m3/pulls/1160/commits"},"statuses":{"href":"https://api.github.com/repos/m3db/m3/statuses/f63a8c1c32d0aea961e11402b1e59b12b59670f0"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"robskillington"}}