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

x/text: usage of text/template or html/template disables compiler DCE #72787

Open
xaurx opened this issue Mar 11, 2025 · 9 comments
Open

x/text: usage of text/template or html/template disables compiler DCE #72787

xaurx opened this issue Mar 11, 2025 · 9 comments
Labels
BugReport Issues describing a possible bug in the Go implementation. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@xaurx
Copy link

xaurx commented Mar 11, 2025

Go version

go 1.24

Output of go env in your module/workspace:

irrelevant

What did you do?

x/text package uses text/template package which disables DCE (dead code elimination) in compiler due to usage of specific reflect methods. This typically executable binary size by 25-30%.

What did you see happen?

Increases executable size

What did you expect to see?

Smaller executable

@gopherbot gopherbot added this to the Unreleased milestone Mar 11, 2025
@seankhliao
Copy link
Member

Where specifically? can you show a reproducer?

@seankhliao seankhliao added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Mar 11, 2025
@gabyhelp
Copy link

Related Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

@gabyhelp gabyhelp added the BugReport Issues describing a possible bug in the Go implementation. label Mar 11, 2025
@andig

This comment has been minimized.

@ianlancetaylor ianlancetaylor removed the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Mar 11, 2025
@ianlancetaylor
Copy link
Member

I don't think there is anything we can do here.

@seankhliao
Copy link
Member

Most of x/text's use of template seems to be for codegen
if there's not any complex run time templating, we could consider replacing it with fmt...

@andig
Copy link
Contributor

andig commented Mar 11, 2025

@seankhliao are these even a problem, given that happens before compile time?

@seankhliao
Copy link
Member

That's why I was asking for more information on this issue?

@andig

This comment has been minimized.

@seankhliao
Copy link
Member

the use of html/template in x/net/trace is unfortunate but necessary for its safe operation (rendering html pages).

that is not the same as the use of template in x/text

@seankhliao seankhliao added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BugReport Issues describing a possible bug in the Go implementation. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

6 participants