Skip to content

Implement local devirtualization #179

@quasilyte

Description

@quasilyte

Go compiler rarely does a good job at removing the interfaces overhead.
Here is an example:

func f(buf *bytes.Buffer) {
  var rw io.ReadWriter = b
  g(rw) // performs convI2I
}

//go:noinline
func g(r io.Reader) {}

Fixed code:

func f(buf *bytes.Buffer) {
  var rw = b // just use *bytes.Buffer directly
  g(rw) // cheaper conversion
}

//go:noinline
func g(r io.Reader) {}

Investigation needed: how often can we improve things?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions