{"action":"created","issue":{"url":"https://api.github.com/repos/docker/libnetwork/issues/1072","repository_url":"https://api.github.com/repos/docker/libnetwork","labels_url":"https://api.github.com/repos/docker/libnetwork/issues/1072/labels{/name}","comments_url":"https://api.github.com/repos/docker/libnetwork/issues/1072/comments","events_url":"https://api.github.com/repos/docker/libnetwork/issues/1072/events","html_url":"https://github.com/docker/libnetwork/pull/1072","id":145768150,"number":1072,"title":"Remove pre-defined networks from package init","user":{"login":"cpuguy83","id":799078,"avatar_url":"https://avatars.githubusercontent.com/u/799078?v=3","gravatar_id":"","url":"https://api.github.com/users/cpuguy83","html_url":"https://github.com/cpuguy83","followers_url":"https://api.github.com/users/cpuguy83/followers","following_url":"https://api.github.com/users/cpuguy83/following{/other_user}","gists_url":"https://api.github.com/users/cpuguy83/gists{/gist_id}","starred_url":"https://api.github.com/users/cpuguy83/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cpuguy83/subscriptions","organizations_url":"https://api.github.com/users/cpuguy83/orgs","repos_url":"https://api.github.com/users/cpuguy83/repos","events_url":"https://api.github.com/users/cpuguy83/events{/privacy}","received_events_url":"https://api.github.com/users/cpuguy83/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/docker/libnetwork/labels/status/0-triage","name":"status/0-triage","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-04-04T18:34:10Z","updated_at":"2016-04-04T18:51:05Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/docker/libnetwork/pulls/1072","html_url":"https://github.com/docker/libnetwork/pull/1072","diff_url":"https://github.com/docker/libnetwork/pull/1072.diff","patch_url":"https://github.com/docker/libnetwork/pull/1072.patch"},"body":"This moves the initialization of the pre-defined networks to where it's\r\nused, in `Allocator`.\r\nThis reason for this change is having this be populated in `init()`\r\ncauses it to always consume cpu to populate, and memory (4.3MB of\r\nmemory) even if the package is unused (like for instnace, in a re-exec).\r\n\r\nHere is a memory profile of docker/docker just after starting the daemon of the\r\ntop 10 largest memory consumers:\r\n\r\nBefore:\r\n```\r\n      flat  flat%   sum%        cum   cum%\r\n         0     0%     0%    11.89MB 95.96%  runtime.goexit\r\n         0     0%     0%     6.79MB 54.82%  runtime.main\r\n         0     0%     0%     5.79MB 46.74%  main.init\r\n         0     0%     0%     4.79MB 38.67%  github.com/docker/docker/api/server/router/network.init\r\n         0     0%     0%     4.79MB 38.67%  github.com/docker/libnetwork.init\r\n         0     0%     0%     4.29MB 34.63%  github.com/docker/libnetwork/ipam.init\r\n         0     0%     0%     4.29MB 34.63%  github.com/docker/libnetwork/ipams/builtin.init\r\n         0     0%     0%     4.29MB 34.63%  github.com/docker/libnetwork/ipamutils.init\r\n         0     0%     0%     4.29MB 34.63%  github.com/docker/libnetwork/ipamutils.init.1\r\n    4.29MB 34.63% 34.63%     4.29MB 34.63%  github.com/docker/libnetwork/ipamutils.initGranularPredefinedNetworks\r\n```\r\n\r\nAfter:\r\n```\r\n      flat  flat%   sum%        cum   cum%\r\n         0     0%     0%  4439.37kB 89.66%  runtime.goexit\r\n         0     0%     0%  4439.37kB 89.66%  runtime.main\r\n         0     0%     0%  3882.11kB 78.40%  github.com/docker/docker/cli.(*Cli).Run\r\n         0     0%     0%  3882.11kB 78.40%  main.main\r\n 3882.11kB 78.40% 78.40%  3882.11kB 78.40%  reflect.callMethod\r\n         0     0% 78.40%  3882.11kB 78.40%  reflect.methodValueCall\r\n         0     0% 78.40%   557.26kB 11.25%  github.com/docker/docker/api/server.init\r\n  557.26kB 11.25% 89.66%   557.26kB 11.25%  html.init\r\n         0     0% 89.66%   557.26kB 11.25%  html/template.init\r\n         0     0% 89.66%   557.26kB 11.25%  main.init\r\n```\r\n\r\nNow, of course the docker daemon will still need to consume this memory, but\r\nat least now re-execs and such won't have to re-init these variables.\r\n\r\nSigned-off-by: Brian Goff <cpuguy83@gmail.com>"},"comment":{"url":"https://api.github.com/repos/docker/libnetwork/issues/comments/205445032","html_url":"https://github.com/docker/libnetwork/pull/1072#issuecomment-205445032","issue_url":"https://api.github.com/repos/docker/libnetwork/issues/1072","id":205445032,"user":{"login":"mavenugo","id":5056191,"avatar_url":"https://avatars.githubusercontent.com/u/5056191?v=3","gravatar_id":"","url":"https://api.github.com/users/mavenugo","html_url":"https://github.com/mavenugo","followers_url":"https://api.github.com/users/mavenugo/followers","following_url":"https://api.github.com/users/mavenugo/following{/other_user}","gists_url":"https://api.github.com/users/mavenugo/gists{/gist_id}","starred_url":"https://api.github.com/users/mavenugo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mavenugo/subscriptions","organizations_url":"https://api.github.com/users/mavenugo/orgs","repos_url":"https://api.github.com/users/mavenugo/repos","events_url":"https://api.github.com/users/mavenugo/events{/privacy}","received_events_url":"https://api.github.com/users/mavenugo/received_events","type":"User","site_admin":false},"created_at":"2016-04-04T18:51:05Z","updated_at":"2016-04-04T18:51:05Z","body":"@icecrime yes. we are waiting on 1 important fix to be merged before the next vendor in."}}