-
Notifications
You must be signed in to change notification settings - Fork 17.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x/tools/gopls: completion often uses all of 1s time budget #68063
Comments
unhelpful @gabyhelp |
That is indeed quite slow. I see that your completion budget is 1s. Is there a reason you increased it from the default of 100ms? Decreasing the budget will cause completion to abort its deep search sooner. |
I tried to change it to 100ms, and it looked slower. $/cancelRequest last: 0s, longest: 6.288ms Is the package is too large? Then I found that the use of cpu became higher when completing the code. |
Thanks. Indeed, that is too slow. It also doesn't look like your workspace is that large. Do you always experience this, even in a tiny hello world program? I note that it is not just completion: everything looks very slow from the timings you shared. Can you please start gopls with
Run that command from a terminal, do some typing when gopls is slow. After 10 seconds, the go command will jump into a pprof shell. I'd be interested in the output of |
Do you always experience this, even in a tiny hello world program? |
When I work under small package, it's very good. |
Wow, that appears to be all disk I/O. Are you perhaps running with a particularly slow filesystem? Even so, I'd expect that after the initial workspace load disk I/O is not in the fast path of most operations: they should all be hitting cache. I wonder if it is related to the file cache. Another mystery: I don't see an entry point for the reads in CC @adonovan |
Are you perhaps running with a particularly slow filesystem? Even so, I'd expect that after the initial workspace load disk I/O is not in the fast path of most operations: they should all be hitting cache. I wonder if it is related to the file cache. |
$/cancelRequest last: 0s, longest: 1.0013ms PS C:\Users\value> go tool pprof -seconds=20 http://localhost:5050/debug/pprof/profile |
@xuhezhong If you visit the And @findleyr wondered if you can share the pprof web screenshot.
For this, you can use |
Thanks! The longest request in #68063 (comment) shows 1s+ spent The last request shows 92ms for actual completion computation, but was waiting in the queue (blocked by other LSP requests). From the profile flame graph, 61% is in file read op, originated from |
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
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 last: 0s, longest: 25.3429ms
$/progress last: 0s, longest: 558.2µs
client/registerCapability last: 2.3282ms, longest: 22.2058ms
gocommand.Runner.Run last: 1.4592542s, longest: 1.4592542s
gocommand.Runner.RunRaw last: 1.4592542s, longest: 1.4592542s
gopls/handshake last: 279.2767ms, longest: 279.2767ms
initialize last: 1.4941373s, longest: 1.4941373s
initialized last: 3.5351ms, longest: 3.5351ms
protocol.canceller last: 0s, longest: 25.3429ms
queued last: 0s, longest: 7.7154184s
textDocument/codeAction last: 6.9961ms, longest: 7.7154184s
textDocument/codeLens last: 2.028921s, longest: 7.1807699s
textDocument/completion last: 1.8880714s, longest: 5.6789887s
textDocument/didChange last: 1.11ms, longest: 6.3120549s
textDocument/didOpen last: 11.552ms, longest: 11.552ms
textDocument/didSave last: 1.0021ms, longest: 3.0005ms
textDocument/documentLink last: 25.8237ms, longest: 5.3391951s
textDocument/documentSymbol last: 1.2762219s, longest: 7.1998994s
textDocument/foldingRange last: 12.4753ms, longest: 5.9395043s
textDocument/formatting last: 46.6567ms, longest: 46.6567ms
textDocument/inlayHint last: 1.8887478s, longest: 8.048331s
textDocument/publishDiagnostics last: 15.8979ms, longest: 22.8799ms
textDocument/semanticTokens/full last: 1.1832525s, longest: 6.3649223s
textDocument/semanticTokens/range last: 5.9401569s, longest: 5.9401569s
textDocument/signatureHelp last: 2.0988934s, longest: 2.0988934s
window/logMessage last: 511.8µs, longest: 59.5579ms
window/workDoneProgress/create last: 791.6519ms, longest: 791.6519ms
workspace/configuration last: 7.248ms, longest: 7.248ms
workspace/didChangeWatchedFiles last: 17.9947ms, longest: 1.8196535s
The text was updated successfully, but these errors were encountered: