Skip to content

x/net/trace: dependency on html/template inhibits dead code elimination #62024

Open
@artem-anisimov-0x7f

Description

@artem-anisimov-0x7f

Any use of reflect.Value.MethodByName() or reflect.Type.MethodByName() disables the DCE. The compiler assumes that these functions will look any method up, and cannot remove methods even if they are never called.

text/template and html/template are very notable offenders in this respect. They call MethodByName() on random strings extracted from template texts.

The package x/net/trace uses html/template, hence any user of x/net/trace compiles with DCE disabled. Worse yet, the package's init() references html/template which disables DCE even if x/net/trace is imported, but otherwise unused.

There is a very popular user of x/net/trace, namely google.golang.org/grpc. Essentially, this means that a lot of networked services in golang are compiled without DCE.

What did you expect to see?

I expect that a low-level library that is used by almost everyone does not pessimise the code generation by disabling the DCE. I'd avoid html/template altogether.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.binary-sizecompiler/runtimeIssues related to the Go compiler and/or runtime.help wanted

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions