{"action":"created","issue":{"url":"https://api.github.com/repos/magit/magit/issues/2559","repository_url":"https://api.github.com/repos/magit/magit","labels_url":"https://api.github.com/repos/magit/magit/issues/2559/labels{/name}","comments_url":"https://api.github.com/repos/magit/magit/issues/2559/comments","events_url":"https://api.github.com/repos/magit/magit/issues/2559/events","html_url":"https://github.com/magit/magit/issues/2559","id":135063362,"number":2559,"title":"magit-auto-revert-mode slowness during load-library","user":{"login":"warner","id":27146,"avatar_url":"https://avatars.githubusercontent.com/u/27146?v=3","gravatar_id":"","url":"https://api.github.com/users/warner","html_url":"https://github.com/warner","followers_url":"https://api.github.com/users/warner/followers","following_url":"https://api.github.com/users/warner/following{/other_user}","gists_url":"https://api.github.com/users/warner/gists{/gist_id}","starred_url":"https://api.github.com/users/warner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/warner/subscriptions","organizations_url":"https://api.github.com/users/warner/orgs","repos_url":"https://api.github.com/users/warner/repos","events_url":"https://api.github.com/users/warner/events{/privacy}","received_events_url":"https://api.github.com/users/warner/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/magit/magit/labels/fly","name":"fly","color":"f7c6c7"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2016-02-20T11:36:30Z","updated_at":"2016-02-26T22:16:11Z","closed_at":"2016-02-23T11:29:57Z","body":"This came up in the comments on #2552, but appears to be a distinct issue, so I'm leaving that bug to its original problem report and moving the auto-revert issues here. Most of this comment is copied from that bug.\r\n\r\nThis slowness appears when loading the magit library in an emacs with lots (~240 on my box) of buffers that are under git control (and thus might need to be examined or reverted when magit has run git commands). This also happens during the autoload of magit, so it can masquerade as a slowness in running `magit-status`, but is actually during the eval of `magit.el` (and related files) themselves.\r\n\r\nThanks to @danrharms and @ilohmar , I tried the following function to temporarily disable the mode, just while loading, then put it back to whatever it was before:\r\n\r\n```elisp\r\n(defun my-load-magit ()\r\n  (interactive)\r\n  (let ((magit-auto-revert-mode nil)\r\n        (start (float-time)))\r\n    (load-library \"magit\")\r\n    (message \"elapsed: %f\" (- (float-time) start))\r\n    ))\r\n```\r\n\r\nCalling this (right after startup and calling any magit functions) takes about 0.5 seconds. Restarting emacs and calling again with `t` instead of `nil` takes 11 seconds. I have about 240 buffers open at startup (via desktop-save-mode), most of which are probably under git control, which implies something in eval is taking about 40ms per buffer.\r\n\r\nI guess the easiest workaround is to force-load magit (with a function like above) from my `emacs.el` at startup. I use magit every day, so it's not like I'm saving any time or memory by deferring to an autoload.\r\n\r\nA better fix would be to somehow rig the autoload function to change `magit-auto-revert-mode` before and after loading.. can the autoloader call a function instead of loading the library directly?\r\n\r\nThe best fix would be to isolate where in magit this delay is coming from and wrap *that*. It's happening at eval time, which should narrow down the possible location somewhat. If we're right and this really is a recent issue, then bisecting the magit history might be a quick way to narrow it down.\r\n\r\nIt's just a hunch, but I'd bet that the auto-revert changes for #2513 is involved, since they landed on 26-Jan, and I think that's in-between the updates I did when I first noticed the problem.\r\n"},"comment":{"url":"https://api.github.com/repos/magit/magit/issues/comments/189505598","html_url":"https://github.com/magit/magit/issues/2559#issuecomment-189505598","issue_url":"https://api.github.com/repos/magit/magit/issues/2559","id":189505598,"user":{"login":"ilohmar","id":3136063,"avatar_url":"https://avatars.githubusercontent.com/u/3136063?v=3","gravatar_id":"","url":"https://api.github.com/users/ilohmar","html_url":"https://github.com/ilohmar","followers_url":"https://api.github.com/users/ilohmar/followers","following_url":"https://api.github.com/users/ilohmar/following{/other_user}","gists_url":"https://api.github.com/users/ilohmar/gists{/gist_id}","starred_url":"https://api.github.com/users/ilohmar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ilohmar/subscriptions","organizations_url":"https://api.github.com/users/ilohmar/orgs","repos_url":"https://api.github.com/users/ilohmar/repos","events_url":"https://api.github.com/users/ilohmar/events{/privacy}","received_events_url":"https://api.github.com/users/ilohmar/received_events","type":"User","site_admin":false},"created_at":"2016-02-26T22:16:10Z","updated_at":"2016-02-26T22:16:10Z","body":"Understood, thanks."}}