{"action":"created","comment":{"url":"https://api.github.com/repos/pinojs/pino/pulls/comments/205781955","pull_request_review_id":141123443,"id":205781955,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNTc4MTk1NQ==","diff_hunk":"@@ -82,26 +83,41 @@ function asJson (obj, msg, num, time) {\n   // we need the child bindings added to the output first so instance logged\n   // objects can take precedence when JSON.parse-ing the resulting log line\n   data = data + chindings\n+\n+  if (hasObj === false) return data + end\n+\n+  const notHasOwnProperty = obj.hasOwnProperty === undefined\n+\n+  if (objError === true) {\n+    data += ',\"type\":\"Error\",\"stack\":' + stringify(obj.stack)\n+  }\n+\n+  // if global serializer is set, call it first\n+  if (serializers[wildcardGsym]) {\n+    obj = serializers[wildcardGsym](obj)\n+  }\n+\n+  var hasSerializableKeys = false\n+  for (var szKey in serializers) {\n+    if (szKey in obj) hasSerializableKeys = true\n+  }","path":"lib/tools.js","position":null,"original_position":38,"commit_id":"e9f56d581a2219f9af2057751518137f02f3b0dd","original_commit_id":"f416818938b7f74d6b9c7d66058590e89fd0f7a5","user":{"login":"mcollina","id":52195,"node_id":"MDQ6VXNlcjUyMTk1","avatar_url":"https://avatars0.githubusercontent.com/u/52195?v=4","gravatar_id":"","url":"https://api.github.com/users/mcollina","html_url":"https://github.com/mcollina","followers_url":"https://api.github.com/users/mcollina/followers","following_url":"https://api.github.com/users/mcollina/following{/other_user}","gists_url":"https://api.github.com/users/mcollina/gists{/gist_id}","starred_url":"https://api.github.com/users/mcollina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcollina/subscriptions","organizations_url":"https://api.github.com/users/mcollina/orgs","repos_url":"https://api.github.com/users/mcollina/repos","events_url":"https://api.github.com/users/mcollina/events{/privacy}","received_events_url":"https://api.github.com/users/mcollina/received_events","type":"User","site_admin":false},"body":"There is no need to do that for every child instantiation. The vast majority of the time child loggers do not have serializers, so we can reuse the function that was already there.","created_at":"2018-07-27T13:58:55Z","updated_at":"2018-07-27T13:58:56Z","html_url":"https://github.com/pinojs/pino/pull/463#discussion_r205781955","pull_request_url":"https://api.github.com/repos/pinojs/pino/pulls/463","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/pinojs/pino/pulls/comments/205781955"},"html":{"href":"https://github.com/pinojs/pino/pull/463#discussion_r205781955"},"pull_request":{"href":"https://api.github.com/repos/pinojs/pino/pulls/463"}},"in_reply_to_id":205633984},"pull_request":{"url":"https://api.github.com/repos/pinojs/pino/pulls/463","id":204259135,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA0MjU5MTM1","html_url":"https://github.com/pinojs/pino/pull/463","diff_url":"https://github.com/pinojs/pino/pull/463.diff","patch_url":"https://github.com/pinojs/pino/pull/463.patch","issue_url":"https://api.github.com/repos/pinojs/pino/issues/463","number":463,"state":"open","locked":false,"title":"optimizing deep objects","user":{"login":"davidmarkclements","id":1190716,"node_id":"MDQ6VXNlcjExOTA3MTY=","avatar_url":"https://avatars1.githubusercontent.com/u/1190716?v=4","gravatar_id":"","url":"https://api.github.com/users/davidmarkclements","html_url":"https://github.com/davidmarkclements","followers_url":"https://api.github.com/users/davidmarkclements/followers","following_url":"https://api.github.com/users/davidmarkclements/following{/other_user}","gists_url":"https://api.github.com/users/davidmarkclements/gists{/gist_id}","starred_url":"https://api.github.com/users/davidmarkclements/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidmarkclements/subscriptions","organizations_url":"https://api.github.com/users/davidmarkclements/orgs","repos_url":"https://api.github.com/users/davidmarkclements/repos","events_url":"https://api.github.com/users/davidmarkclements/events{/privacy}","received_events_url":"https://api.github.com/users/davidmarkclements/received_events","type":"User","site_admin":false},"body":"Our deep objects have become slow (in both v4 and v5, node 8 and 10). This PR is an on-going attempt to address that, but it's going to mean making hard  trade off decisions – which we'll need consensus on.\r\n\r\nThere's actually two optimizations here, one general and one that creates a fast path for objects that have no serializable properties.\r\n\r\nThe first wraps a try/catch around JSON.stringify, this gives around a ~15% improvement on deep objects. The trade-off of this approach is it opens up an edge case, if an object mutates itself in toJSON methods but has a circular reference that causes a throw it may have mutated parts of itself before throwing, and the following reserialization after a catch could give undesired results. This is why we had to not do this, since `pino-noir` uses that exact approach. However in v5 we're using fast-redact, which doesn't - and that approach is something we should recommend against, and is unlikely to be used outside of pino-noir. \r\n\r\nThe second optimization checks for keys in the object that match serializers, if there are no serializers it will use JSON.stringify on the entire object, and then chop of the starting `{` and ending `}`. \r\nThis gives a ~25% improvement over current deep object benchmarks. \r\n\r\nHowever... the trade off of this second optimization is that it **adds** ~25% onto our small object benchmarks. Which are still faster than everything even with that.\r\n\r\nLet's discuss.","created_at":"2018-07-26T20:34:16Z","updated_at":"2018-07-27T13:58:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4cd77c1c45a66c92c6ce4ad0a2b20ea43ed412fc","assignee":null,"assignees":[],"requested_reviewers":[{"login":"jsumners","id":321201,"node_id":"MDQ6VXNlcjMyMTIwMQ==","avatar_url":"https://avatars1.githubusercontent.com/u/321201?v=4","gravatar_id":"","url":"https://api.github.com/users/jsumners","html_url":"https://github.com/jsumners","followers_url":"https://api.github.com/users/jsumners/followers","following_url":"https://api.github.com/users/jsumners/following{/other_user}","gists_url":"https://api.github.com/users/jsumners/gists{/gist_id}","starred_url":"https://api.github.com/users/jsumners/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsumners/subscriptions","organizations_url":"https://api.github.com/users/jsumners/orgs","repos_url":"https://api.github.com/users/jsumners/repos","events_url":"https://api.github.com/users/jsumners/events{/privacy}","received_events_url":"https://api.github.com/users/jsumners/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/pinojs/pino/pulls/463/commits","review_comments_url":"https://api.github.com/repos/pinojs/pino/pulls/463/comments","review_comment_url":"https://api.github.com/repos/pinojs/pino/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pinojs/pino/issues/463/comments","statuses_url":"https://api.github.com/repos/pinojs/pino/statuses/e9f56d581a2219f9af2057751518137f02f3b0dd","head":{"label":"pinojs:fast-path-for-non-serializable-objects","ref":"fast-path-for-non-serializable-objects","sha":"e9f56d581a2219f9af2057751518137f02f3b0dd","user":{"login":"pinojs","id":23048140,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIzMDQ4MTQw","avatar_url":"https://avatars1.githubusercontent.com/u/23048140?v=4","gravatar_id":"","url":"https://api.github.com/users/pinojs","html_url":"https://github.com/pinojs","followers_url":"https://api.github.com/users/pinojs/followers","following_url":"https://api.github.com/users/pinojs/following{/other_user}","gists_url":"https://api.github.com/users/pinojs/gists{/gist_id}","starred_url":"https://api.github.com/users/pinojs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pinojs/subscriptions","organizations_url":"https://api.github.com/users/pinojs/orgs","repos_url":"https://api.github.com/users/pinojs/repos","events_url":"https://api.github.com/users/pinojs/events{/privacy}","received_events_url":"https://api.github.com/users/pinojs/received_events","type":"Organization","site_admin":false},"repo":{"id":51840802,"node_id":"MDEwOlJlcG9zaXRvcnk1MTg0MDgwMg==","name":"pino","full_name":"pinojs/pino","owner":{"login":"pinojs","id":23048140,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIzMDQ4MTQw","avatar_url":"https://avatars1.githubusercontent.com/u/23048140?v=4","gravatar_id":"","url":"https://api.github.com/users/pinojs","html_url":"https://github.com/pinojs","followers_url":"https://api.github.com/users/pinojs/followers","following_url":"https://api.github.com/users/pinojs/following{/other_user}","gists_url":"https://api.github.com/users/pinojs/gists{/gist_id}","starred_url":"https://api.github.com/users/pinojs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pinojs/subscriptions","organizations_url":"https://api.github.com/users/pinojs/orgs","repos_url":"https://api.github.com/users/pinojs/repos","events_url":"https://api.github.com/users/pinojs/events{/privacy}","received_events_url":"https://api.github.com/users/pinojs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pinojs/pino","description":"🌲 super fast, all natural json logger 🌲","fork":false,"url":"https://api.github.com/repos/pinojs/pino","forks_url":"https://api.github.com/repos/pinojs/pino/forks","keys_url":"https://api.github.com/repos/pinojs/pino/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pinojs/pino/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pinojs/pino/teams","hooks_url":"https://api.github.com/repos/pinojs/pino/hooks","issue_events_url":"https://api.github.com/repos/pinojs/pino/issues/events{/number}","events_url":"https://api.github.com/repos/pinojs/pino/events","assignees_url":"https://api.github.com/repos/pinojs/pino/assignees{/user}","branches_url":"https://api.github.com/repos/pinojs/pino/branches{/branch}","tags_url":"https://api.github.com/repos/pinojs/pino/tags","blobs_url":"https://api.github.com/repos/pinojs/pino/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pinojs/pino/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pinojs/pino/git/refs{/sha}","trees_url":"https://api.github.com/repos/pinojs/pino/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pinojs/pino/statuses/{sha}","languages_url":"https://api.github.com/repos/pinojs/pino/languages","stargazers_url":"https://api.github.com/repos/pinojs/pino/stargazers","contributors_url":"https://api.github.com/repos/pinojs/pino/contributors","subscribers_url":"https://api.github.com/repos/pinojs/pino/subscribers","subscription_url":"https://api.github.com/repos/pinojs/pino/subscription","commits_url":"https://api.github.com/repos/pinojs/pino/commits{/sha}","git_commits_url":"https://api.github.com/repos/pinojs/pino/git/commits{/sha}","comments_url":"https://api.github.com/repos/pinojs/pino/comments{/number}","issue_comment_url":"https://api.github.com/repos/pinojs/pino/issues/comments{/number}","contents_url":"https://api.github.com/repos/pinojs/pino/contents/{+path}","compare_url":"https://api.github.com/repos/pinojs/pino/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pinojs/pino/merges","archive_url":"https://api.github.com/repos/pinojs/pino/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pinojs/pino/downloads","issues_url":"https://api.github.com/repos/pinojs/pino/issues{/number}","pulls_url":"https://api.github.com/repos/pinojs/pino/pulls{/number}","milestones_url":"https://api.github.com/repos/pinojs/pino/milestones{/number}","notifications_url":"https://api.github.com/repos/pinojs/pino/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pinojs/pino/labels{/name}","releases_url":"https://api.github.com/repos/pinojs/pino/releases{/id}","deployments_url":"https://api.github.com/repos/pinojs/pino/deployments","created_at":"2016-02-16T14:14:29Z","updated_at":"2018-07-27T11:14:56Z","pushed_at":"2018-07-27T13:56:37Z","git_url":"git://github.com/pinojs/pino.git","ssh_url":"git@github.com:pinojs/pino.git","clone_url":"https://github.com/pinojs/pino.git","svn_url":"https://github.com/pinojs/pino","homepage":"http://getpino.io","size":1587,"stargazers_count":2869,"watchers_count":2869,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":161,"mirror_url":null,"archived":false,"open_issues_count":15,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":161,"open_issues":15,"watchers":2869,"default_branch":"master"}},"base":{"label":"pinojs:next-major","ref":"next-major","sha":"d5a380de015d6650b9f4f0a2f2df9d2c47806a6b","user":{"login":"pinojs","id":23048140,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIzMDQ4MTQw","avatar_url":"https://avatars1.githubusercontent.com/u/23048140?v=4","gravatar_id":"","url":"https://api.github.com/users/pinojs","html_url":"https://github.com/pinojs","followers_url":"https://api.github.com/users/pinojs/followers","following_url":"https://api.github.com/users/pinojs/following{/other_user}","gists_url":"https://api.github.com/users/pinojs/gists{/gist_id}","starred_url":"https://api.github.com/users/pinojs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pinojs/subscriptions","organizations_url":"https://api.github.com/users/pinojs/orgs","repos_url":"https://api.github.com/users/pinojs/repos","events_url":"https://api.github.com/users/pinojs/events{/privacy}","received_events_url":"https://api.github.com/users/pinojs/received_events","type":"Organization","site_admin":false},"repo":{"id":51840802,"node_id":"MDEwOlJlcG9zaXRvcnk1MTg0MDgwMg==","name":"pino","full_name":"pinojs/pino","owner":{"login":"pinojs","id":23048140,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIzMDQ4MTQw","avatar_url":"https://avatars1.githubusercontent.com/u/23048140?v=4","gravatar_id":"","url":"https://api.github.com/users/pinojs","html_url":"https://github.com/pinojs","followers_url":"https://api.github.com/users/pinojs/followers","following_url":"https://api.github.com/users/pinojs/following{/other_user}","gists_url":"https://api.github.com/users/pinojs/gists{/gist_id}","starred_url":"https://api.github.com/users/pinojs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pinojs/subscriptions","organizations_url":"https://api.github.com/users/pinojs/orgs","repos_url":"https://api.github.com/users/pinojs/repos","events_url":"https://api.github.com/users/pinojs/events{/privacy}","received_events_url":"https://api.github.com/users/pinojs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pinojs/pino","description":"🌲 super fast, all natural json logger 🌲","fork":false,"url":"https://api.github.com/repos/pinojs/pino","forks_url":"https://api.github.com/repos/pinojs/pino/forks","keys_url":"https://api.github.com/repos/pinojs/pino/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pinojs/pino/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pinojs/pino/teams","hooks_url":"https://api.github.com/repos/pinojs/pino/hooks","issue_events_url":"https://api.github.com/repos/pinojs/pino/issues/events{/number}","events_url":"https://api.github.com/repos/pinojs/pino/events","assignees_url":"https://api.github.com/repos/pinojs/pino/assignees{/user}","branches_url":"https://api.github.com/repos/pinojs/pino/branches{/branch}","tags_url":"https://api.github.com/repos/pinojs/pino/tags","blobs_url":"https://api.github.com/repos/pinojs/pino/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pinojs/pino/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pinojs/pino/git/refs{/sha}","trees_url":"https://api.github.com/repos/pinojs/pino/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pinojs/pino/statuses/{sha}","languages_url":"https://api.github.com/repos/pinojs/pino/languages","stargazers_url":"https://api.github.com/repos/pinojs/pino/stargazers","contributors_url":"https://api.github.com/repos/pinojs/pino/contributors","subscribers_url":"https://api.github.com/repos/pinojs/pino/subscribers","subscription_url":"https://api.github.com/repos/pinojs/pino/subscription","commits_url":"https://api.github.com/repos/pinojs/pino/commits{/sha}","git_commits_url":"https://api.github.com/repos/pinojs/pino/git/commits{/sha}","comments_url":"https://api.github.com/repos/pinojs/pino/comments{/number}","issue_comment_url":"https://api.github.com/repos/pinojs/pino/issues/comments{/number}","contents_url":"https://api.github.com/repos/pinojs/pino/contents/{+path}","compare_url":"https://api.github.com/repos/pinojs/pino/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pinojs/pino/merges","archive_url":"https://api.github.com/repos/pinojs/pino/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pinojs/pino/downloads","issues_url":"https://api.github.com/repos/pinojs/pino/issues{/number}","pulls_url":"https://api.github.com/repos/pinojs/pino/pulls{/number}","milestones_url":"https://api.github.com/repos/pinojs/pino/milestones{/number}","notifications_url":"https://api.github.com/repos/pinojs/pino/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pinojs/pino/labels{/name}","releases_url":"https://api.github.com/repos/pinojs/pino/releases{/id}","deployments_url":"https://api.github.com/repos/pinojs/pino/deployments","created_at":"2016-02-16T14:14:29Z","updated_at":"2018-07-27T11:14:56Z","pushed_at":"2018-07-27T13:56:37Z","git_url":"git://github.com/pinojs/pino.git","ssh_url":"git@github.com:pinojs/pino.git","clone_url":"https://github.com/pinojs/pino.git","svn_url":"https://github.com/pinojs/pino","homepage":"http://getpino.io","size":1587,"stargazers_count":2869,"watchers_count":2869,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":161,"mirror_url":null,"archived":false,"open_issues_count":15,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":161,"open_issues":15,"watchers":2869,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pinojs/pino/pulls/463"},"html":{"href":"https://github.com/pinojs/pino/pull/463"},"issue":{"href":"https://api.github.com/repos/pinojs/pino/issues/463"},"comments":{"href":"https://api.github.com/repos/pinojs/pino/issues/463/comments"},"review_comments":{"href":"https://api.github.com/repos/pinojs/pino/pulls/463/comments"},"review_comment":{"href":"https://api.github.com/repos/pinojs/pino/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pinojs/pino/pulls/463/commits"},"statuses":{"href":"https://api.github.com/repos/pinojs/pino/statuses/e9f56d581a2219f9af2057751518137f02f3b0dd"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"mcollina"}}