Skip to content

cmd/compile/internal/types: lazy/incremental type expansion #25056

Open
@mdempsky

Description

@mdempsky

The compiler now supports an indexed data format for package export data that enables efficient random-access of package data. We already use this to implement lazy expansion of declarations and inline bodies, but we still currently fully expand types whenever they're referenced. I expect in larger projects that a lot of deeply nested details are never needed and we could avoid reading that data into memory.

I think the steps are largely:

  1. Hide remaining Type fields behind setter/getter methods.
  2. Create a new TSTUB Type with a way to register an expander function that rewrites the Type into a real Go type.
  3. Add a Type.expand method that checks for Etype==TSTUB and calls the expander function.
  4. Insert calls to expand() at the top of every(?) public Type method.
  5. Update iimport.go to create TSTUB types instead of normal types.

Another useful (but non-critical) step would be to review the Type API and try to prune/simplify unnecessary methods. This would reduce how many places we need to instrument with expand calls.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Triage Backlog

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions