{"action":"created","comment":{"url":"https://api.github.com/repos/symfony/symfony/pulls/comments/129040231","pull_request_review_id":51773610,"id":129040231,"diff_hunk":"@@ -41,92 +39,87 @@ protected function doClone($var)\n         $a = null;                      // Array cast for nested structures\n         $stub = null;                   // Stub capturing the main properties of an original item value\n                                         // or null if the original value is used directly\n-        $zval = array(                  // Main properties of the current value\n-            'type' => null,\n-            'zval_isref' => null,\n-            'zval_hash' => null,\n-            'array_count' => null,\n-            'object_class' => null,\n-            'object_handle' => null,\n-            'resource_type' => null,\n-        );\n+\n         if (!self::$hashMask) {\n             self::initHashMask();\n         }\n         $hashMask = self::$hashMask;\n         $hashOffset = self::$hashOffset;\n+        $arrayStub = new Stub();\n+        $arrayStub->type = Stub::TYPE_ARRAY;\n \n         for ($i = 0; $i < $len; ++$i) {\n-            $indexed = true;            // Whether the currently iterated array is numerically indexed or not\n-            $j = -1;                    // Position in the currently iterated array\n-            $fromObjCast = array_keys($queue[$i]);\n-            $fromObjCast = array_keys(array_flip($fromObjCast)) !== $fromObjCast;\n-            $refs = $vals = $fromObjCast ? array_values($queue[$i]) : $queue[$i];\n-            foreach ($queue[$i] as $k => $v) {\n-                // $k is the original key\n+            $fromObjCast = \\array_keys($queue[$i]);\n+            $fromObjCast = \\array_keys(\\array_flip($fromObjCast)) !== $fromObjCast;\n+            $refs = $vals = $fromObjCast ? \\array_values($queue[$i]) : $queue[$i];\n+            foreach ($vals as $k => $v) {\n                 // $v is the original value or a stub object in case of hard references\n-                if ($k !== ++$j) {\n-                    $indexed = false;\n-                }\n-                if ($fromObjCast) {\n-                    $k = $j;\n-                }\n-                if ($useExt) {\n-                    $zval = symfony_zval_info($k, $refs);\n-                } else {\n-                    $refs[$k] = $cookie;\n-                    if ($zval['zval_isref'] = $vals[$k] === $cookie) {\n-                        $zval['zval_hash'] = $v instanceof Stub ? spl_object_hash($v) : null;\n-                    }\n-                    $zval['type'] = gettype($v);\n-                }\n-                if ($zval['zval_isref']) {\n+                $refs[$k] = $cookie;\n+                if ($zvalIsRef = $vals[$k] === $cookie) {\n                     $vals[$k] = &$stub;         // Break hard references to make $queue completely\n                     unset($stub);               // independent from the original structure\n-                    if (isset($hardRefs[$zval['zval_hash']])) {\n-                        $vals[$k] = $useExt ? ($v = $hardRefs[$zval['zval_hash']]) : ($refs[$k] = $v);\n+                    if (isset($hardRefs[$v instanceof Stub ? \\spl_object_hash($v) : ''])) {\n+                        $vals[$k] = $refs[$k] = $v;\n                         if ($v->value instanceof Stub && (Stub::TYPE_OBJECT === $v->value->type || Stub::TYPE_RESOURCE === $v->value->type)) {\n                             ++$v->value->refCount;\n                         }\n                         ++$v->refCount;\n                         continue;\n                     }\n+                    $refs[$k] = $vals[$k] = new Stub();\n+                    $refs[$k]->value = $v;\n+                    $h = \\spl_object_hash($refs[$k]);\n+                    $hardRefs[$h] = &$refs[$k];\n+                    $values[$h] = $v;\n+                    $vals[$k]->handle = ++$refsCounter;\n                 }\n                 // Create $stub when the original value $v can not be used directly\n                 // If $v is a nested structure, put that structure in array $a\n-                switch ($zval['type']) {\n-                    case 'string':\n-                        if (isset($v[0]) && !preg_match('//u', $v)) {\n+                switch (true) {","path":"src/Symfony/Component/VarDumper/Cloner/VarCloner.php","position":90,"original_position":90,"commit_id":"5cd7a7509a82a7f39287bb2f3f8b47e75dbf3dce","original_commit_id":"5cd7a7509a82a7f39287bb2f3f8b47e75dbf3dce","user":{"login":"nicolas-grekas","id":243674,"avatar_url":"https://avatars3.githubusercontent.com/u/243674?v=4","gravatar_id":"","url":"https://api.github.com/users/nicolas-grekas","html_url":"https://github.com/nicolas-grekas","followers_url":"https://api.github.com/users/nicolas-grekas/followers","following_url":"https://api.github.com/users/nicolas-grekas/following{/other_user}","gists_url":"https://api.github.com/users/nicolas-grekas/gists{/gist_id}","starred_url":"https://api.github.com/users/nicolas-grekas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicolas-grekas/subscriptions","organizations_url":"https://api.github.com/users/nicolas-grekas/orgs","repos_url":"https://api.github.com/users/nicolas-grekas/repos","events_url":"https://api.github.com/users/nicolas-grekas/events{/privacy}","received_events_url":"https://api.github.com/users/nicolas-grekas/received_events","type":"User","site_admin":false},"body":"Using root namespaced `\\is_*()` function is noticeably faster that comparing the string result of `gettype()` on PHP 7.\r\nSince this is a hot path, I've added a `\\` to all root functions in the loop.","created_at":"2017-07-24T13:50:36Z","updated_at":"2017-07-24T13:50:36Z","html_url":"https://github.com/symfony/symfony/pull/23644#discussion_r129040231","pull_request_url":"https://api.github.com/repos/symfony/symfony/pulls/23644","_links":{"self":{"href":"https://api.github.com/repos/symfony/symfony/pulls/comments/129040231"},"html":{"href":"https://github.com/symfony/symfony/pull/23644#discussion_r129040231"},"pull_request":{"href":"https://api.github.com/repos/symfony/symfony/pulls/23644"}}},"pull_request":{"url":"https://api.github.com/repos/symfony/symfony/pulls/23644","id":132037264,"html_url":"https://github.com/symfony/symfony/pull/23644","diff_url":"https://github.com/symfony/symfony/pull/23644.diff","patch_url":"https://github.com/symfony/symfony/pull/23644.patch","issue_url":"https://api.github.com/repos/symfony/symfony/issues/23644","number":23644,"state":"open","locked":false,"title":"[VarDumper] Dont use Stub objects for arrays - lower GC pressure","user":{"login":"nicolas-grekas","id":243674,"avatar_url":"https://avatars3.githubusercontent.com/u/243674?v=4","gravatar_id":"","url":"https://api.github.com/users/nicolas-grekas","html_url":"https://github.com/nicolas-grekas","followers_url":"https://api.github.com/users/nicolas-grekas/followers","following_url":"https://api.github.com/users/nicolas-grekas/following{/other_user}","gists_url":"https://api.github.com/users/nicolas-grekas/gists{/gist_id}","starred_url":"https://api.github.com/users/nicolas-grekas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicolas-grekas/subscriptions","organizations_url":"https://api.github.com/users/nicolas-grekas/orgs","repos_url":"https://api.github.com/users/nicolas-grekas/repos","events_url":"https://api.github.com/users/nicolas-grekas/events{/privacy}","received_events_url":"https://api.github.com/users/nicolas-grekas/received_events","type":"User","site_admin":false},"body":"| Q             | A\r\n| ------------- | ---\r\n| Branch?       | 3.3\r\n| Bug fix?      | yes\r\n| New feature?  | no\r\n| BC breaks?    | no\r\n| Deprecations? | no\r\n| Tests pass?   | yes\r\n| Fixed tickets | #23644\r\n| License       | MIT\r\n| Doc PR        | -\r\n\r\nSeveral recent profiles have shown that VarDumper triggers the garbage collector quite often, leading to high CPU usage. The reason for this is that internally, VarCloner creates one Stub object per array+object+resource.\r\n\r\nThis PR removes the need for Stub objects for each arrays, replacing them with stub arrays. This should almost remove the GC pressure, since the number of Stub objects now has the same magnitude than the number of dumped objects.\r\n\r\nMeanwhile, this PR removes any use of the `symfony_debug` extension, which is mostly useless anyway. This helps make the code simpler (really :) ), thus helps maintenance (eg merging up to master.)\r\n\r\nI also changed the values of the constants defined in the Stub class, and removed the corresponding Data::mapStubConsts() method. Since the serialized format has changed (and we have to do it as there is no other way to fix this GC issue), there is no need to keep any sort of compat mapping there.\r\n\r\nCan be reviewed ignoring whitespaces:\r\nhttps://github.com/symfony/symfony/pull/23644/files?w=1","created_at":"2017-07-24T12:23:09Z","updated_at":"2017-07-24T13:50:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0a2f1062d586c3f68e80892114d8da487a237fb3","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":{"url":"https://api.github.com/repos/symfony/symfony/milestones/16","html_url":"https://github.com/symfony/symfony/milestone/16","labels_url":"https://api.github.com/repos/symfony/symfony/milestones/16/labels","id":2180800,"number":16,"title":"3.3","description":"https://symfony.com/roadmap?version=3.3#checker","creator":{"login":"xabbuh","id":1957048,"avatar_url":"https://avatars0.githubusercontent.com/u/1957048?v=4","gravatar_id":"","url":"https://api.github.com/users/xabbuh","html_url":"https://github.com/xabbuh","followers_url":"https://api.github.com/users/xabbuh/followers","following_url":"https://api.github.com/users/xabbuh/following{/other_user}","gists_url":"https://api.github.com/users/xabbuh/gists{/gist_id}","starred_url":"https://api.github.com/users/xabbuh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xabbuh/subscriptions","organizations_url":"https://api.github.com/users/xabbuh/orgs","repos_url":"https://api.github.com/users/xabbuh/repos","events_url":"https://api.github.com/users/xabbuh/events{/privacy}","received_events_url":"https://api.github.com/users/xabbuh/received_events","type":"User","site_admin":false},"open_issues":6,"closed_issues":575,"state":"open","created_at":"2016-12-07T08:48:45Z","updated_at":"2017-07-24T12:23:09Z","due_on":"2018-01-31T08:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/symfony/symfony/pulls/23644/commits","review_comments_url":"https://api.github.com/repos/symfony/symfony/pulls/23644/comments","review_comment_url":"https://api.github.com/repos/symfony/symfony/pulls/comments{/number}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/23644/comments","statuses_url":"https://api.github.com/repos/symfony/symfony/statuses/5cd7a7509a82a7f39287bb2f3f8b47e75dbf3dce","head":{"label":"nicolas-grekas:var-array","ref":"var-array","sha":"5cd7a7509a82a7f39287bb2f3f8b47e75dbf3dce","user":{"login":"nicolas-grekas","id":243674,"avatar_url":"https://avatars3.githubusercontent.com/u/243674?v=4","gravatar_id":"","url":"https://api.github.com/users/nicolas-grekas","html_url":"https://github.com/nicolas-grekas","followers_url":"https://api.github.com/users/nicolas-grekas/followers","following_url":"https://api.github.com/users/nicolas-grekas/following{/other_user}","gists_url":"https://api.github.com/users/nicolas-grekas/gists{/gist_id}","starred_url":"https://api.github.com/users/nicolas-grekas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicolas-grekas/subscriptions","organizations_url":"https://api.github.com/users/nicolas-grekas/orgs","repos_url":"https://api.github.com/users/nicolas-grekas/repos","events_url":"https://api.github.com/users/nicolas-grekas/events{/privacy}","received_events_url":"https://api.github.com/users/nicolas-grekas/received_events","type":"User","site_admin":false},"repo":{"id":15110606,"name":"symfony","full_name":"nicolas-grekas/symfony","owner":{"login":"nicolas-grekas","id":243674,"avatar_url":"https://avatars3.githubusercontent.com/u/243674?v=4","gravatar_id":"","url":"https://api.github.com/users/nicolas-grekas","html_url":"https://github.com/nicolas-grekas","followers_url":"https://api.github.com/users/nicolas-grekas/followers","following_url":"https://api.github.com/users/nicolas-grekas/following{/other_user}","gists_url":"https://api.github.com/users/nicolas-grekas/gists{/gist_id}","starred_url":"https://api.github.com/users/nicolas-grekas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicolas-grekas/subscriptions","organizations_url":"https://api.github.com/users/nicolas-grekas/orgs","repos_url":"https://api.github.com/users/nicolas-grekas/repos","events_url":"https://api.github.com/users/nicolas-grekas/events{/privacy}","received_events_url":"https://api.github.com/users/nicolas-grekas/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nicolas-grekas/symfony","description":"The Symfony PHP framework","fork":true,"url":"https://api.github.com/repos/nicolas-grekas/symfony","forks_url":"https://api.github.com/repos/nicolas-grekas/symfony/forks","keys_url":"https://api.github.com/repos/nicolas-grekas/symfony/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nicolas-grekas/symfony/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nicolas-grekas/symfony/teams","hooks_url":"https://api.github.com/repos/nicolas-grekas/symfony/hooks","issue_events_url":"https://api.github.com/repos/nicolas-grekas/symfony/issues/events{/number}","events_url":"https://api.github.com/repos/nicolas-grekas/symfony/events","assignees_url":"https://api.github.com/repos/nicolas-grekas/symfony/assignees{/user}","branches_url":"https://api.github.com/repos/nicolas-grekas/symfony/branches{/branch}","tags_url":"https://api.github.com/repos/nicolas-grekas/symfony/tags","blobs_url":"https://api.github.com/repos/nicolas-grekas/symfony/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nicolas-grekas/symfony/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nicolas-grekas/symfony/git/refs{/sha}","trees_url":"https://api.github.com/repos/nicolas-grekas/symfony/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nicolas-grekas/symfony/statuses/{sha}","languages_url":"https://api.github.com/repos/nicolas-grekas/symfony/languages","stargazers_url":"https://api.github.com/repos/nicolas-grekas/symfony/stargazers","contributors_url":"https://api.github.com/repos/nicolas-grekas/symfony/contributors","subscribers_url":"https://api.github.com/repos/nicolas-grekas/symfony/subscribers","subscription_url":"https://api.github.com/repos/nicolas-grekas/symfony/subscription","commits_url":"https://api.github.com/repos/nicolas-grekas/symfony/commits{/sha}","git_commits_url":"https://api.github.com/repos/nicolas-grekas/symfony/git/commits{/sha}","comments_url":"https://api.github.com/repos/nicolas-grekas/symfony/comments{/number}","issue_comment_url":"https://api.github.com/repos/nicolas-grekas/symfony/issues/comments{/number}","contents_url":"https://api.github.com/repos/nicolas-grekas/symfony/contents/{+path}","compare_url":"https://api.github.com/repos/nicolas-grekas/symfony/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nicolas-grekas/symfony/merges","archive_url":"https://api.github.com/repos/nicolas-grekas/symfony/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nicolas-grekas/symfony/downloads","issues_url":"https://api.github.com/repos/nicolas-grekas/symfony/issues{/number}","pulls_url":"https://api.github.com/repos/nicolas-grekas/symfony/pulls{/number}","milestones_url":"https://api.github.com/repos/nicolas-grekas/symfony/milestones{/number}","notifications_url":"https://api.github.com/repos/nicolas-grekas/symfony/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nicolas-grekas/symfony/labels{/name}","releases_url":"https://api.github.com/repos/nicolas-grekas/symfony/releases{/id}","deployments_url":"https://api.github.com/repos/nicolas-grekas/symfony/deployments","created_at":"2013-12-11T15:13:36Z","updated_at":"2015-04-11T08:00:47Z","pushed_at":"2017-07-24T13:45:34Z","git_url":"git://github.com/nicolas-grekas/symfony.git","ssh_url":"git@github.com:nicolas-grekas/symfony.git","clone_url":"https://github.com/nicolas-grekas/symfony.git","svn_url":"https://github.com/nicolas-grekas/symfony","homepage":"symfony.com","size":95708,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"symfony:3.3","ref":"3.3","sha":"a00b05e3edb0ba7b6b78b1a43d82cf339584898b","user":{"login":"symfony","id":143937,"avatar_url":"https://avatars3.githubusercontent.com/u/143937?v=4","gravatar_id":"","url":"https://api.github.com/users/symfony","html_url":"https://github.com/symfony","followers_url":"https://api.github.com/users/symfony/followers","following_url":"https://api.github.com/users/symfony/following{/other_user}","gists_url":"https://api.github.com/users/symfony/gists{/gist_id}","starred_url":"https://api.github.com/users/symfony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symfony/subscriptions","organizations_url":"https://api.github.com/users/symfony/orgs","repos_url":"https://api.github.com/users/symfony/repos","events_url":"https://api.github.com/users/symfony/events{/privacy}","received_events_url":"https://api.github.com/users/symfony/received_events","type":"Organization","site_admin":false},"repo":{"id":458058,"name":"symfony","full_name":"symfony/symfony","owner":{"login":"symfony","id":143937,"avatar_url":"https://avatars3.githubusercontent.com/u/143937?v=4","gravatar_id":"","url":"https://api.github.com/users/symfony","html_url":"https://github.com/symfony","followers_url":"https://api.github.com/users/symfony/followers","following_url":"https://api.github.com/users/symfony/following{/other_user}","gists_url":"https://api.github.com/users/symfony/gists{/gist_id}","starred_url":"https://api.github.com/users/symfony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symfony/subscriptions","organizations_url":"https://api.github.com/users/symfony/orgs","repos_url":"https://api.github.com/users/symfony/repos","events_url":"https://api.github.com/users/symfony/events{/privacy}","received_events_url":"https://api.github.com/users/symfony/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/symfony/symfony","description":"The Symfony PHP framework","fork":false,"url":"https://api.github.com/repos/symfony/symfony","forks_url":"https://api.github.com/repos/symfony/symfony/forks","keys_url":"https://api.github.com/repos/symfony/symfony/keys{/key_id}","collaborators_url":"https://api.github.com/repos/symfony/symfony/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/symfony/symfony/teams","hooks_url":"https://api.github.com/repos/symfony/symfony/hooks","issue_events_url":"https://api.github.com/repos/symfony/symfony/issues/events{/number}","events_url":"https://api.github.com/repos/symfony/symfony/events","assignees_url":"https://api.github.com/repos/symfony/symfony/assignees{/user}","branches_url":"https://api.github.com/repos/symfony/symfony/branches{/branch}","tags_url":"https://api.github.com/repos/symfony/symfony/tags","blobs_url":"https://api.github.com/repos/symfony/symfony/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/symfony/symfony/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/symfony/symfony/git/refs{/sha}","trees_url":"https://api.github.com/repos/symfony/symfony/git/trees{/sha}","statuses_url":"https://api.github.com/repos/symfony/symfony/statuses/{sha}","languages_url":"https://api.github.com/repos/symfony/symfony/languages","stargazers_url":"https://api.github.com/repos/symfony/symfony/stargazers","contributors_url":"https://api.github.com/repos/symfony/symfony/contributors","subscribers_url":"https://api.github.com/repos/symfony/symfony/subscribers","subscription_url":"https://api.github.com/repos/symfony/symfony/subscription","commits_url":"https://api.github.com/repos/symfony/symfony/commits{/sha}","git_commits_url":"https://api.github.com/repos/symfony/symfony/git/commits{/sha}","comments_url":"https://api.github.com/repos/symfony/symfony/comments{/number}","issue_comment_url":"https://api.github.com/repos/symfony/symfony/issues/comments{/number}","contents_url":"https://api.github.com/repos/symfony/symfony/contents/{+path}","compare_url":"https://api.github.com/repos/symfony/symfony/compare/{base}...{head}","merges_url":"https://api.github.com/repos/symfony/symfony/merges","archive_url":"https://api.github.com/repos/symfony/symfony/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/symfony/symfony/downloads","issues_url":"https://api.github.com/repos/symfony/symfony/issues{/number}","pulls_url":"https://api.github.com/repos/symfony/symfony/pulls{/number}","milestones_url":"https://api.github.com/repos/symfony/symfony/milestones{/number}","notifications_url":"https://api.github.com/repos/symfony/symfony/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/symfony/symfony/labels{/name}","releases_url":"https://api.github.com/repos/symfony/symfony/releases{/id}","deployments_url":"https://api.github.com/repos/symfony/symfony/deployments","created_at":"2010-01-04T14:21:21Z","updated_at":"2017-07-24T09:25:15Z","pushed_at":"2017-07-24T13:45:41Z","git_url":"git://github.com/symfony/symfony.git","ssh_url":"git@github.com:symfony/symfony.git","clone_url":"https://github.com/symfony/symfony.git","svn_url":"https://github.com/symfony/symfony","homepage":"symfony.com","size":99656,"stargazers_count":14893,"watchers_count":14893,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":5615,"mirror_url":null,"open_issues_count":827,"forks":5615,"open_issues":827,"watchers":14893,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/symfony/symfony/pulls/23644"},"html":{"href":"https://github.com/symfony/symfony/pull/23644"},"issue":{"href":"https://api.github.com/repos/symfony/symfony/issues/23644"},"comments":{"href":"https://api.github.com/repos/symfony/symfony/issues/23644/comments"},"review_comments":{"href":"https://api.github.com/repos/symfony/symfony/pulls/23644/comments"},"review_comment":{"href":"https://api.github.com/repos/symfony/symfony/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/symfony/symfony/pulls/23644/commits"},"statuses":{"href":"https://api.github.com/repos/symfony/symfony/statuses/5cd7a7509a82a7f39287bb2f3f8b47e75dbf3dce"}}}}
{"actor":{"display_login":"nicolas-grekas"}}