Skip to content

go/token: FileSet.AddExistingFiles is quadratic [freeze exception] #73851

Open
@adonovan

Description

@adonovan

The new FileSet.AddExistingFiles method is quadratic when called repeatedly (as intended), and this is a serious performance problem in gopls that cannot be fixed within gopls, since it cannot change the representation of FileSet. A performance problem of this magnitude is properly considered a bug. (My bug, but still.)

https://go.dev/cl/675736 is a fix: instead of a (repeatedly) sorted array of files, we use a tree. It's 1000x faster on the benchmark that most closely models the problematic case. I propose to merge it into go1.25.

@golang/release

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.FixPendingIssues that have a fix which has not yet been reviewed or submitted.release-blocker

    Type

    No type

    Projects

    Status

    Approved

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions