{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/6853","repository_url":"https://api.github.com/repos/golang/go","labels_url":"https://api.github.com/repos/golang/go/issues/6853/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/6853/comments","events_url":"https://api.github.com/repos/golang/go/issues/6853/events","html_url":"https://github.com/golang/go/issues/6853","id":51285824,"number":6853,"title":"all: binaries too big and growing","user":{"login":"robpike","id":4324516,"avatar_url":"https://avatars.githubusercontent.com/u/4324516?v=3","gravatar_id":"","url":"https://api.github.com/users/robpike","html_url":"https://github.com/robpike","followers_url":"https://api.github.com/users/robpike/followers","following_url":"https://api.github.com/users/robpike/following{/other_user}","gists_url":"https://api.github.com/users/robpike/gists{/gist_id}","starred_url":"https://api.github.com/users/robpike/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robpike/subscriptions","organizations_url":"https://api.github.com/users/robpike/orgs","repos_url":"https://api.github.com/users/robpike/repos","events_url":"https://api.github.com/users/robpike/events{/privacy}","received_events_url":"https://api.github.com/users/robpike/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":true,"assignee":null,"milestone":{"url":"https://api.github.com/repos/golang/go/milestones/31","html_url":"https://github.com/golang/go/milestones/Go1.7","labels_url":"https://api.github.com/repos/golang/go/milestones/31/labels","id":1414133,"number":31,"title":"Go1.7","description":"","creator":{"login":"bradfitz","id":2621,"avatar_url":"https://avatars.githubusercontent.com/u/2621?v=3","gravatar_id":"","url":"https://api.github.com/users/bradfitz","html_url":"https://github.com/bradfitz","followers_url":"https://api.github.com/users/bradfitz/followers","following_url":"https://api.github.com/users/bradfitz/following{/other_user}","gists_url":"https://api.github.com/users/bradfitz/gists{/gist_id}","starred_url":"https://api.github.com/users/bradfitz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bradfitz/subscriptions","organizations_url":"https://api.github.com/users/bradfitz/orgs","repos_url":"https://api.github.com/users/bradfitz/repos","events_url":"https://api.github.com/users/bradfitz/events{/privacy}","received_events_url":"https://api.github.com/users/bradfitz/received_events","type":"User","site_admin":false},"open_issues":211,"closed_issues":27,"state":"open","created_at":"2015-11-16T16:57:07Z","updated_at":"2016-02-18T23:27:03Z","due_on":"2016-07-31T07:00:00Z","closed_at":null},"comments":34,"created_at":"2013-11-30T18:31:15Z","updated_at":"2016-02-19T01:00:18Z","closed_at":null,"body":"<pre>As an experiment, I build &quot;hello, world&quot; at the release points for go 1.0.\n1.1, and 1.2. Here are the binary's sizes:\n\n% ls -l x.1.?\n-rwxr-xr-x  1 r  staff  1191952 Nov 30 10:25 x.1.0\n-rwxr-xr-x  1 r  staff  1525936 Nov 30 10:20 x.1.1\n-rwxr-xr-x  1 r  staff  2188576 Nov 30 10:18 x.1.2\n% size x.1.?\n__TEXT\t__DATA\t__OBJC\tothers\tdec\thex\n880640\t33682096\t0\t4112\t34566848\t20f72c0\tx.1.0\n1064960\t94656\t0\t75952\t1235568\t12da70\tx.1.1\n1429504\t147896\t0\t177440\t1754840\t1ac6d8\tx.1.2\n% \n\nA near-doubling of the binary size in two releases is a bug of a kind. I will hold on to\nthe files so they can be analyzed more, but am filing this issue to get the topic\nregistered. We need to develop a better understanding of the problem and how to address\nit.\n\nMarking this 1.3 (not maybe) because I consider it a priority.\n\n\nA few months ago I exchanged mail with Russ about this topic regarding a different, much\nlarger binary. To avoid him having to redo the analysis, here is what he said at the\ntime:\n\n====\ni sent CL 13722046 to make the nm -S output a bit more useful.\nfor the toy binary i now get\n\n  4a2280  1898528 D symtab\n  26f3a0  1405936 D type.*\n  671aa0  1058432 D pclntab\n  3c6790   598056 D go.string.*\n  4620c0    49600 D gcbss\n  7a7c20    45496 B runtime.mheap\n  46e280    21936 D gcdata\n  7a29e0    21056 b bufferList\n  1ed600    16480 T crypto/tls.(*Conn).clientHandshake\n  79eb20    16064 b semtable\n  1b3d90    14224 T net/http.init\n\nthat seems plausible to me. some notes:\n\nsymtab is the plan 9 symbol table. it in the binary but never referenced at run time. it\nsupports things like nm -S only. it needs to move into an unmapped section of the\nbinary, but it is only costing at most 8k at run time right now due to fragmentation and\nit just wasn't worth the effort to try to move. the new linker will make this easier. of\ncourse, moving it in the file doesn't shrink the file.\n\nthe thing named pclntab is a reencoding of the original pclntab and the parts of the\nplan 9 symbol table that we did need at run time (mostly just a list of functions and\ntheir names and addresses). as you can see, it is much smaller than the old form (the\nsymbol table dominates).\n\ntype.* is the reflect types and go.string.* is the static go string data. the *\nindicates that i coalesced many symbols into one, to avoid useless individual names\nbloating the symbol table. if we tried we could probably cut the reflect types by 2-4x.\nit would mean packing the data a bit more compactly than an ordinary go data structure\nwould and then using unsafe to get it back out.\n\ngcbss and gcdata are garbage collection bits for the bss and data segments. that's what\natom symbol did, and it's not clear whether it will last (probably not) and whether what\nwill replace it will be smaller. time will tell. i have a meeting with dmitriy, carl,\nand keith next week to figure out what the plan is.\n\nruntime.mheap, bufferList, and semtable are bss.\n\nyou're not seeing the gdb dwarf debug information here, because it's not a runtime\nsymbol.\n \ng% otool -l $(which toy) | egrep '^  segname|filesize'\n  segname __PAGEZERO\n filesize 0\n  segname __TEXT\n filesize 7811072\n  segname __DATA\n filesize 126560\n  segname __LINKEDIT\n filesize 921772\n  segname __DWARF\n filesize 2886943\ng% \n\nthere's another 3 MB. you can build with -ldflags -w to get rid of that at least.\nif you read the full otool -l output you will find\n\nLoad command 6\n     cmd LC_SYMTAB\n cmdsize 24\n  symoff 10825728\n   nsyms 22559\n  stroff 11186924\n strsize 560576\n\nlooks like another 1 MB or so (560576+11186924-10825728 or 22559*16+560576) for the\nmach-o symbol table.\n\nwhen we do the new linker we can make recording this kind of information in a useful\nform a priority.</pre>"},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/185999280","html_url":"https://github.com/golang/go/issues/6853#issuecomment-185999280","issue_url":"https://api.github.com/repos/golang/go/issues/6853","id":185999280,"user":{"login":"gopherbot","id":8566911,"avatar_url":"https://avatars.githubusercontent.com/u/8566911?v=3","gravatar_id":"","url":"https://api.github.com/users/gopherbot","html_url":"https://github.com/gopherbot","followers_url":"https://api.github.com/users/gopherbot/followers","following_url":"https://api.github.com/users/gopherbot/following{/other_user}","gists_url":"https://api.github.com/users/gopherbot/gists{/gist_id}","starred_url":"https://api.github.com/users/gopherbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gopherbot/subscriptions","organizations_url":"https://api.github.com/users/gopherbot/orgs","repos_url":"https://api.github.com/users/gopherbot/repos","events_url":"https://api.github.com/users/gopherbot/events{/privacy}","received_events_url":"https://api.github.com/users/gopherbot/received_events","type":"User","site_admin":false},"created_at":"2016-02-19T01:00:18Z","updated_at":"2016-02-19T01:00:18Z","body":"CL https://golang.org/cl/16610 mentions this issue."}}