Skip to content

cmd/compile: overhaul inliner #61502

Open

Description

@aclements

We’re starting a project to overhaul the inlining optimization pass in the Go compiler, with the goal of having a far more effective inliner in Go 1.22. This issue will track this work. This document motivates this project and outlines our general design goals. More detailed design documents will follow.

This project is being driven by @thanm and @mdempsky, but we would love to have input from the community. Inlining is inherently very heuristic and can be a deep rabbit hole to go down, so I’m sure many of our design decisions will be motivated by pragmatism and trying to ship something better than what we have for Go 1.22, even if it’s not perfect, with the goal of further improving it in later releases.

Activity

  1. added this to the Go1.22 milestone on Jul 21, 2023
  2. gopherbot commented on Jul 21, 2023

    @gopherbot
    Contributor

    Change https://go.dev/cl/511565 mentions this issue: cmd/compile/internal/inline: add call site flag generation

  3. gopherbot commented on Jul 21, 2023

    @gopherbot
    Contributor

    Change https://go.dev/cl/511560 mentions this issue: cmd/compile/internal/ir: export 'reassigned', handle OASOP

  4. gopherbot commented on Jul 21, 2023

    @gopherbot
    Contributor

    Change https://go.dev/cl/511559 mentions this issue: cmd/compile/internal/inline: analyze function return properties

  5. gopherbot commented on Jul 21, 2023

    @gopherbot
    Contributor

    Change https://go.dev/cl/511555 mentions this issue: internal/goexperiment: add "InlinerRevamp" experiment

  6. gopherbot commented on Jul 21, 2023

    @gopherbot
    Contributor

    Change https://go.dev/cl/511566 mentions this issue: cmd/compile/internal/inline/inlheur: assign scores to callsites

  7. gopherbot commented on Jul 21, 2023

    @gopherbot
    Contributor

    Change https://go.dev/cl/511564 mentions this issue: cmd/compile/internal/inline: build call site table

  8. gopherbot commented on Jul 21, 2023

    @gopherbot
    Contributor

    Change https://go.dev/cl/511562 mentions this issue: cmd/compile: write "properties" to export data for inlinable funcs

  9. gopherbot commented on Jul 21, 2023

    @gopherbot
    Contributor

    Change https://go.dev/cl/511557 mentions this issue: cmd/compile/internal/inline: add framework to compute func "properties"

  10. gopherbot commented on Jul 21, 2023

    @gopherbot
    Contributor

    Change https://go.dev/cl/511561 mentions this issue: cmd/compile/internal/inline: analyze function param properties

  11. 33 remaining items

  12. michael-obermueller commented on Jul 1, 2024

    @michael-obermueller

    I would like to discuss the topic of better supporting automatic instrumentation frameworks, because they will be affected by the planned Go inliner improvements. One example is eBPF which allows to access user code and variables by analyzing the stack and CPU registers via uprobes. Uprobes do not require Go code changes and are usually installed on function-level to read parameters and return values. However, this requires to be able to predict if a function might get inlined. Only functions which never get inlined are potential candidates for installing uprobes.
    The opentelemetry-go-instrumentation (How it works) framework is one example which uses eBPF to automatically monitor Go applications.
    At Dynatrace, we also rely on some functions which might be inlined in the future, for providing detailed insight into Go applications (through an approach different from eBPF).

    I'm bringing up this topic, because I think it would be a great opportunity to improve automatic monitoring capabilities of Golang.

  13. objectref commented on Aug 7, 2024

    @objectref

    Hi. Is this new inliner included in Go 1.23?

  14. jub0bs commented on Aug 7, 2024

    @jub0bs
    Contributor

    @objectref No mention of the new inliner in the provisional release notes for 1.23, so I would say no.

  15. objectref commented on Aug 7, 2024

    @objectref

    @jub0bs Pity. But I would love to know the current state of this, it will be such an improvement!

  16. randall77 commented on Aug 7, 2024

    @randall77
    Contributor

    The new inliner went out in 1.22.
    Not sure why this issue is still open, maybe because the inliner is never really done.

  17. aclements commented on Aug 7, 2024

    @aclements
    MemberAuthor

    In addition to the improvements that @randall77 linked to in Go 1.22, Go 1.23 includes improved stack slot allocation that directly came out of the inlining project. That change is really important for more aggressive inlining, though it happens to lift all boats.

    Unfortunately, other than these few changes, our broader plans for the inliner have currently been shelved because of personnel shifts. It's still in the backlog, but we're weighing it against other opportunities (again).

    The heuristic changes that can be enabled with the GOEXPERIMENT never produced reliable performance improvements, so they remain off by default, and one of the big next steps here would be to really understand why that is and what can be used from those heuristics, or if we just need a totally different approach to the heuristics.

  18. modified the milestones: Go1.23, Backlog on Aug 7, 2024
  19. gopherbot commented on Aug 28, 2025

    @gopherbot
    Contributor

    Change https://go.dev/cl/699675 mentions this issue: unicode/utf8: make DecodeRune{,InString} inlineable

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

Metadata

Metadata

Labels

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions