Skip to content
This repository was archived by the owner on Nov 5, 2026. It is now read-only.

Build stripped binaries to reduce sizes - #2537

Merged
knative-prow-robot merged 1 commit into
knative:masterfrom
tcnghia:strip-binary
Oct 27, 2020
Merged

knative-prow-robot merged 1 commit into
knative:masterfrom
tcnghia:strip-binary

Conversation

@tcnghia

@tcnghia tcnghia commented Oct 27, 2020

Copy link
Copy Markdown
Contributor

What this PR does, why we need it:
Build stripped binaries to reduce sizes. See knative/serving#9957 (comment).

Which issue(s) this PR fixes:
Part of knative/serving#9957

Special notes to reviewers:

User-visible changes in this PR: reduced Knative binaries sizes

@google-cla google-cla Bot added the cla: yes Indicates the PR's author has signed the CLA. label Oct 27, 2020
@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 27, 2020
@knative-prow-robot knative-prow-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Oct 27, 2020

@mattmoor mattmoor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

🎉

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 27, 2020
@knative-prow-robot

Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mattmoor, tcnghia

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@dprotaso

dprotaso commented Oct 28, 2020 •

Copy link
Copy Markdown
Member

I worry about doing this across the board because we'll lose stack trace information from users and don't have a way to hydrate them with a symbol file.

Secondly - can we double check this doesn't break runtime.Caller invocations? ie. zap log stack trace output

Can we roll this back until the above is sorted

@dprotaso

Copy link
Copy Markdown
Member

cc @n3wscott

@mattmoor

Copy link
Copy Markdown
Contributor
# GOFLAGS='-ldflags=-s -ldflags=-w' CGO_ENABLED=0 go build ./cmd/foo/ && ./foo
2020/10/27 18:32:46 stack trace: goroutine 1 [running]:
main.bar()
        /Users/mattmoor/go/src/knative.dev/serving/cmd/foo/main.go:10 +0x6d
main.foo(...)
        /Users/mattmoor/go/src/knative.dev/serving/cmd/foo/main.go:15
main.main()
        /Users/mattmoor/go/src/knative.dev/serving/cmd/foo/main.go:19 +0x20

This information doesn't key off of the symbol table, but something in runtime called pclntab.

@mattmoor

Copy link
Copy Markdown
Contributor

... which is like another 10MB 🙄

@mattmoor

Copy link
Copy Markdown
Contributor
package main

import (
	"log"
	"runtime"
)

func bar() {
	buf := make([]byte, 1000)
	i := runtime.Stack(buf, true)
	log.Printf("stack trace: %s", string(buf[:i]))
}

func foo() {
	bar()
}

func main() {
	foo()
}

For posterity...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants