{"action":"created","issue":{"url":"https://api.github.com/repos/backdrop/backdrop-issues/issues/1409","labels_url":"https://api.github.com/repos/backdrop/backdrop-issues/issues/1409/labels{/name}","comments_url":"https://api.github.com/repos/backdrop/backdrop-issues/issues/1409/comments","events_url":"https://api.github.com/repos/backdrop/backdrop-issues/issues/1409/events","html_url":"https://github.com/backdrop/backdrop-issues/issues/1409","id":121891132,"number":1409,"title":"Contextual links - performance issue","user":{"login":"Gormartsen","id":5018896,"avatar_url":"https://avatars.githubusercontent.com/u/5018896?v=3","gravatar_id":"","url":"https://api.github.com/users/Gormartsen","html_url":"https://github.com/Gormartsen","followers_url":"https://api.github.com/users/Gormartsen/followers","following_url":"https://api.github.com/users/Gormartsen/following{/other_user}","gists_url":"https://api.github.com/users/Gormartsen/gists{/gist_id}","starred_url":"https://api.github.com/users/Gormartsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gormartsen/subscriptions","organizations_url":"https://api.github.com/users/Gormartsen/orgs","repos_url":"https://api.github.com/users/Gormartsen/repos","events_url":"https://api.github.com/users/Gormartsen/events{/privacy}","received_events_url":"https://api.github.com/users/Gormartsen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-12-13T01:23:31Z","updated_at":"2015-12-14T22:04:50Z","closed_at":null,"body":"I just noticed that this module slow down Backdrop.\r\n\r\n\r\nSome debug info: (it's a function call tree)\r\n```\r\n[2.5%]  |    |    |    |    |    |    └── theme [0.06 Mb] [realtime: 2.993 ms] \r\n[2.4%]  |    |    |    |    |    |    |    └── template_preprocess_block [0.06 Mb] [realtime: 2.828 ms] \r\n[2.1%]  |    |    |    |    |    |    |    |    └── contextual_pre_render_links [0.06 Mb] [realtime: 2.427 ms] \r\n[2.0%]  |    |    |    |    |    |    |    |    |    └── menu_contextual_links [0.06 Mb] [realtime: 2.350 ms] \r\n[1.5%]  |    |    |    |    |    |    |    |    |    |    └── menu_get_item [0.05 Mb] [realtime: 1.763 ms] \r\n[1.0%]  |    |    |    |    |    |    |    |    |    |    |    └── db_query_range [0.02 Mb] [realtime: 1.179 ms] \r\n```\r\n\r\nThe real problem is here:\r\n\r\nhttps://github.com/backdrop/backdrop/blob/a5070a3ac1d5efb99bcae631b2b0b7484320f33e/core/includes/menu.inc#L2177\r\n\r\n```php\r\nfunction menu_contextual_links($module, $parent_path, $args) {\r\n......\r\n  $router_item = menu_get_item($path);\r\n  if (!$router_item || !$router_item['access']) {\r\n    $path_empty[$parent_path] = TRUE;\r\n    return $links;\r\n  }\r\n```\r\n\r\nWhen I disable this module, page execution time decrease for ~10% for 6 blocks (like menu, breadcrumbs, footer and etc... you know, default one)\r\n\r\nWhen I tested with 11 blocks, page execution time difference  was 20% \r\n- 150ms (contextual links enables) \r\n- 118ms (disabled).\r\n\r\nI don't have a solution for this issue so far."},"comment":{"url":"https://api.github.com/repos/backdrop/backdrop-issues/issues/comments/164574375","html_url":"https://github.com/backdrop/backdrop-issues/issues/1409#issuecomment-164574375","issue_url":"https://api.github.com/repos/backdrop/backdrop-issues/issues/1409","id":164574375,"user":{"login":"dboulet","id":208615,"avatar_url":"https://avatars.githubusercontent.com/u/208615?v=3","gravatar_id":"","url":"https://api.github.com/users/dboulet","html_url":"https://github.com/dboulet","followers_url":"https://api.github.com/users/dboulet/followers","following_url":"https://api.github.com/users/dboulet/following{/other_user}","gists_url":"https://api.github.com/users/dboulet/gists{/gist_id}","starred_url":"https://api.github.com/users/dboulet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dboulet/subscriptions","organizations_url":"https://api.github.com/users/dboulet/orgs","repos_url":"https://api.github.com/users/dboulet/repos","events_url":"https://api.github.com/users/dboulet/events{/privacy}","received_events_url":"https://api.github.com/users/dboulet/received_events","type":"User","site_admin":false},"created_at":"2015-12-14T22:04:50Z","updated_at":"2015-12-14T22:04:50Z","body":"> The Contextual Links module has always been implemented in a slightly obtuse fashion…\r\n\r\nI preferred the way that this was originally implemented in the first version of Admin module in D6. When displaying an entity, block, or view, it would simply call `hook_admin_link`, providing contextual information to modules which were free to add links. Simple.\r\n\r\nWhen the feature was ported to D7 core, it got tied in to the Menu system and was made much more complicated than it needed to be (IMHO)."}}