Coder Social home page Coder Social logo

Comments (4)

laike9m avatar laike9m commented on June 19, 2024

I added some logging:

0_check_with_pyright_start: "01:34:10.683"
1_pyright_run_start: "01:34:10.684"
2_pyright_run_end: "01:34:38.457"

Logging is added in

time_table["1_pyright_run_start"] = get_current_time()
raw_result = subprocess.run(
["pyright", "--pythonversion", "3.12", temp.name],
capture_output=True,
text=True,
).stdout
time_table["2_pyright_run_end"] = get_current_time()
error_lines: list[str] = []

It's clear that pyright takes 28s to finish!

Given subsequent runs take significantly less time, I think this is due to pyright needs to generate indexes and cache the first time it runs.

Given we don't really need to analyze third-party libraries installed in the virtualenv (which pyright does by default), I'll see how can we disable this behavior.

from python-type-challenges.

laike9m avatar laike9m commented on June 19, 2024

Further adding --stats to pyright gives and reran

Overall takes ~27s

1_pyright_run_start: "02:18:28.676"
2_pyright_run_end: "02:18:55.150"

Detailed:

added 1 package, and audited 2 packages in 14s

found 0 vulnerabilities
Loading pyproject.toml file at /app/pyproject.toml
Found 1 source file
pyright 1.1.334
/tmp/tmpn3_n1gxk.py
  /tmp/tmpn3_n1gxk.py:13:8 - error: Expected 1 positional argument (reportGeneralTypeIssues)
1 error, 0 warnings, 0 informations 
Completed in 1.903sec

Analysis stats
Total files parsed and bound: 18
Total files checked: 1

Timing stats
Find Source Files:    0sec
Read Source Files:    0.08sec
Tokenize:             0.14sec
Parse:                0.32sec
Resolve Imports:      0.18sec
Bind:                 0.58sec
Check:                0.06sec
Detect Cycles:        0sec
WARNING: there is a new pyright version available (v1.1.334 -> v1.1.337).
Please install the new version or set PYRIGHT_PYTHON_FORCE_VERSION to `latest`

So out of 27s, installing node packages takes 14s, analyzing takes 2s. It's still unclear where the other 10s is spent on, but at least we know installing node packages is the biggest contributor to slow run

from python-type-challenges.

laike9m avatar laike9m commented on June 19, 2024

Reading https://github.com/microsoft/pyright/blob/main/docs/configuration.md, I can't find any option to pre-install node_modules. It mentions ignoring files when analyzing, but since we only checked one file (see above), I don't think this will help.

Given that, seems the only way is to simply pre-run pyright upon server start, to warm things up.

from python-type-challenges.

laike9m avatar laike9m commented on June 19, 2024

Tested on the debug branch and it worked well.

from python-type-challenges.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.