Skip to content

Speed up implementation indexing with bitmask pre-filtering#234

Merged
jupblb merged 3 commits intomainfrom
michal/speedup-impl
Apr 22, 2026
Merged

Speed up implementation indexing with bitmask pre-filtering#234
jupblb merged 3 commits intomainfrom
michal/speedup-impl

Conversation

@jupblb
Copy link
Copy Markdown
Collaborator

@jupblb jupblb commented Apr 22, 2026

Add three fast filters before the expensive types.Implements call in findImplementations, inspired by gopls's methodsets package:

  1. Unexported method package check — interfaces with unexported methods can only be implemented by types in the same package.
  2. Method count check — O(1) rejection when the type has fewer methods than the interface requires.
  3. 64-bit bitmask subset check — each method's signature is hashed (CRC32 of Id + fingerprint) into one bit of a uint64; a single bitwise AND rejects most non-matching pairs.

The fingerprint encoding is a verbatim copy of gopls's internal/util/fingerprint package, which produces canonical type strings that are identical for identical types regardless of parameter names. A sync.sh script keeps the copy pinned to the golang.org/x/tools version in go.mod.

Also add progress reporting (live counter) to the implementation indexing phase.

jupblb added 3 commits April 22, 2026 09:56
Add three fast filters before the expensive types.Implements call in
findImplementations, inspired by gopls's methodsets package:

1. Unexported method package check — interfaces with unexported methods
   can only be implemented by types in the same package.
2. Method count check — O(1) rejection when the type has fewer methods
   than the interface requires.
3. 64-bit bitmask subset check — each method's signature is hashed
   (CRC32 of Id + fingerprint) into one bit of a uint64; a single
   bitwise AND rejects most non-matching pairs.

The fingerprint encoding is a verbatim copy of gopls's
internal/util/fingerprint package (BSD-3 licensed), which produces
canonical type strings that are identical for identical types regardless
of parameter names. A sync.sh script keeps the copy pinned to the
golang.org/x/tools version in go.mod.

Also add progress reporting (live counter) to the implementation
indexing phase.
Verify that the vendored fingerprint.go stays in sync with the
golang.org/x/tools version declared in go.mod.
dockerTools.buildLayeredImage is not supported on Darwin, so only
expose the docker package on Linux systems. Also fix goimports
alignment in ImplDef struct fields.
@jupblb jupblb merged commit 3f3d6d4 into main Apr 22, 2026
10 checks passed
@jupblb jupblb deleted the michal/speedup-impl branch April 22, 2026 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant