{"action":"created","issue":{"url":"https://api.github.com/repos/docker/docker/issues/16771","labels_url":"https://api.github.com/repos/docker/docker/issues/16771/labels{/name}","comments_url":"https://api.github.com/repos/docker/docker/issues/16771/comments","events_url":"https://api.github.com/repos/docker/docker/issues/16771/events","html_url":"https://github.com/docker/docker/issues/16771","id":109843777,"number":16771,"title":"Terrible `docker rmi` performance","user":{"login":"icecrime","id":1564054,"avatar_url":"https://avatars.githubusercontent.com/u/1564054?v=3","gravatar_id":"","url":"https://api.github.com/users/icecrime","html_url":"https://github.com/icecrime","followers_url":"https://api.github.com/users/icecrime/followers","following_url":"https://api.github.com/users/icecrime/following{/other_user}","gists_url":"https://api.github.com/users/icecrime/gists{/gist_id}","starred_url":"https://api.github.com/users/icecrime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/icecrime/subscriptions","organizations_url":"https://api.github.com/users/icecrime/orgs","repos_url":"https://api.github.com/users/icecrime/repos","events_url":"https://api.github.com/users/icecrime/events{/privacy}","received_events_url":"https://api.github.com/users/icecrime/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/docker/docker/milestones/41","html_url":"https://github.com/docker/docker/milestones/1.9.0","labels_url":"https://api.github.com/repos/docker/docker/milestones/41/labels","id":1211905,"number":41,"title":"1.9.0","description":"","creator":{"login":"dmp42","id":332946,"avatar_url":"https://avatars.githubusercontent.com/u/332946?v=3","gravatar_id":"","url":"https://api.github.com/users/dmp42","html_url":"https://github.com/dmp42","followers_url":"https://api.github.com/users/dmp42/followers","following_url":"https://api.github.com/users/dmp42/following{/other_user}","gists_url":"https://api.github.com/users/dmp42/gists{/gist_id}","starred_url":"https://api.github.com/users/dmp42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmp42/subscriptions","organizations_url":"https://api.github.com/users/dmp42/orgs","repos_url":"https://api.github.com/users/dmp42/repos","events_url":"https://api.github.com/users/dmp42/events{/privacy}","received_events_url":"https://api.github.com/users/dmp42/received_events","type":"User","site_admin":false},"open_issues":31,"closed_issues":36,"state":"open","created_at":"2015-07-16T20:50:09Z","updated_at":"2015-10-07T00:36:07Z","due_on":null,"closed_at":null},"comments":10,"created_at":"2015-10-05T17:12:37Z","updated_at":"2015-10-07T15:34:05Z","closed_at":null,"body":"Currently, a daemon with >50 images takes a ridiculous amount of time to honor a single `rmi` request.\r\n\r\nAfter investigation, the root cause of the issue is [this line](https://github.com/docker/docker/blob/ec1d8d7f2a8f563deb61df2b35aa8a9d6a07c3e2/daemon/image_delete.go#L282). The `HasChildren` function is incredibly complex: it calls into [`graph.ByParent()`](https://github.com/docker/docker/blob/ec1d8d7f2a8f563deb61df2b35aa8a9d6a07c3e2/graph/graph.go#L391) that walks the entire graph just for the sake of determining if an image has children.\r\n\r\nHaving a \"fast-exit\" (e.g., stop the loop when a first children is found) won't solve the most common case. We should look into maybe removing that `ByParent()` function, and maintain a reference count for each graph entry such as delete would fail immediately unless the counter is down to 0.\r\n\r\nI would love to fix this for 1.9.0 but still haven't found the time to do it myself :-( Ping @LK4D4 @runcom if interested!\r\n\r\nPS: the issue is easily reproduced by doing a `docker pull --all-tags` on `ubuntu` or `debian`."},"comment":{"url":"https://api.github.com/repos/docker/docker/issues/comments/146234013","html_url":"https://github.com/docker/docker/issues/16771#issuecomment-146234013","issue_url":"https://api.github.com/repos/docker/docker/issues/16771","id":146234013,"user":{"login":"LK4D4","id":101445,"avatar_url":"https://avatars.githubusercontent.com/u/101445?v=3","gravatar_id":"","url":"https://api.github.com/users/LK4D4","html_url":"https://github.com/LK4D4","followers_url":"https://api.github.com/users/LK4D4/followers","following_url":"https://api.github.com/users/LK4D4/following{/other_user}","gists_url":"https://api.github.com/users/LK4D4/gists{/gist_id}","starred_url":"https://api.github.com/users/LK4D4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LK4D4/subscriptions","organizations_url":"https://api.github.com/users/LK4D4/orgs","repos_url":"https://api.github.com/users/LK4D4/repos","events_url":"https://api.github.com/users/LK4D4/events{/privacy}","received_events_url":"https://api.github.com/users/LK4D4/received_events","type":"User","site_admin":false},"created_at":"2015-10-07T15:34:05Z","updated_at":"2015-10-07T15:34:05Z","body":"@thedrow @runcom @icecrime one second is definitely better. We talking about times like ~30 mins now and 1 sec will became 10 minutes."}}