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

Analysis of nested OrderedDicts is very slow #767

Closed
smphhh opened this issue Dec 23, 2020 · 3 comments
Closed

Analysis of nested OrderedDicts is very slow #767

smphhh opened this issue Dec 23, 2020 · 3 comments
Labels
fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@smphhh
Copy link

smphhh commented Dec 23, 2020

Environment data

  • Language Server version: 2020.12.2
  • OS and version: MacOS 10.15.5
  • Python version (& distribution if applicable, e.g. Anaconda): 3.7.8 via pyenv

Expected behaviour

Analysis should complete very quickly after making edits to the file

Actual behaviour

In a VS Code project with a single seemingly simple Python file (see below) and a clean virtualenv with no dependencies any edits to the file cause the Pylance analysis to take multiple seconds.

Logs

I believe the following lines are relevant:

Info  - 10:53:06 AM] [BG(1)] Long operation: checking: /xxx/pylance-test/main.py (3945ms)
[Info  - 10:53:06 AM] [BG(1)] Long operation: analyzing: /xxx/pylance-test/main.py (3945ms)

Code Snippet / Additional information

from collections import OrderedDict

a = OrderedDict([
    ("c1", OrderedDict([
        ("c2", [
            OrderedDict([
                ("key", "k1"),
                ("name", "v1"),
                ("c3", [
                    OrderedDict([
                        ("c4", [
                            OrderedDict([
                                (
                                    "key",
                                    "k2",
                                ),
                                (
                                    "value",
                                    "v2",
                                ),
                                (
                                    "language",
                                    "foo",
                                ),
                                (
                                    "startDate",
                                    "1800-01-01T00:00:00.000+02:00",
                                ),
                            ]),
                        ])
                    ])
                ]),
            ])
        ]),
    ]))
])
@erictraut
Copy link
Contributor

Thanks for the bug report. Although it's not obvious from the bug title, I'm pretty sure this is the same issue as #590 (comment), which I'm actively working on. Let's leave this one open until I confirm that they're both the same underlying problem.

@judej judej added the needs investigation Could be an issue - needs investigation label Dec 23, 2020
@github-actions github-actions bot removed the triage label Dec 23, 2020
@erictraut
Copy link
Contributor

I've added some additional internal caching to handle deeply-nested expressions of this sort. The above example previously took about 2800ms to analyze. With the new caching in place, it's now down to about 500ms. This fix will be in the next release of Pylance.

@erictraut erictraut added fixed in next version (main) A fix has been implemented and will appear in an upcoming version and removed needs investigation Could be an issue - needs investigation labels Dec 24, 2020
@jakebailey
Copy link
Member

This issue has been fixed in version 2021.1.0, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202110-6-january-2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed in next version (main) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

4 participants