Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/link: enable linker dead code pruning when using reflect #25081

Open
jim-minter opened this issue Apr 25, 2018 · 1 comment
Open

cmd/link: enable linker dead code pruning when using reflect #25081

jim-minter opened this issue Apr 25, 2018 · 1 comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@jim-minter
Copy link

Follow-up from https://groups.google.com/d/topic/golang-nuts/syC4LpVf7sw

The link-time optimisation to prune unused methods is disabled when reflect.Value.Call() is used anywhere within a program.

With large codebases with many vendored libraries, it's hard to avoid including something which calls reflect.Value.Call(), e.g. anything that uses text/template.

This problem is causing serious bloat on kubernetes and openshift binaries.

One improvement that might be feasible is to enable pruning of methods of a type where:

  • the set of packages which use that type is statically determinable (e.g., the type doesn't leak from the package set via an exported identifier), and
  • no packages in the set reference reflect.Value.Call()

The intention is to be able to prune methods which are provably non-reachable from any reflect.Value.Call() callpoint.

Such an improvement may be complex but I believe the commensurate reduction in binary sizes for projects such as kubernetes make it highly worth considering.

@jim-minter
Copy link
Author

@crawshaw as author of most of /src/cmd/link/internal/ld/deadcode.go, what's your take on the above?

@smarterclayton fyi

@FiloSottile FiloSottile changed the title Enable linker dead code pruning when using reflect cmd/link: enable linker dead code pruning when using reflect Apr 25, 2018
@FiloSottile FiloSottile added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 25, 2018
@FiloSottile FiloSottile added this to the Unplanned milestone Apr 25, 2018
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants