{"action":"created","comment":{"url":"https://api.github.com/repos/symfony/symfony/pulls/comments/70302650","id":70302650,"diff_hunk":"@@ -0,0 +1,137 @@\n+<?php\n+\n+/*\n+ * This file is part of the Symfony package.\n+ *\n+ * (c) Fabien Potencier <fabien@symfony.com>\n+ *\n+ * For the full copyright and license information, please view the LICENSE\n+ * file that was distributed with this source code.\n+ */\n+\n+namespace Symfony\\Bundle\\FrameworkBundle\\CacheWarmer;\n+\n+use Symfony\\Component\\Config\\ConfigCacheFactoryInterface;\n+use Symfony\\Component\\Config\\ConfigCacheInterface;\n+use Symfony\\Component\\Config\\Resource\\FileResource;\n+use Symfony\\Component\\Filesystem\\Filesystem;\n+use Symfony\\Component\\HttpFoundation\\Request;\n+use Symfony\\Component\\HttpKernel\\CacheWarmer\\CacheWarmerInterface;\n+use Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface;\n+use Symfony\\Component\\HttpKernel\\ControllerMetadata\\ControllerMetadataFactoryInterface;\n+use Symfony\\Component\\HttpKernel\\ControllerMetadata\\ControllerMetadataUtil;\n+use Symfony\\Component\\Routing\\Route;\n+use Symfony\\Component\\Routing\\RouterInterface;\n+\n+/**\n+ * Generates the cache for controller metadata.\n+ *\n+ * @author Iltar van der Berg <kjarli@gmail.com>\n+ */\n+final class ControllerMetadataCacheWarmer implements CacheWarmerInterface\n+{\n+    private $router;\n+    private $controllerResolver;\n+    private $controllerMetadataFactory;\n+    private $configCacheFactory;\n+    private $cacheFile;\n+\n+    public function __construct(RouterInterface $router, ControllerResolverInterface $controllerResolver, ConfigCacheFactoryInterface $configCacheFactory, ControllerMetadataFactoryInterface $controllerMetadataFactory, $cacheFile)\n+    {\n+        $this->router = $router;\n+        $this->controllerResolver = $controllerResolver;\n+        $this->configCacheFactory = $configCacheFactory;\n+        $this->controllerMetadataFactory = $controllerMetadataFactory;","path":"src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ControllerMetadataCacheWarmer.php","position":44,"original_position":44,"commit_id":"64668bebc04cfc8955a7cf7e5e0c80ca3442abbf","original_commit_id":"64668bebc04cfc8955a7cf7e5e0c80ca3442abbf","user":{"login":"bhavin-nakrani","id":14334368,"avatar_url":"https://avatars.githubusercontent.com/u/14334368?v=3","gravatar_id":"","url":"https://api.github.com/users/bhavin-nakrani","html_url":"https://github.com/bhavin-nakrani","followers_url":"https://api.github.com/users/bhavin-nakrani/followers","following_url":"https://api.github.com/users/bhavin-nakrani/following{/other_user}","gists_url":"https://api.github.com/users/bhavin-nakrani/gists{/gist_id}","starred_url":"https://api.github.com/users/bhavin-nakrani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bhavin-nakrani/subscriptions","organizations_url":"https://api.github.com/users/bhavin-nakrani/orgs","repos_url":"https://api.github.com/users/bhavin-nakrani/repos","events_url":"https://api.github.com/users/bhavin-nakrani/events{/privacy}","received_events_url":"https://api.github.com/users/bhavin-nakrani/received_events","type":"User","site_admin":false},"body":"It should be like\r\n`\r\n$this->router                                  = $router;\r\n$this->controllerResolver               = $controllerResolver;\r\n$this->configCacheFactory            = $configCacheFactory;\r\n$this->controllerMetadataFactory  = $controllerMetadataFactory;\r\n`","created_at":"2016-07-11T17:40:26Z","updated_at":"2016-07-11T17:40:26Z","html_url":"https://github.com/symfony/symfony/pull/19338#discussion_r70302650","pull_request_url":"https://api.github.com/repos/symfony/symfony/pulls/19338","_links":{"self":{"href":"https://api.github.com/repos/symfony/symfony/pulls/comments/70302650"},"html":{"href":"https://github.com/symfony/symfony/pull/19338#discussion_r70302650"},"pull_request":{"href":"https://api.github.com/repos/symfony/symfony/pulls/19338"}}},"pull_request":{"url":"https://api.github.com/repos/symfony/symfony/pulls/19338","id":76965882,"html_url":"https://github.com/symfony/symfony/pull/19338","diff_url":"https://github.com/symfony/symfony/pull/19338.diff","patch_url":"https://github.com/symfony/symfony/pull/19338.patch","issue_url":"https://api.github.com/repos/symfony/symfony/issues/19338","number":19338,"state":"open","locked":false,"title":"[WiP] Using a cache for Controller Argument and Configuration","user":{"login":"iltar","id":1754678,"avatar_url":"https://avatars.githubusercontent.com/u/1754678?v=3","gravatar_id":"","url":"https://api.github.com/users/iltar","html_url":"https://github.com/iltar","followers_url":"https://api.github.com/users/iltar/followers","following_url":"https://api.github.com/users/iltar/following{/other_user}","gists_url":"https://api.github.com/users/iltar/gists{/gist_id}","starred_url":"https://api.github.com/users/iltar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iltar/subscriptions","organizations_url":"https://api.github.com/users/iltar/orgs","repos_url":"https://api.github.com/users/iltar/repos","events_url":"https://api.github.com/users/iltar/events{/privacy}","received_events_url":"https://api.github.com/users/iltar/received_events","type":"User","site_admin":false},"body":"| Q             | A\r\n| ------------- | ---\r\n| Branch?       | master\r\n| Bug fix?      | no\r\n| New feature?  | yes\r\n| BC breaks?    | no\r\n| Deprecations? | no\r\n| Tests pass?   | no \r\n| Fixed tickets | -\r\n| License       | MIT\r\n| Doc PR        | -\r\n\r\nSome time ago I was working on the `ArgumentResolver`. This PR adds the following:\r\n - A cache to store the resolved arguments\r\n - A cache to store controller configuration\r\n\r\n## Cache to store Resolved Arguments\r\n\r\nThe first part is done. During cache warm-up it instantiates all controllers (sadly no other way atm) and indexes all available actions from those controllers. The second part has an extension point already but has yet to be implemented. The idea is to cache away the entire configuration; Like the SensioFrameworkExtraBundle does, except it doesn't need run-time reflection anymore as it's cached. \r\n\r\nI've tested this in my own application:\r\n - 55 controllers\r\n - 430 actions on those controllers\r\n - 9 subrequests on average \r\n - 5 of those are from controllers which are completely excluded from the routing (subrequests only)\r\n - argument resolving was done 500 times in a for loop during 1 request\r\n - php 7\r\n - xdebug enabled (thus reflection will most likely be a bit faster)\r\n\r\n**Cached**\r\n\"20 ms with 3 arguments\"\r\n\"8 ms with 0 arguments\"\r\n\"8 ms with 0 arguments\"\r\n\"10 ms with 1 arguments\"\r\n\"11 ms with 1 arguments\"\r\n\"18 ms with 2 arguments\"\r\n\"11 ms with 1 arguments\"\r\n\"8 ms with 0 arguments\"\r\n\"11 ms with 1 arguments\"\r\n\r\n**Fresh** \r\n\"25 ms with 3 arguments\"\r\n\"6 ms with 0 arguments\"\r\n\"5 ms with 0 arguments\"\r\n\"12 ms with 1 arguments\"\r\n\"14 ms with 1 arguments\"\r\n\"23 ms with 2 arguments\"\r\n\"12 ms with 1 arguments\"\r\n\"5 ms with 0 arguments\"\r\n\"12 ms with 1 arguments\"\r\n\r\nThe ones with 0 arguments have a bit more overhead because an unserialize is triggered while it has no arguments. In total, the cache warm-up for this application takes ~230ms longer. I've used the `\\Serializable` interface to reduce the cache size and speed up unserialize. The file went from 360K to 105K by adding the interface to the `ControllerMetadata` and `ArgumentMetadata`. Executing the `include` 500 times in a row went from 1450ms before to 135ms after adding the interface.\r\n\r\n## controller configuration\r\nThe biggest power lies in the added possibility to store configurations for controllers. The Extra Bundle already allows you to add Annotations on the controller and actions, but this requires run-time reflection (only annotations are cached via the reader). Because the controller config doesn't change, this can easily be cached away. \r\n\r\nBy implementing an interface, I've also made it possible to implement an XML, Yaml or even a raw PHP variant if desired. This will reduce overhead at run-time.\r\n\r\nThe only thing I'm not sure of yet, is the caching method. At the moment it generates one big array of serialized strings and I'm afraid this might have a performance impact once the configurations are loaded. If you have any caching suggestions, they are more than welcome.\r\n\r\n_Before I continue to put more time and effort in here, do you think this feature is nice to have? Personally I'd like to move this functionality to the core instead of the extra bundle, but in a well-designed way._","created_at":"2016-07-11T14:43:11Z","updated_at":"2016-07-11T17:40:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ddd6c33190cd5a400e33e9aa82416395b29fffad","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/symfony/symfony/pulls/19338/commits","review_comments_url":"https://api.github.com/repos/symfony/symfony/pulls/19338/comments","review_comment_url":"https://api.github.com/repos/symfony/symfony/pulls/comments{/number}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/19338/comments","statuses_url":"https://api.github.com/repos/symfony/symfony/statuses/64668bebc04cfc8955a7cf7e5e0c80ca3442abbf","head":{"label":"iltar:feature/controller-cache","ref":"feature/controller-cache","sha":"64668bebc04cfc8955a7cf7e5e0c80ca3442abbf","user":{"login":"iltar","id":1754678,"avatar_url":"https://avatars.githubusercontent.com/u/1754678?v=3","gravatar_id":"","url":"https://api.github.com/users/iltar","html_url":"https://github.com/iltar","followers_url":"https://api.github.com/users/iltar/followers","following_url":"https://api.github.com/users/iltar/following{/other_user}","gists_url":"https://api.github.com/users/iltar/gists{/gist_id}","starred_url":"https://api.github.com/users/iltar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iltar/subscriptions","organizations_url":"https://api.github.com/users/iltar/orgs","repos_url":"https://api.github.com/users/iltar/repos","events_url":"https://api.github.com/users/iltar/events{/privacy}","received_events_url":"https://api.github.com/users/iltar/received_events","type":"User","site_admin":false},"repo":{"id":7439250,"name":"symfony","full_name":"iltar/symfony","owner":{"login":"iltar","id":1754678,"avatar_url":"https://avatars.githubusercontent.com/u/1754678?v=3","gravatar_id":"","url":"https://api.github.com/users/iltar","html_url":"https://github.com/iltar","followers_url":"https://api.github.com/users/iltar/followers","following_url":"https://api.github.com/users/iltar/following{/other_user}","gists_url":"https://api.github.com/users/iltar/gists{/gist_id}","starred_url":"https://api.github.com/users/iltar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iltar/subscriptions","organizations_url":"https://api.github.com/users/iltar/orgs","repos_url":"https://api.github.com/users/iltar/repos","events_url":"https://api.github.com/users/iltar/events{/privacy}","received_events_url":"https://api.github.com/users/iltar/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/iltar/symfony","description":"The Symfony PHP framework","fork":true,"url":"https://api.github.com/repos/iltar/symfony","forks_url":"https://api.github.com/repos/iltar/symfony/forks","keys_url":"https://api.github.com/repos/iltar/symfony/keys{/key_id}","collaborators_url":"https://api.github.com/repos/iltar/symfony/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/iltar/symfony/teams","hooks_url":"https://api.github.com/repos/iltar/symfony/hooks","issue_events_url":"https://api.github.com/repos/iltar/symfony/issues/events{/number}","events_url":"https://api.github.com/repos/iltar/symfony/events","assignees_url":"https://api.github.com/repos/iltar/symfony/assignees{/user}","branches_url":"https://api.github.com/repos/iltar/symfony/branches{/branch}","tags_url":"https://api.github.com/repos/iltar/symfony/tags","blobs_url":"https://api.github.com/repos/iltar/symfony/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/iltar/symfony/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/iltar/symfony/git/refs{/sha}","trees_url":"https://api.github.com/repos/iltar/symfony/git/trees{/sha}","statuses_url":"https://api.github.com/repos/iltar/symfony/statuses/{sha}","languages_url":"https://api.github.com/repos/iltar/symfony/languages","stargazers_url":"https://api.github.com/repos/iltar/symfony/stargazers","contributors_url":"https://api.github.com/repos/iltar/symfony/contributors","subscribers_url":"https://api.github.com/repos/iltar/symfony/subscribers","subscription_url":"https://api.github.com/repos/iltar/symfony/subscription","commits_url":"https://api.github.com/repos/iltar/symfony/commits{/sha}","git_commits_url":"https://api.github.com/repos/iltar/symfony/git/commits{/sha}","comments_url":"https://api.github.com/repos/iltar/symfony/comments{/number}","issue_comment_url":"https://api.github.com/repos/iltar/symfony/issues/comments{/number}","contents_url":"https://api.github.com/repos/iltar/symfony/contents/{+path}","compare_url":"https://api.github.com/repos/iltar/symfony/compare/{base}...{head}","merges_url":"https://api.github.com/repos/iltar/symfony/merges","archive_url":"https://api.github.com/repos/iltar/symfony/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/iltar/symfony/downloads","issues_url":"https://api.github.com/repos/iltar/symfony/issues{/number}","pulls_url":"https://api.github.com/repos/iltar/symfony/pulls{/number}","milestones_url":"https://api.github.com/repos/iltar/symfony/milestones{/number}","notifications_url":"https://api.github.com/repos/iltar/symfony/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/iltar/symfony/labels{/name}","releases_url":"https://api.github.com/repos/iltar/symfony/releases{/id}","deployments_url":"https://api.github.com/repos/iltar/symfony/deployments","created_at":"2013-01-04T11:22:34Z","updated_at":"2015-02-06T10:55:28Z","pushed_at":"2016-07-11T14:20:59Z","git_url":"git://github.com/iltar/symfony.git","ssh_url":"git@github.com:iltar/symfony.git","clone_url":"https://github.com/iltar/symfony.git","svn_url":"https://github.com/iltar/symfony","homepage":"symfony.com","size":73861,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"symfony:master","ref":"master","sha":"c221908fc48c5af11057f80098c0b49a31bfdd73","user":{"login":"symfony","id":143937,"avatar_url":"https://avatars.githubusercontent.com/u/143937?v=3","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://avatars.githubusercontent.com/u/143937?v=3","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":"2016-07-11T17:11:25Z","pushed_at":"2016-07-11T15:33:34Z","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":135738,"stargazers_count":12613,"watchers_count":12613,"language":"PHP","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":4929,"mirror_url":null,"open_issues_count":677,"forks":4929,"open_issues":677,"watchers":12613,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/symfony/symfony/pulls/19338"},"html":{"href":"https://github.com/symfony/symfony/pull/19338"},"issue":{"href":"https://api.github.com/repos/symfony/symfony/issues/19338"},"comments":{"href":"https://api.github.com/repos/symfony/symfony/issues/19338/comments"},"review_comments":{"href":"https://api.github.com/repos/symfony/symfony/pulls/19338/comments"},"review_comment":{"href":"https://api.github.com/repos/symfony/symfony/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/symfony/symfony/pulls/19338/commits"},"statuses":{"href":"https://api.github.com/repos/symfony/symfony/statuses/64668bebc04cfc8955a7cf7e5e0c80ca3442abbf"}}}}
{"actor":{"display_login":"bhavin-nakrani"}}