{"action":"created","issue":{"url":"https://api.github.com/repos/amalgam8/amalgam8/issues/418","repository_url":"https://api.github.com/repos/amalgam8/amalgam8","labels_url":"https://api.github.com/repos/amalgam8/amalgam8/issues/418/labels{/name}","comments_url":"https://api.github.com/repos/amalgam8/amalgam8/issues/418/comments","events_url":"https://api.github.com/repos/amalgam8/amalgam8/issues/418/events","html_url":"https://github.com/amalgam8/amalgam8/pull/418","id":191310231,"number":418,"title":"Shrink released binaries using stripping and UPX compression","user":{"login":"zcahana","id":17428696,"avatar_url":"https://avatars.githubusercontent.com/u/17428696?v=3","gravatar_id":"","url":"https://api.github.com/users/zcahana","html_url":"https://github.com/zcahana","followers_url":"https://api.github.com/users/zcahana/followers","following_url":"https://api.github.com/users/zcahana/following{/other_user}","gists_url":"https://api.github.com/users/zcahana/gists{/gist_id}","starred_url":"https://api.github.com/users/zcahana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zcahana/subscriptions","organizations_url":"https://api.github.com/users/zcahana/orgs","repos_url":"https://api.github.com/users/zcahana/repos","events_url":"https://api.github.com/users/zcahana/events{/privacy}","received_events_url":"https://api.github.com/users/zcahana/received_events","type":"User","site_admin":false},"labels":[{"id":438616351,"url":"https://api.github.com/repos/amalgam8/amalgam8/labels/registry","name":"registry","color":"c5def5","default":false},{"id":438616139,"url":"https://api.github.com/repos/amalgam8/amalgam8/labels/sidecar","name":"sidecar","color":"e99695","default":false}],"state":"open","locked":false,"assignee":{"login":"ericvn","id":10537847,"avatar_url":"https://avatars.githubusercontent.com/u/10537847?v=3","gravatar_id":"","url":"https://api.github.com/users/ericvn","html_url":"https://github.com/ericvn","followers_url":"https://api.github.com/users/ericvn/followers","following_url":"https://api.github.com/users/ericvn/following{/other_user}","gists_url":"https://api.github.com/users/ericvn/gists{/gist_id}","starred_url":"https://api.github.com/users/ericvn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericvn/subscriptions","organizations_url":"https://api.github.com/users/ericvn/orgs","repos_url":"https://api.github.com/users/ericvn/repos","events_url":"https://api.github.com/users/ericvn/events{/privacy}","received_events_url":"https://api.github.com/users/ericvn/received_events","type":"User","site_admin":false},"assignees":[{"login":"ericvn","id":10537847,"avatar_url":"https://avatars.githubusercontent.com/u/10537847?v=3","gravatar_id":"","url":"https://api.github.com/users/ericvn","html_url":"https://github.com/ericvn","followers_url":"https://api.github.com/users/ericvn/followers","following_url":"https://api.github.com/users/ericvn/following{/other_user}","gists_url":"https://api.github.com/users/ericvn/gists{/gist_id}","starred_url":"https://api.github.com/users/ericvn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericvn/subscriptions","organizations_url":"https://api.github.com/users/ericvn/orgs","repos_url":"https://api.github.com/users/ericvn/repos","events_url":"https://api.github.com/users/ericvn/events{/privacy}","received_events_url":"https://api.github.com/users/ericvn/received_events","type":"User","site_admin":false}],"milestone":null,"comments":10,"created_at":"2016-11-23T15:51:04Z","updated_at":"2016-12-01T13:27:16Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/amalgam8/amalgam8/pulls/418","html_url":"https://github.com/amalgam8/amalgam8/pull/418","diff_url":"https://github.com/amalgam8/amalgam8/pull/418.diff","patch_url":"https://github.com/amalgam8/amalgam8/pull/418.patch"},"body":"The following PR applies two methods to significantly shrink the size of our released binaries, based on the [following method](https://blog.filippo.io/shrink-your-go-binaries-with-this-one-weird-trick/).\r\n1. Strip symbol tables and debug information using the `-s -w` [linker flags](https://golang.org/cmd/link/).\r\n  This shrinks the binary by about %25-%50, while still keeping types/methods/filepaths to be displayed in panic stack traces.\r\n2. Compress the binary into a self-decompressing executable using [UPX](https://upx.github.io/):\r\n  This further shrinks the binary by an additional %80, to a total of about %90!\r\n  The cost is the decompression latency when invoking the executable, which ranges between 100-400ms, depending on binary size and compression method.\r\n  \r\nNote that binary size was not much of a concern until now, being around 10-11 MB per binary.\r\nBut, with the reimplementation of the kubernetes adapter using the [official kubernetes go client](https://github.com/kubernetes/client-go) (in a separate PR), the `a8registry` & `a8sidecar` binaries sizes have skyrocketed to ~50 MB.\r\nCombining the two methods above, the binary sizes are significantly reduced:\r\n\r\n```bash\r\nzvic@zvic-vbox:~/Workspace/go/src/github.com/amalgam8/amalgam8/bin (compress_binaries)$ ll -h\r\ntotal 88M\r\ndrwxrwxr-x  2 zvic zvic 4.0K Nov 23 15:56 ./\r\ndrwxrwxr-x 20 zvic zvic 4.0K Nov 23 15:49 ../\r\n-rwxrwxr-x  1 zvic zvic  46M Nov 23 11:27 a8sidecar*\r\n-rwxrwxr-x  1 zvic zvic  26M Nov 23 11:24 a8sidecar-stripped*\r\n-rwxrwxr-x  1 zvic zvic 6.0M Nov 23 11:24 a8sidecar-stripped-upx*\r\n-rwxrwxr-x  1 zvic zvic 5.7M Nov 23 11:24 a8sidecar-stripped-upx-best*\r\n-rwxrwxr-x  1 zvic zvic 4.5M Nov 23 11:24 a8sidecar-stripped-upx-best-ultra*\r\n```\r\n\r\n- `a8sidecar` (our vanilla sidecar) as well as `a8sidecar-stripped` starts up in about 50 ms.\r\n- `a8sidecar-stripped-upx` (default compression method) as well as `a8sidecar-stripped-upx-best` (best compression method) starts up in about 150 ms.\r\n- `a8sidecar-stripped-upx-best-ultra` (better than best compression :smile:) starts up in about 450 ms.\r\n\r\nTwo additional notes:\r\n- According to the UPX docs, the produced executables are self-containing (no dependencies, statically linked) are should be able to run on any linux platform capable of running ELF executables (i.e., any).\r\n- We need to make sure there are no issues with [UPX license](https://github.com/upx/upx/blob/master/LICENSE). For my understanding, the only section which applies to us is [SPECIAL EXCEPTION FOR COMPRESSED EXECUTABLES](https://github.com/upx/upx/blob/master/LICENSE#L68), which doesn't apply any special restrictions or requirements on us. @ericvn I'd appreciate if you could take a look and see if we can clear that."},"comment":{"url":"https://api.github.com/repos/amalgam8/amalgam8/issues/comments/264172762","html_url":"https://github.com/amalgam8/amalgam8/pull/418#issuecomment-264172762","issue_url":"https://api.github.com/repos/amalgam8/amalgam8/issues/418","id":264172762,"user":{"login":"rshriram","id":8202871,"avatar_url":"https://avatars.githubusercontent.com/u/8202871?v=3","gravatar_id":"","url":"https://api.github.com/users/rshriram","html_url":"https://github.com/rshriram","followers_url":"https://api.github.com/users/rshriram/followers","following_url":"https://api.github.com/users/rshriram/following{/other_user}","gists_url":"https://api.github.com/users/rshriram/gists{/gist_id}","starred_url":"https://api.github.com/users/rshriram/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rshriram/subscriptions","organizations_url":"https://api.github.com/users/rshriram/orgs","repos_url":"https://api.github.com/users/rshriram/repos","events_url":"https://api.github.com/users/rshriram/events{/privacy}","received_events_url":"https://api.github.com/users/rshriram/received_events","type":"User","site_admin":false},"created_at":"2016-12-01T13:27:16Z","updated_at":"2016-12-01T13:27:16Z","body":"Just make sure to document this in the developer documentation at least (about reducing binary sizes). "}}
{"actor":{"display_login":"rshriram"}}