Skip to content
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

High CPU usage when pow function exists in code #1087

Closed
agentx3 opened this issue Jun 17, 2024 · 10 comments
Closed

High CPU usage when pow function exists in code #1087

agentx3 opened this issue Jun 17, 2024 · 10 comments
Assignees

Comments

@agentx3
Copy link

agentx3 commented Jun 17, 2024

Issue
CPU usage increases dramatically when there is a pow function in the code. The specific process seems to be this one ../start/coc-pyright/node_modules/pyright/langserver.index.js--node-ipc--clientProcessId=xxxxxxx.

During this time, the CocAction doHover cannot be called. CPU usage can stay high for 3+ minutes before it seemingly resolves, doHover functionality is restored, and the parameter inlay hints are displayed.

Minimum reproducable steps

echo "pow(1,-1,1)" > code.py
nvim code.py

Hopefully it's not just me. May also be an upstream issue, but I'm not sure.
Afternote: Also happens with pow(1,1)

What's the output of :CocCommand pyright.version
coc-pyright 1.1.365 with Pyright 1.1.365

What's the output of :CocCommand workspace.showOutput Pyright

This was captured moments after opening the file. If I wait for it to resolve, then the output is 6000+ lines long, so I won't post it unless asked

Workspace: /home/agentx3/TEMP/pyright-test
Using python from /etc/profiles/per-user/agentx3/bin/python

[Trace - 14:49:36.461] Sending request 'initialize - (0)'.
Params: {
    "processId": 536966,
    "rootPath": "/home/agentx3/TEMP/pyright-test",
    "rootUri": "file:///home/agentx3/TEMP/pyright-test",
    "capabilities": {
        "workspace": {
            "applyEdit": true,
            "workspaceEdit": {
                "documentChanges": true,
                "resourceOperations": [
                    "create",
                    "rename",
                    "delete"
                ],
                "failureHandling": "undo",
                "normalizesLineEndings": true,
                "changeAnnotationSupport": {
                    "groupsOnLabel": false
                }
            },
            "didChangeConfiguration": {
                "dynamicRegistration": true
            },
            "didChangeWatchedFiles": {
                "dynamicRegistration": true,
                "relativePatternSupport": true
            },
            "codeLens": {
                "refreshSupport": true
            },
            "executeCommand": {
                "dynamicRegistration": true
            },
            "configuration": true,
            "fileOperations": {
                "dynamicRegistration": true,
                "didCreate": true,
                "didRename": true,
                "didDelete": true,
                "willCreate": true,
                "willRename": true,
                "willDelete": true
            },
            "semanticTokens": {
                "refreshSupport": true
            },
            "inlayHint": {
                "refreshSupport": true
            },
            "inlineValue": {
                "refreshSupport": true
            },
            "diagnostics": {
                "refreshSupport": true
            },
            "symbol": {
                "dynamicRegistration": true,
                "symbolKind": {
                    "valueSet": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                        15,
                        16,
                        17,
                        18,
                        19,
                        20,
                        21,
                        22,
                        23,
                        24,
                        25,
                        26
                    ]
                },
                "tagSupport": {
                    "valueSet": [
                        1
                    ]
                },
                "resolveSupport": {
                    "properties": [
                        "location.range"
                    ]
                }
            },
            "workspaceFolders": true
        },
        "textDocument": {
            "publishDiagnostics": {
                "relatedInformation": true,
                "versionSupport": true,
                "tagSupport": {
                    "valueSet": [
                        1,
                        2
                    ]
                },
                "codeDescriptionSupport": true,
                "dataSupport": true
            },
            "synchronization": {
                "dynamicRegistration": true,
                "willSave": true,
                "willSaveWaitUntil": true,
                "didSave": true
            },
            "completion": {
                "dynamicRegistration": true,
                "contextSupport": true,
                "completionItem": {
                    "snippetSupport": true,
                    "commitCharactersSupport": true,
                    "documentationFormat": [
                        "markdown",
                        "plaintext"
                    ],
                    "deprecatedSupport": true,
                    "preselectSupport": true,
                    "insertReplaceSupport": true,
                    "tagSupport": {
                        "valueSet": [
                            1
                        ]
                    },
                    "resolveSupport": {
                        "properties": [
                            "documentation",
                            "detail",
                            "additionalTextEdits"
                        ]
                    },
                    "labelDetailsSupport": true,
                    "insertTextModeSupport": {
                        "valueSet": [
                            1,
                            2
                        ]
                    }
                },
                "completionItemKind": {
                    "valueSet": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                        15,
                        16,
                        17,
                        18,
                        19,
                        20,
                        21,
                        22,
                        23,
                        24,
                        25
                    ]
                },
                "insertTextMode": 2,
                "completionList": {
                    "itemDefaults": [
                        "commitCharacters",
                        "editRange",
                        "insertTextFormat",
                        "insertTextMode"
                    ]
                }
            },
            "hover": {
                "dynamicRegistration": true,
                "contentFormat": [
                    "markdown",
                    "plaintext"
                ]
            },
            "signatureHelp": {
                "dynamicRegistration": true,
                "contextSupport": true,
                "signatureInformation": {
                    "documentationFormat": [
                        "markdown",
                        "plaintext"
                    ],
                    "activeParameterSupport": false,
                    "parameterInformation": {
                        "labelOffsetSupport": true
                    }
                }
            },
            "references": {
                "dynamicRegistration": true
            },
            "definition": {
                "dynamicRegistration": true,
                "linkSupport": true
            },
            "documentHighlight": {
                "dynamicRegistration": true
            },
            "documentSymbol": {
                "dynamicRegistration": true,
                "symbolKind": {
                    "valueSet": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                        15,
                        16,
                        17,
                        18,
                        19,
                        20,
                        21,
                        22,
                        23,
                        24,
                        25,
                        26
                    ]
                },
                "hierarchicalDocumentSymbolSupport": true,
                "tagSupport": {
                    "valueSet": [
                        1
                    ]
                },
                "labelSupport": true
            },
            "codeAction": {
                "dynamicRegistration": true,
                "isPreferredSupport": true,
                "disabledSupport": true,
                "dataSupport": true,
                "honorsChangeAnnotations": false,
                "resolveSupport": {
                    "properties": [
                        "edit"
                    ]
                },
                "codeActionLiteralSupport": {
                    "codeActionKind": {
                        "valueSet": [
                            "",
                            "quickfix",
                            "refactor",
                            "refactor.extract",
                            "refactor.inline",
                            "refactor.rewrite",
                            "source",
                            "source.organizeImports"
                        ]
                    }
                }
            },
            "codeLens": {
                "dynamicRegistration": true
            },
            "formatting": {
                "dynamicRegistration": true
            },
            "rangeFormatting": {
                "dynamicRegistration": true
            },
            "onTypeFormatting": {
                "dynamicRegistration": true
            },
            "rename": {
                "dynamicRegistration": true,
                "prepareSupport": true,
                "honorsChangeAnnotations": true,
                "prepareSupportDefaultBehavior": 1
            },
            "documentLink": {
                "dynamicRegistration": true,
                "tooltipSupport": true
            },
            "typeDefinition": {
                "dynamicRegistration": true,
                "linkSupport": true
            },
            "implementation": {
                "dynamicRegistration": true,
                "linkSupport": true
            },
            "declaration": {
                "dynamicRegistration": true,
                "linkSupport": true
            },
            "colorProvider": {
                "dynamicRegistration": true
            },
            "foldingRange": {
                "dynamicRegistration": true,
                "rangeLimit": 5000,
                "lineFoldingOnly": true,
                "foldingRangeKind": {
                    "valueSet": [
                        "comment",
                        "imports",
                        "region"
                    ]
                },
                "foldingRange": {
                    "collapsedText": false
                }
            },
            "selectionRange": {
                "dynamicRegistration": true
            },
            "callHierarchy": {
                "dynamicRegistration": true
            },
            "linkedEditingRange": {
                "dynamicRegistration": true
            },
            "semanticTokens": {
                "dynamicRegistration": true,
                "tokenTypes": [
                    "namespace",
                    "type",
                    "class",
                    "enum",
                    "interface",
                    "struct",
                    "typeParameter",
                    "parameter",
                    "variable",
                    "property",
                    "enumMember",
                    "event",
                    "function",
                    "method",
                    "macro",
                    "keyword",
                    "modifier",
                    "comment",
                    "string",
                    "number",
                    "regexp",
                    "decorator",
                    "operator"
                ],
                "tokenModifiers": [
                    "declaration",
                    "definition",
                    "readonly",
                    "static",
                    "deprecated",
                    "abstract",
                    "async",
                    "modification",
                    "documentation",
                    "defaultLibrary"
                ],
                "formats": [
                    "relative"
                ],
                "requests": {
                    "range": true,
                    "full": {
                        "delta": true
                    }
                },
                "multilineTokenSupport": false,
                "overlappingTokenSupport": false,
                "serverCancelSupport": true,
                "augmentsSyntaxTokens": true
            },
            "inlayHint": {
                "dynamicRegistration": true,
                "resolveSupport": {
                    "properties": [
                        "tooltip",
                        "textEdits",
                        "label.tooltip",
                        "label.location",
                        "label.command"
                    ]
                }
            },
            "inlineValue": {
                "dynamicRegistration": true
            },
            "diagnostic": {
                "dynamicRegistration": true,
                "relatedDocumentSupport": true
            },
            "typeHierarchy": {
                "dynamicRegistration": true
            }
        },
        "window": {
            "showMessage": {
                "messageActionItem": {
                    "additionalPropertiesSupport": true
                }
            },
            "showDocument": {
                "support": true
            },
            "workDoneProgress": true
        },
        "general": {
            "regularExpressions": {
                "engine": "ECMAScript",
                "version": "ES2020"
            },
            "markdown": {
                "parser": "marked",
                "version": "7.0.5"
            },
            "positionEncodings": [
                "utf-16"
            ],
            "staleRequestSupport": {
                "cancel": true,
                "retryOnContentModified": [
                    "textDocument/inlayHint",
                    "textDocument/semanticTokens/full",
                    "textDocument/semanticTokens/range",
                    "textDocument/semanticTokens/full/delta"
                ]
            }
        }
    },
    "trace": "verbose",
    "workspaceFolders": [
        {
            "uri": "file:///home/agentx3/TEMP/pyright-test",
            "name": "pyright-test"
        }
    ],
    "locale": "en_US",
    "clientInfo": {
        "name": "coc.nvim",
        "version": "0.0.82"
    },
    "workDoneToken": "735769f3-c6cc-4c17-83f1-5eb4e84711b8"
}


[Trace - 14:49:36.610] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "Pyright language server 1.1.365 starting"
}


[Info  - 14:49:36.610] Pyright language server 1.1.365 starting
[Trace - 14:49:36.610] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "Server root directory: file:///nix/store/hba29r28xzmiqxhgq8hrrva2fx293bkm-vimplugin-coc-pyright-1.1.365/node_modules/pyright/dist"
}


[Info  - 14:49:36.610] Server root directory: file:///nix/store/hba29r28xzmiqxhgq8hrrva2fx293bkm-vimplugin-coc-pyright-1.1.365/node_modules/pyright/dist
[Trace - 14:49:36.613] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "Starting service instance \"pyright-test\""
}


[Info  - 14:49:36.613] Starting service instance "pyright-test"
[Trace - 14:49:36.615] Received response 'initialize - (0)' in 154ms.
Result: {
    "capabilities": {
        "textDocumentSync": 2,
        "definitionProvider": {
            "workDoneProgress": true
        },
        "declarationProvider": {
            "workDoneProgress": true
        },
        "typeDefinitionProvider": {
            "workDoneProgress": true
        },
        "referencesProvider": {
            "workDoneProgress": true
        },
        "documentSymbolProvider": {
            "workDoneProgress": true
        },
        "workspaceSymbolProvider": {
            "workDoneProgress": true
        },
        "hoverProvider": {
            "workDoneProgress": true
        },
        "documentHighlightProvider": {
            "workDoneProgress": true
        },
        "renameProvider": {
            "prepareProvider": true,
            "workDoneProgress": true
        },
        "completionProvider": {
            "triggerCharacters": [
                ".",
                "[",
                "\"",
                "'"
            ],
            "resolveProvider": true,
            "workDoneProgress": true,
            "completionItem": {
                "labelDetailsSupport": true
            }
        },
        "signatureHelpProvider": {
            "triggerCharacters": [
                "(",
                ",",
                ")"
            ],
            "workDoneProgress": true
        },
        "codeActionProvider": {
            "codeActionKinds": [
                "quickfix",
                "source.organizeImports"
            ],
            "workDoneProgress": true
        },
        "executeCommandProvider": {
            "commands": [],
            "workDoneProgress": true
        },
        "callHierarchyProvider": true,
        "workspace": {
            "workspaceFolders": {
                "supported": true,
                "changeNotifications": true
            }
        }
    }
}


[Trace - 14:49:36.616] Sending notification 'initialized'.
Params: {}


[Trace - 14:49:36.619] Sending notification 'workspace/didChangeConfiguration'.
Params: {
    "settings": {
        "python": {
            "analysis": {
                "indexing": true,
                "extraPaths": [],
                "typeshedPaths": [],
                "autoImportCompletions": true,
                "autoSearchPaths": true,
                "stubPath": "typings",
                "diagnosticMode": "openFilesOnly",
                "include": [],
                "exclude": [],
                "ignore": [],
                "diagnosticSeverityOverrides": {},
                "logLevel": "Information",
                "typeCheckingMode": "standard",
                "useLibraryCodeForTypes": true
            },
            "linting": {
                "enabled": true,
                "flake8Args": [],
                "flake8CategorySeverity": {
                    "E": "Error",
                    "F": "Error",
                    "W": "Warning"
                },
                "flake8Enabled": false,
                "flake8Stdin": false,
                "flake8Path": "flake8",
                "ignorePatterns": [
                    ".vscode/*.py",
                    "**/site-packages/**/*.py"
                ],
                "lintOnSave": true,
                "maxNumberOfProblems": 100,
                "banditArgs": [],
                "banditEnabled": false,
                "banditPath": "bandit",
                "mypyArgs": [
                    "--no-pretty",
                    "--ignore-missing-imports",
                    "--follow-imports=silent",
                    "--show-column-numbers"
                ],
                "mypyCategorySeverity": {
                    "error": "Error",
                    "note": "Information"
                },
                "mypyEnabled": false,
                "mypyPath": "mypy",
                "pytypeEnabled": false,
                "pytypePath": "pytype",
                "pytypeArgs": [],
                "pycodestyleArgs": [],
                "pycodestyleCategorySeverity": {
                    "E": "Error",
                    "W": "Warning"
                },
                "pycodestyleEnabled": false,
                "pycodestylePath": "pycodestyle",
                "prospectorArgs": [],
                "prospectorEnabled": false,
                "prospectorPath": "prospector",
                "pydocstyleArgs": [],
                "pydocstyleEnabled": false,
                "pydocstylePath": "pydocstyle",
                "pyflakesEnabled": false,
                "pyflakesPath": "pyflakes",
                "ruffEnabled": false,
                "ruffStdin": true,
                "ruffPath": "ruff",
                "ruffArgs": [],
                "pylamaArgs": [],
                "pylamaEnabled": false,
                "pylamaPath": "pylama",
                "pylintArgs": [],
                "pylintCategorySeverity": {
                    "convention": "Information",
                    "error": "Error",
                    "fatal": "Error",
                    "refactor": "Hint",
                    "warning": "Warning"
                },
                "pylintStdin": false,
                "pylintEnabled": false,
                "pylintPath": "pylint"
            },
            "pythonPath": "python",
            "venvPath": "",
            "formatting": {
                "blackArgs": [],
                "blackPath": "black",
                "ruffArgs": [],
                "ruffPath": "ruff",
                "pyinkArgs": [],
                "pyinkPath": "pyink",
                "darkerArgs": [],
                "darkerPath": "darker",
                "yapfArgs": [],
                "yapfPath": "yapf",
                "autopep8Args": [],
                "autopep8Path": "autopep8",
                "blackdPath": "blackd",
                "blackdHTTPURL": "",
                "blackdHTTPHeaders": {},
                "provider": "autopep8"
            },
            "sortImports": {
                "path": "isort",
                "args": []
            }
        },
        "pyright": {
            "enable": true,
            "inlayHints": {
                "functionReturnTypes": true,
                "variableTypes": true,
                "parameterTypes": true
            },
            "disableCompletion": false,
            "disableDiagnostics": false,
            "disableDocumentation": false,
            "disableProgressNotifications": false,
            "disableTaggedHints": false,
            "completion": {
                "importSupport": true,
                "snippetSupport": true
            },
            "organizeimports": {
                "provider": "isort"
            },
            "server": "",
            "testing": {
                "provider": "unittest",
                "pytestArgs": [],
                "unittestArgs": []
            },
            "trace": {
                "server": "verbose"
            },
            "extraPaths": [
                "venv"
            ]
        }
    }
}


[Trace - 14:49:36.619] Sending notification 'textDocument/didOpen'.
Params: {
    "textDocument": {
        "uri": "file:///home/agentx3/TEMP/pyright-test/code.py",
        "languageId": "python",
        "version": 1,
        "text": "pow(1,-1,1)\n"
    }
}


[Trace - 14:49:36.620] Received request 'client/registerCapability - (0)'.
Params: {
    "registrations": [
        {
            "id": "f43683b1-740b-4963-86d8-78004b3e69a4",
            "method": "workspace/didChangeWatchedFiles",
            "registerOptions": {
                "watchers": [
                    {
                        "globPattern": "**/pyrightconfig.json",
                        "kind": 7
                    },
                    {
                        "globPattern": "**",
                        "kind": 7
                    }
                ]
            }
        }
    ]
}


[Trace - 14:49:36.620] Sending response 'client/registerCapability - (0)'. Processing request took 0ms
No result returned.


[Trace - 14:49:36.620] Received request 'workspace/configuration - (1)'.
Params: {
    "items": [
        {
            "scopeUri": "file:///home/agentx3/TEMP/pyright-test",
            "section": "python"
        }
    ]
}


[Trace - 14:49:36.621] Sending response 'workspace/configuration - (1)'. Processing request took 1ms
Result: [
    {
        "analysis": {
            "indexing": true,
            "extraPaths": [],
            "typeshedPaths": [],
            "autoImportCompletions": true,
            "autoSearchPaths": true,
            "diagnosticMode": "openFilesOnly",
            "include": [],
            "exclude": [],
            "ignore": [],
            "diagnosticSeverityOverrides": {},
            "logLevel": "Information",
            "typeCheckingMode": "standard",
            "useLibraryCodeForTypes": true
        },
        "linting": {
            "enabled": true,
            "flake8Args": [],
            "flake8CategorySeverity": {
                "E": "Error",
                "F": "Error",
                "W": "Warning"
            },
            "flake8Enabled": false,
            "flake8Stdin": false,
            "flake8Path": "flake8",
            "ignorePatterns": [
                ".vscode/*.py",
                "**/site-packages/**/*.py"
            ],
            "lintOnSave": true,
            "maxNumberOfProblems": 100,
            "banditArgs": [],
            "banditEnabled": false,
            "banditPath": "bandit",
            "mypyArgs": [
                "--no-pretty",
                "--ignore-missing-imports",
                "--follow-imports=silent",
                "--show-column-numbers"
            ],
            "mypyCategorySeverity": {
                "error": "Error",
                "note": "Information"
            },
            "mypyEnabled": false,
            "mypyPath": "mypy",
            "pytypeEnabled": false,
            "pytypePath": "pytype",
            "pytypeArgs": [],
            "pycodestyleArgs": [],
            "pycodestyleCategorySeverity": {
                "E": "Error",
                "W": "Warning"
            },
            "pycodestyleEnabled": false,
            "pycodestylePath": "pycodestyle",
            "prospectorArgs": [],
            "prospectorEnabled": false,
            "prospectorPath": "prospector",
            "pydocstyleArgs": [],
            "pydocstyleEnabled": false,
            "pydocstylePath": "pydocstyle",
            "pyflakesEnabled": false,
            "pyflakesPath": "pyflakes",
            "ruffEnabled": false,
            "ruffStdin": true,
            "ruffPath": "ruff",
            "ruffArgs": [],
            "pylamaArgs": [],
            "pylamaEnabled": false,
            "pylamaPath": "pylama",
            "pylintArgs": [],
            "pylintCategorySeverity": {
                "convention": "Information",
                "error": "Error",
                "fatal": "Error",
                "refactor": "Hint",
                "warning": "Warning"
            },
            "pylintStdin": false,
            "pylintEnabled": false,
            "pylintPath": "pylint"
        },
        "pythonPath": "/etc/profiles/per-user/agentx3/bin/python",
        "venvPath": "",
        "formatting": {
            "blackArgs": [],
            "blackPath": "black",
            "ruffArgs": [],
            "ruffPath": "ruff",
            "pyinkArgs": [],
            "pyinkPath": "pyink",
            "darkerArgs": [],
            "darkerPath": "darker",
            "yapfArgs": [],
            "yapfPath": "yapf",
            "autopep8Args": [],
            "autopep8Path": "autopep8",
            "blackdPath": "blackd",
            "blackdHTTPURL": "",
            "blackdHTTPHeaders": {},
            "provider": "autopep8"
        },
        "sortImports": {
            "path": "isort",
            "args": []
        }
    }
]


[Trace - 14:49:36.621] Received request 'workspace/configuration - (2)'.
Params: {
    "items": [
        {
            "scopeUri": "file:///home/agentx3/TEMP/pyright-test",
            "section": "python.analysis"
        }
    ]
}


[Trace - 14:49:36.622] Sending response 'workspace/configuration - (2)'. Processing request took 1ms
Result: [
    {
        "indexing": true,
        "extraPaths": [],
        "typeshedPaths": [],
        "autoImportCompletions": true,
        "autoSearchPaths": true,
        "diagnosticMode": "openFilesOnly",
        "include": [],
        "exclude": [],
        "ignore": [],
        "diagnosticSeverityOverrides": {},
        "logLevel": "Information",
        "typeCheckingMode": "standard",
        "useLibraryCodeForTypes": true
    }
]


[Trace - 14:49:36.622] Received request 'workspace/configuration - (3)'.
Params: {
    "items": [
        {
            "scopeUri": "file:///home/agentx3/TEMP/pyright-test",
            "section": "pyright"
        }
    ]
}


[Trace - 14:49:36.622] Sending response 'workspace/configuration - (3)'. Processing request took 0ms
Result: [
    {
        "enable": true,
        "inlayHints": {
            "functionReturnTypes": true,
            "variableTypes": true,
            "parameterTypes": true
        },
        "disableCompletion": false,
        "disableDiagnostics": false,
        "disableDocumentation": false,
        "disableProgressNotifications": false,
        "disableTaggedHints": false,
        "completion": {
            "importSupport": true,
            "snippetSupport": true
        },
        "organizeimports": {
            "provider": "isort"
        },
        "server": "",
        "testing": {
            "provider": "unittest",
            "pytestArgs": [],
            "unittestArgs": []
        },
        "trace": {
            "server": "verbose"
        },
        "extraPaths": [
            "venv"
        ]
    }
]


[Trace - 14:49:36.623] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "Setting pythonPath for service \"pyright-test\": \"/etc/profiles/per-user/agentx3/bin/python\""
}


[Info  - 14:49:36.623] Setting pythonPath for service "pyright-test": "/etc/profiles/per-user/agentx3/bin/python"
[Trace - 14:49:36.643] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "Assuming Python version 3.12.3.final.0"
}


[Info  - 14:49:36.643] Assuming Python version 3.12.3.final.0
[Trace - 14:49:36.691] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "Found 2 source files"
}


[Info  - 14:49:36.691] Found 2 source files
[Trace - 14:49:36.692] Received request 'client/registerCapability - (4)'.
Params: {
    "registrations": [
        {
            "id": "35b7e71a-601d-4d30-86d9-ca82ccc26db5",
            "method": "workspace/didChangeWatchedFiles",
            "registerOptions": {
                "watchers": [
                    {
                        "globPattern": "**/pyrightconfig.json",
                        "kind": 7
                    },
                    {
                        "globPattern": "**",
                        "kind": 7
                    },
                    {
                        "globPattern": {
                            "baseUri": "file:///nix/store/zwvdwiw0zg5liz6lkkkqyab035parhld-python3-3.12.3/lib/python3.12",
                            "pattern": "**"
                        },
                        "kind": 7
                    }
                ]
            }
        }
    ]
}


[Trace - 14:49:36.692] Sending response 'client/registerCapability - (4)'. Processing request took 0ms
No result returned.


[Trace - 14:49:36.692] Received request 'client/unregisterCapability - (5)'.
Params: {
    "unregisterations": [
        {
            "id": "f43683b1-740b-4963-86d8-78004b3e69a4",
            "method": "workspace/didChangeWatchedFiles"
        }
    ]
}


[Trace - 14:49:36.692] Sending response 'client/unregisterCapability - (5)'. Processing request took 0ms
No result returned.


[Trace - 14:49:37.051] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "uri": "file:///home/agentx3/TEMP/pyright-test/code.py",
    "version": 1,
    "diagnostics": []
}


[Trace - 14:49:37.097] Sending request 'textDocument/signatureHelp - (1)'.
Params: {
    "textDocument": {
        "uri": "file:///home/agentx3/TEMP/pyright-test/code.py"
    },
    "position": {
        "line": 0,
        "character": 4
    }
}


[Trace - 14:49:40.189] Sending request 'textDocument/documentHighlight - (2)'.
Params: {
    "textDocument": {
        "uri": "file:///home/agentx3/TEMP/pyright-test/code.py"
    },
    "position": {
        "line": 0,
        "character": 0
    }
}


[Trace - 14:49:40.489] Sending notification '$/cancelRequest'.
Params: {
    "id": 2
}


[Trace - 14:49:45.695] Received response 'textDocument/signatureHelp - (1)' in 8598ms.
Result: {
    "signatures": [
        {
            "label": "(base: int, exp: int, mod: int) -> int",
            "parameters": [
                {
                    "label": [
                        1,
                        10
                    ]
                },
                {
                    "label": [
                        12,
                        20
                    ]
                },
                {
                    "label": [
                        22,
                        30
                    ]
                }
            ],
            "activeParameter": 0
        },
        {
            "label": "(base: int, exp: Literal[0], mod: None = None) -> Literal[1]",
            "parameters": [
                {
                    "label": [
                        1,
                        10
                    ]
                },
                {
                    "label": [
                        12,
                        27
                    ]
                },
                {
                    "label": [
                        29,
                        45
                    ]
                }
            ],
            "activeParameter": 0
        },
        {
            "label": "(base: int, exp: _PositiveInteger, mod: None = None) -> int",
            "parameters": [
                {
                    "label": [
                        1,
                        10
                    ]
                },
                {
                    "label": [
                        12,
                        33
                    ]
                },
                {
                    "label": [
                        35,
                        51
                    ]
                }
            ],
            "activeParameter": 0
        },
        {
            "label": "(base: int, exp: _NegativeInteger, mod: None = None) -> float",
            "parameters": [
                {
                    "label": [
                        1,
                        10
                    ]
                },
                {
                    "label": [
                        12,
                        33
                    ]
                },
                {
                    "label": [
                        35,
                        51
                    ]
                }
            ],
            "activeParameter": 0
        },
        {
            "label": "(base: int, exp: int, mod: None = None) -> Any",
            "parameters": [
                {
                    "label": [
                        1,
                        10
                    ]
                },
                {
                    "label": [
                        12,
                        20
                    ]
                },
                {
                    "label": [
                        22,
                        38
                    ]
                }
            ],
            "activeParameter": 0
        },
        {
            "label": "(base: _PositiveInteger, exp: float, mod: None = None) -> float",
            "parameters": [
                {
                    "label": [
                        1,
                        23
                    ]
                },
                {
                    "label": [
                        25,
                        35
                    ]
                },
                {
                    "label": [
                        37,
                        53
                    ]
                }
            ],
            "activeParameter": 0
        },
        {
            "label": "(base: _NegativeInteger, exp: float, mod: None = None) -> complex",
            "parameters": [
                {
                    "label": [
                        1,
                        23
                    ]
                },
                {
                    "label": [
                        25,
                        35
                    ]
                },
                {
                    "label": [
                        37,
                        53
                    ]
                }
            ],
            "activeParameter": 0
        },
        {
            "label": "(base: float, exp: int, mod: None = None) -> float",
            "parameters": [
                {
                    "label": [
                        1,
                        12
                    ]
                },
                {
                    "label": [
                        14,
                        22
                    ]
                },
                {
                    "label": [
                        24,
                        40
                    ]
                }
            ],
            "activeParameter": 0
        },
        {
            "label": "(base: float, exp: _SupportsSomeKindOfPow | complex, mod: None = None) -> Any",
            "parameters": [
                {
                    "label": [
                        1,
                        12
                    ]
                },
                {
                    "label": [
                        14,
                        51
                    ]
                },
                {
                    "label": [
                        53,
                        69
                    ]
                }
            ],
            "activeParameter": 0
        },
        {
            "label": "(base: complex, exp: _SupportsSomeKindOfPow | complex, mod: None = None) -> complex",
            "parameters": [
                {
                    "label": [
                        1,
                        14
                    ]
                },
                {
                    "label": [
                        16,
                        53
                    ]
                },
                {
                    "label": [
                        55,
                        71
                    ]
                }
            ],
            "activeParameter": 0
        },
        {
            "label": "(base: _SupportsPow2[_E@pow, _T_co@pow], exp: _E@pow, mod: None = None) -> _T_co@pow",
            "parameters": [
                {
                    "label": [
                        1,
                        39
                    ]
                },
                {
                    "label": [
                        41,
                        52
                    ]
                },
                {
                    "label": [
                        54,
                        70
                    ]
                }
            ],
            "activeParameter": 0
        },
        {
            "label": "(base: _SupportsPow3NoneOnly[_E@pow, _T_co@pow], exp: _E@pow, mod: None = None) -> _T_co@pow",
            "parameters": [
                {
                    "label": [
                        1,
                        47
                    ]
                },
                {
                    "label": [
                        49,
                        60
                    ]
                },
                {
                    "label": [
                        62,
                        78
                    ]
                }
            ],
            "activeParameter": 0
        },
        {
            "label": "(base: _SupportsPow3[_E@pow, _M@pow, _T_co@pow], exp: _E@pow, mod: _M@pow) -> _T_co@pow",
            "parameters": [
                {
                    "label": [
                        1,
                        47
                    ]
                },
                {
                    "label": [
                        49,
                        60
                    ]
                },
                {
                    "label": [
                        62,
                        73
                    ]
                }
            ],
            "activeParameter": 0
        },
        {
            "label": "(base: _SupportsSomeKindOfPow, exp: float, mod: None = None) -> Any",
            "parameters": [
                {
                    "label": [
                        1,
                        29
                    ]
                },
                {
                    "label": [
                        31,
                        41
                    ]
                },
                {
                    "label": [
                        43,
                        59
                    ]
                }
            ],
            "activeParameter": 0
        },
        {
            "label": "(base: _SupportsSomeKindOfPow, exp: complex, mod: None = None) -> complex",
            "parameters": [
                {
                    "label": [
                        1,
                        29
                    ]
                },
                {
                    "label": [
                        31,
                        43
                    ]
                },
                {
                    "label": [
                        45,
                        61
                    ]
                }
            ],
            "activeParameter": 0
        }
    ],
    "activeSignature": 0,
    "activeParameter": 0
}


[Trace - 14:49:45.695] Sending request 'textDocument/signatureHelp - (3)'.
Params: {
    "textDocument": {
        "uri": "file:///home/agentx3/TEMP/pyright-test/code.py"
    },
    "position": {
        "line": 0,
        "character": 6
    }
}


[Trace - 14:49:45.695] Received response 'textDocument/documentHighlight - (2)' in 5506ms. Request failed: request cancelled (-32800).
[Error - 14:49:45.695] Sending request textDocument/documentHighlight failed.
  Message: request cancelled
  Code: -32800 
[Trace - 14:49:50.360] Sending request 'textDocument/signatureHelp - (4)'.
Params: {
    "textDocument": {
        "uri": "file:///home/agentx3/TEMP/pyright-test/code.py"
    },
    "position": {
        "line": 0,
        "character": 4
    }
}


[Trace - 14:49:54.303] Received response 'textDocument/signatureHelp - (3)' in 8608ms.
Result: {
    "signatures": [
        {
            "label": "(base: int, exp: int, mod: int) -> int",
            "parameters": [
                {
                    "label": [
                        1,
                        10
                    ]
                },
                {
                    "label": [
                        12,
                        20
                    ]
                },
                {
                    "label": [
                        22,
                        30
                    ]
                }
            ],
            "activeParameter": 1
        },
        {
            "label": "(base: int, exp: Literal[0], mod: None = None) -> Literal[1]",
            "parameters": [
                {
                    "label": [
                        1,
                        10
                    ]
                },
                {
                    "label": [
                        12,
                        27
                    ]
                },
                {
                    "label": [
                        29,
                        45
                    ]
                }
            ],
            "activeParameter": 1
        },
        {
            "label": "(base: int, exp: _PositiveInteger, mod: None = None) -> int",
            "parameters": [
                {
                    "label": [
                        1,
                        10
                    ]
                },
                {
                    "label": [
                        12,
                        33
                    ]
                },
                {
                    "label": [
                        35,
                        51
                    ]
                }
            ],
            "activeParameter": 1
        },
        {
            "label": "(base: int, exp: _NegativeInteger, mod: None = None) -> float",
            "parameters": [
                {
                    "label": [
                        1,
                        10
                    ]
                },
                {
                    "label": [
                        12,
                        33
                    ]
                },
                {
                    "label": [
                        35,
                        51
                    ]
                }
            ],
            "activeParameter": 1
        },
        {
            "label": "(base: int, exp: int, mod: None = None) -> Any",
            "parameters": [
                {
                    "label": [
                        1,
                        10
                    ]
                },
                {
                    "label": [
                        12,
                        20
                    ]
                },
                {
                    "label": [
                        22,
                        38
                    ]
                }
            ],
            "activeParameter": 1
        },
        {
            "label": "(base: _PositiveInteger, exp: float, mod: None = None) -> float",
            "parameters": [
                {
                    "label": [
                        1,
                        23
                    ]
                },
                {
                    "label": [
                        25,
                        35
                    ]
                },
                {
                    "label": [
                        37,
                        53
                    ]
                }
            ],
            "activeParameter": 1
        },
        {
            "label": "(base: _NegativeInteger, exp: float, mod: None = None) -> complex",
            "parameters": [
                {
                    "label": [
                        1,
                        23
                    ]
                },
                {
                    "label": [
                        25,
                        35
                    ]
                },
                {
                    "label": [
                        37,
                        53
                    ]
                }
            ],
            "activeParameter": 1
        },
        {
            "label": "(base: float, exp: int, mod: None = None) -> float",
            "parameters": [
                {
                    "label": [
                        1,
                        12
                    ]
                },
                {
                    "label": [
                        14,
                        22
                    ]
                },
                {
                    "label": [
                        24,
                        40
                    ]
                }
            ],
            "activeParameter": 1
        },
        {
            "label": "(base: float, exp: _SupportsSomeKindOfPow | complex, mod: None = None) -> Any",
            "parameters": [
                {
                    "label": [
                        1,
                        12
                    ]
                },
                {
                    "label": [
                        14,
                        51
                    ]
                },
                {
                    "label": [
                        53,
                        69
                    ]
                }
            ],
            "activeParameter": 1
        },
        {
            "label": "(base: complex, exp: _SupportsSomeKindOfPow | complex, mod: None = None) -> complex",
            "parameters": [
                {
                    "label": [
                        1,
                        14
                    ]
                },
                {
                    "label": [
                        16,
                        53
                    ]
                },
                {
                    "label": [
                        55,
                        71
                    ]
                }
            ],
            "activeParameter": 1
        },
        {
            "label": "(base: _SupportsPow2[_E@pow, _T_co@pow], exp: _E@pow, mod: None = None) -> _T_co@pow",
            "parameters": [
                {
                    "label": [
                        1,
                        39
                    ]
                },
                {
                    "label": [
                        41,
                        52
                    ]
                },
                {
                    "label": [
                        54,
                        70
                    ]
                }
            ],
            "activeParameter": 1
        },
        {
            "label": "(base: _SupportsPow3NoneOnly[_E@pow, _T_co@pow], exp: _E@pow, mod: None = None) -> _T_co@pow",
            "parameters": [
                {
                    "label": [
                        1,
                        47
                    ]
                },
                {
                    "label": [
                        49,
                        60
                    ]
                },
                {
                    "label": [
                        62,
                        78
                    ]
                }
            ],
            "activeParameter": 1
        },
        {
            "label": "(base: _SupportsPow3[_E@pow, _M@pow, _T_co@pow], exp: _E@pow, mod: _M@pow) -> _T_co@pow",
            "parameters": [
                {
                    "label": [
                        1,
                        47
                    ]
                },
                {
                    "label": [
                        49,
                        60
                    ]
                },
                {
                    "label": [
                        62,
                        73
                    ]
                }
            ],
            "activeParameter": 1
        },
        {
            "label": "(base: _SupportsSomeKindOfPow, exp: float, mod: None = None) -> Any",
            "parameters": [
                {
                    "label": [
                        1,
                        29
                    ]
                },
                {
                    "label": [
                        31,
                        41
                    ]
                },
                {
                    "label": [
                        43,
                        59
                    ]
                }
            ],
            "activeParameter": 1
        },
        {
            "label": "(base: _SupportsSomeKindOfPow, exp: complex, mod: None = None) -> complex",
            "parameters": [
                {
                    "label": [
                        1,
                        29
                    ]
                },
                {
                    "label": [
                        31,
                        43
                    ]
                },
                {
                    "label": [
                        45,
                        61
                    ]
                }
            ],
            "activeParameter": 1
        }
    ],
    "activeSignature": 0,
    "activeParameter": 1
}


[Trace - 14:49:54.304] Sending request 'textDocument/signatureHelp - (5)'.
Params: {
    "textDocument": {
        "uri": "file:///home/agentx3/TEMP/pyright-test/code.py"
    },
    "position": {
        "line": 0,
        "character": 9
    }
}

@agentx3
Copy link
Author

agentx3 commented Jun 17, 2024

In general it seems like the performance has slowed down greatly. For example, even

import json
f = open("msg.json", "r")
msg = json.load(f)

takes sometime to load (~30s), but the pow was the most extreme case. So it might be a symptom of a larger issue

@agentx3
Copy link
Author

agentx3 commented Jun 18, 2024

OK, I think I found the culprit after spending a bunch of time messing with the settings. The issue goes away when I set inlayHints.parameterTypes = false, so it's probably something about how that's implemented. I'm happy to have this marked as closed if you are.

@fannheyward
Copy link
Owner

fannheyward commented Jun 18, 2024

coc-pyright uses getCallNodeAndActiveParameterIndex from Pyright to add parameter inlayHint, and Pyright is slow on this case, we can't do anything for this by now. Leave this open for future debugging.

@ammen99
Copy link

ammen99 commented Aug 8, 2024

I also am encountering the same issue with latest coc-pyright, spent like a day trying to figure out what is going on, indeed, something like a single open() call is enough to make pyright use lots of CPU. However it seems that this is a problem only for some functions and not for others - i.e calling json.dumps() seems to not cause any issues. Is there already a pyright issue (if this is indeed a problem with pyright)?

@Krzmbrzl
Copy link

Has there been any report to the Pyright maintainers with specifics of what exactly is taking so insanely long? I was unable to find any mention of getCallNodeAndActiveParameterIndex in the official Pyright repository and don't have enough context to actually create an issue about this performance problem.

@fannheyward
Copy link
Owner

@Krzmbrzl it's getCallNodeAndActiveParamIndex function now.

I haven't reported this to the Pyright repository because the function is internal and coc-pyright used this in a hack way. Pyright uses TypeEvaluator to analyze and compute parameters typing, but coc-pyright can't use this, instead coc-pyright use the getCallNodeAndActiveParamIndex function which is expensive on some time.

@owocado
Copy link

owocado commented Jan 18, 2025

I am also experiencing similar issue where if the open .py file has too many getattr() calls defined, it significantly slows down displaying inlay hints and CPU usage spikes to 90% to 100%

I was scratching my forehead very hard since few days thinking it was an issue with my wifi/router connection, then it took me a while to debug this and search for this in this repo.

coc-pyright v1.1.390
NVIM v0.9.5

Terr added a commit to Terr/dotfiles-vim that referenced this issue Jan 29, 2025
coc-pyright is often stuck at 100% CPU for minutes when it encounters
certain functions, probably while generating inlay type hints.
(see fannheyward/coc-pyright#1087)

pyright itself doesn't provide these hints (MS keeps that feature hidden
in the closed-source pylance VS Code extension), but the fork
basedpyright does. Performance has been good so far, so switch to using
that language server directly from coc.nvim

coc-pyright also handled linting / formatting via e.g. ruff, so that
functionality needs to be replaced as well.

efm-languageserver acts like a proxy between LSP clients and linting /
formatting tools. Multiple tools can be configured per language to
provide linting suggestions or formatting files.

coc.nvim is okay with running multiple language servers for a filetype,
so basedpyright and efm-languageserver can be used together.
@Terr
Copy link

Terr commented Jan 30, 2025

Oh, my dotfiles commit showed up here. I had to replace coc-pyright for now because of these performance reasons.

I switched to using basedpyright because the original pyright, as mentioned, doesn't do inlay hints.

Maybe this language server could also be something for coc-pyright? It's a true fork though so it has new checks and different defaults which might be a very unexpected change for users if this project would suddenly switch to it.

It is, however, very performant.

@Cnly
Copy link

Cnly commented Jan 31, 2025

@Terr thanks for sharing! I just checked and there seems to be https://github.com/fannheyward/coc-basedpyright which looks like worth trying out

@Terr
Copy link

Terr commented Jan 31, 2025

@Cnly Great find! I didn't see it in the coc extensions list and didn't think to look further.

I'm going to give it a try :)

Edit: it works very well. I would say the same using basedpyright-langserver directly.

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

No branches or pull requests

7 participants