Repository: go
Issue: x/tools/gopls: run completion using partial type checking of current package
Labels: NeedsInvestigation,gopls,Tools,gopls/performance,gopls/completion

### gopls version

Build info
----------
golang.org/x/tools/gopls v0.15.3
    golang.org/x/tools/gopls@v0.15.3 h1:zbdOidFrPTc8Bx0YrN5QKgJ0zCjyGi0L27sKQ/bDG5o=
    github.com/BurntSushi/toml@v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
    github.com/google/go-cmp@v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
    golang.org/x/exp/typeparams@v0.0.0-20221212164502-fae10dda9338 h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y=
    golang.org/x/mod@v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8=
    golang.org/x/sync@v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
    golang.org/x/sys@v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
    golang.org/x/telemetry@v0.0.0-20240209200032-7b892fcb8a78 h1:vcVnuftN4J4UKLRcgetjzfU9FjjgXUUYUc3JhFplgV4=
    golang.org/x/text@v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
    golang.org/x/tools@v0.18.1-0.20240412183611-d92ae0781217 h1:uH9jJYgeLCvblH0S+03kFO0qUDxRkbLRLFiKVVDl7ak=
    golang.org/x/vuln@v1.0.1 h1:KUas02EjQK5LTuIx1OylBQdKKZ9jeugs+HiqO5HormU=
    honnef.co/go/tools@v0.4.6 h1:oFEHCKeID7to/3autwsWfnuv69j3NsfcXbvJKuIcep8=
    mvdan.cc/gofumpt@v0.6.0 h1:G3QvahNDmpD+Aek/bNOLrFR2XC6ZAdo62dZu65gmwGo=
    mvdan.cc/xurls/v2@v2.5.0 h1:lyBNOm8Wo71UknhUs4QTFUNNMyxy2JEIaKKo0RWOh+8=
go: go1.22.0

### go env

```shell
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\value\AppData\Local\go-build
set GOENV=E:\Users\value\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=D:\gez\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=D:\\gez
set GOPRIVATE=
set GOPROXY=https://goproxy.cn/
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.22.0
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=D:\gez\src\rent-manager\go.mod
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\value\AppData\Local\Temp\go-build1699389175=/tmp/go-build -gno-record-gcc-switches
```


### What did you do?

no

### What did you see happen?

completion is slow

### What did you expect to see?

How to improve the completion speed

### Editor and settings

{
    "git.autofetch": true,
    "go.addTags":{
        "tags": "json",
        "options": "",
        "transform": "camelcase"
    },
    "go.lintOnSave":"package",
    "go.vetOnSave": "off",
    "go.lintTool":"golangci-lint",
    "go.lintFlags":[
   //     "-min_confidence=0.9",
   //     "all,-ST1020,-ST1003,-ST1006"
    ],
    "go.formatTool":"gofmt",
    "go.testFlags": [
        "-v",
        "-count=1"
    ],
   "go.useLanguageServer": true,
   "go.languageServerFlags": [
       "-remote=auto","-logfile=auto","-debug=localhost:5050","-rpc.trace"
],
    "[go]": {
        "editor.snippetSuggestions":"top",
        "editor.formatOnSave": true,
        "editor.codeActionsOnSave": {
           "source.organizeImports": "explicit"
        },
        "editor.suggest.snippetsPreventQuickSuggestions": false
    },
    "editor.quickSuggestions": {
        "strings": true
    },
    "gopls": {
        "ui.completion.completeFunctionCalls": true,
        "ui.diagnostic.staticcheck": false,
        "ui.completion.usePlaceholders": false,
        "ui.completion.matcher": "Fuzzy",
        "ui.semanticTokens": true,
        "ui.codelenses": {
            "gc_details": false,
            "generate": false,
            "regenerate_cgo": true,
            "tidy": false,
            "upgrade_dependency": false,
            "vendor": false,
            "test": false
        },
        "ui.completion.completionBudget": "1s",
        "ui.vulncheck":"On",
        "allExperiments": true,
        "ui.completion.experimentalPostfixCompletions": true,
        "build.templateExtensions": [
            ".go"
        ],
        "zeroConfig": false,
        "analyses": {
            "nilness": false
        }
    },
    "cSpell.diagnosticLevel": "Hint",
    "cSpell.userWords": [
        "bson",
        "Infof",
        "querys"
    ],
    "cSpell.showCommandsInEditorContextMenu": false,
    "security.workspace.trust.untrustedFiles": "open",
    "window.openFoldersInNewWindow": "on",
    "go-struct-tag.cases": [
        "camel"
    ],
    "workbench.iconTheme": "material-icon-theme",
    "go.inlayHints.constantValues": true,
    "extensions.ignoreRecommendations": true,
    "go.editorContextMenuCommands": {
        "toggleTestFile": false,
        "addImport": false,
        "testCoverage": false,
        "playground": false
    },
    "json.schemaDownload.enable": false,
    "workbench.editorAssociations": {
        "*.exe": "default"
    },
    "go.toolsEnvVars": {},
    "leetcode.endpoint": "leetcode-cn",
    "leetcode.defaultLanguage": "golang",
    "leetcode.workspaceFolder": "C:\\Users\\value\\.leetcode",
    "leetcode.hint.configWebviewMarkdown": false,
    "leetcode.hint.commandShortcut": false,
    "fittencode.inlineCompletion.enable": true,
    "go.toolsManagement.autoUpdate": true,
    "go.delveConfig": {},
    "files.associations": {
        "*.go":"go"
    },
    "go.inlayHints.rangeVariableTypes": true,
    "leetcode.hint.commentDescription": false,
    "Lingma.LocalStoragePath": "C:\\Users\\value\\.lingma"
}


### Logs

[$/cancelRequest](http://localhost:5050/trace/$/cancelRequest) last: 0s, longest: 25.3429ms
[$/progress](http://localhost:5050/trace/$/progress) last: 0s, longest: 558.2µs
[client/registerCapability](http://localhost:5050/trace/client/registerCapability) last: 2.3282ms, longest: 22.2058ms
[gocommand.Runner.Run](http://localhost:5050/trace/gocommand.Runner.Run) last: 1.4592542s, longest: 1.4592542s
[gocommand.Runner.RunRaw](http://localhost:5050/trace/gocommand.Runner.RunRaw) last: 1.4592542s, longest: 1.4592542s
[gopls/handshake](http://localhost:5050/trace/gopls/handshake) last: 279.2767ms, longest: 279.2767ms
[initialize](http://localhost:5050/trace/initialize) last: 1.4941373s, longest: 1.4941373s
[initialized](http://localhost:5050/trace/initialized) last: 3.5351ms, longest: 3.5351ms
[protocol.canceller](http://localhost:5050/trace/protocol.canceller) last: 0s, longest: 25.3429ms
[queued](http://localhost:5050/trace/queued) last: 0s, longest: 7.7154184s
[textDocument/codeAction](http://localhost:5050/trace/textDocument/codeAction) last: 6.9961ms, longest: 7.7154184s
[textDocument/codeLens](http://localhost:5050/trace/textDocument/codeLens) last: 2.028921s, longest: 7.1807699s
[textDocument/completion](http://localhost:5050/trace/textDocument/completion) last: 1.8880714s, longest: 5.6789887s
[textDocument/didChange](http://localhost:5050/trace/textDocument/didChange) last: 1.11ms, longest: 6.3120549s
[textDocument/didOpen](http://localhost:5050/trace/textDocument/didOpen) last: 11.552ms, longest: 11.552ms
[textDocument/didSave](http://localhost:5050/trace/textDocument/didSave) last: 1.0021ms, longest: 3.0005ms
[textDocument/documentLink](http://localhost:5050/trace/textDocument/documentLink) last: 25.8237ms, longest: 5.3391951s
[textDocument/documentSymbol](http://localhost:5050/trace/textDocument/documentSymbol) last: 1.2762219s, longest: 7.1998994s
[textDocument/foldingRange](http://localhost:5050/trace/textDocument/foldingRange) last: 12.4753ms, longest: 5.9395043s
[textDocument/formatting](http://localhost:5050/trace/textDocument/formatting) last: 46.6567ms, longest: 46.6567ms
[textDocument/inlayHint](http://localhost:5050/trace/textDocument/inlayHint) last: 1.8887478s, longest: 8.048331s
[textDocument/publishDiagnostics](http://localhost:5050/trace/textDocument/publishDiagnostics) last: 15.8979ms, longest: 22.8799ms
[textDocument/semanticTokens/full](http://localhost:5050/trace/textDocument/semanticTokens/full) last: 1.1832525s, longest: 6.3649223s
[textDocument/semanticTokens/range](http://localhost:5050/trace/textDocument/semanticTokens/range) last: 5.9401569s, longest: 5.9401569s
[textDocument/signatureHelp](http://localhost:5050/trace/textDocument/signatureHelp) last: 2.0988934s, longest: 2.0988934s
[window/logMessage](http://localhost:5050/trace/window/logMessage) last: 511.8µs, longest: 59.5579ms
[window/workDoneProgress/create](http://localhost:5050/trace/window/workDoneProgress/create) last: 791.6519ms, longest: 791.6519ms
[workspace/configuration](http://localhost:5050/trace/workspace/configuration) last: 7.248ms, longest: 7.248ms
[workspace/didChangeWatchedFiles](http://localhost:5050/trace/workspace/didChangeWatchedFiles) last: 17.9947ms, longest: 1.8196535s