microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.29k stars 1.18k forks source link

`autoTestDiscoverOnSaveEnabled` setting causing significant decreases in VS Code performance #21446

Closed mudit2812 closed 1 year ago

mudit2812 commented 1 year ago

Type: Bug

I ran extension bisect to figure out which extension was causing trouble with the performance of VS Code on my machine. Extension Bisect led to detecting vscode-python (and associated extensions pylint, isort, pylance) to be the problem causers. The troubles I commonly encounter include:

The only way I can fix performance is by reloading the window, which I have to do over 10 times a day because the slowdowns are very consistent. This is a big headache for me as I code almost exclusively in Python.

Extension version: 2023.10.1 VS Code version: Code 1.79.0 (Universal) (b380da4ef1ee00e224a15c1d4d9793e27c2b6302, 2023-06-07T14:29:00.206Z) OS version: Darwin arm64 22.5.0 Modes:

System Info |Item|Value| |---|---| |CPUs|Apple M1 (8 x 24)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|3, 2, 2| |Memory (System)|16.00GB (0.15GB free)| |Process Argv|--crash-reporter-id 0bdbd0bc-c581-437f-8eff-d3312dcce3ec| |Screen Reader|no| |VM|0%|
A/B Experiments ``` vsliv368:30146709 vsreu685:30147344 python383cf:30185419 vspor879:30202332 vspor708:30202333 vspor363:30204092 vswsl492:30256859 vslsvsres303:30308271 vserr242cf:30382550 pythontb:30283811 vsjup518:30340749 pythonptprofiler:30281270 vshan820:30294714 vstes263cf:30335440 vscoreces:30445986 vscod805cf:30301675 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 vsaa593cf:30376535 pythonvs932:30410667 vsclangdf:30486550 c4g48928:30535728 dsvsc012:30540252 pynewext54:30695312 azure-dev_surveyone:30548225 3biah626:30602489 pyind779:30671433 f6dab269:30613381 pythonsymbol12:30671437 a9j8j154:30646983 showlangstatbar:30737416 vsctsb:30748421 pythonms35:30701012 03d35959:30757346 pythonfmttext:30731395 pythoncmv:30756943 fixshowwlkth:30730052 showindicator:30766890 pythongtdpath:30739704 i26e3531:30763805 dh2dc718:30763024 ```
karthiknadig commented 1 year ago

This might be due to file system watching, can you enable these logs to see if it is being triggered to often. Would it be possible for you to provide a minimal repro or a repository that we can use to repro this.

Logging (local) !!! This is ONLY when you open a local workspace, for remote see below !!! We provide logging for file events when you enable verbose logging. Steps are:

image

Logging (remote) !!! This is ONLY when you open a remote workspace (WSL, Docker, SSH), for local see above !!! We provide logging for file events when you enable verbose logging. Steps are:

image

mudit2812 commented 1 year ago

I set the

"python.testing.autoTestDiscoverOnSaveEnabled": true

setting to false and the slowdown disappeared completely. I will enable it and attach the file watcher output once I'm able to replicate the error.

Would it be possible for you to provide a minimal repro or a repository that we can use to repro this.

I'm working on the PennyLane repository. There are a lot of tests, which could be why this setting being enabled impacts performance so much.

mudit2812 commented 1 year ago

Here's a snippet of the file watcher when I was noticing the performance degradation. The two major things I noticed were:

log.ts:401 TRACE [File Watcher (parcel)] [DELETED] /Users/mudit.pandey/repos/braket-plugin-fork/.tox/unit-tests/log/2-commands[0].log
log.ts:401 TRACE [File Watcher (parcel)]  >> normalized [DELETED] /Users/mudit.pandey/repos/braket-plugin-fork/.tox/unit-tests/log/2-commands[0].log
log.ts:401 TRACE [File Watcher (parcel)]  >> normalized [CHANGED] /Users/mudit.pandey/repos/braket-plugin-fork/.tox/unit-tests/log/1-install_package.log
log.ts:401 TRACE [File Watcher (parcel)] [ADDED] /Users/mudit.pandey/repos/braket-plugin-fork/test/unit_tests/__pycache__/test_translation.cpython-310-pytest-7.4.0.pyc
log.ts:401 TRACE [File Watcher (parcel)] [DELETED] /Users/mudit.pandey/repos/braket-plugin-fork/test/unit_tests/__pycache__/test_translation.cpython-310-pytest-7.4.0.pyc.83295
log.ts:401 TRACE [File Watcher (parcel)] [DELETED] /Users/mudit.pandey/repos/braket-plugin-fork/test/unit_tests/__pycache__/test_translation.cpython-310-pytest-7.4.0.pyc.83298
log.ts:401 TRACE [File Watcher (parcel)] [DELETED] /Users/mudit.pandey/repos/braket-plugin-fork/test/unit_tests/__pycache__/test_translation.cpython-310-pytest-7.4.0.pyc.83299
log.ts:401 TRACE [File Watcher (parcel)] [DELETED] /Users/mudit.pandey/repos/braket-plugin-fork/test/unit_tests/__pycache__/test_translation.cpython-310-pytest-7.4.0.pyc.83302
log.ts:401 TRACE [File Watcher (parcel)] [DELETED] /Users/mudit.pandey/repos/braket-plugin-fork/test/unit_tests/__pycache__/test_translation.cpython-310-pytest-7.4.0.pyc.83306
log.ts:401 TRACE [File Watcher (parcel)] [DELETED] /Users/mudit.pandey/repos/braket-plugin-fork/test/unit_tests/__pycache__/test_translation.cpython-310-pytest-7.4.0.pyc.83309
log.ts:401 TRACE [File Watcher (parcel)] [ADDED] /Users/mudit.pandey/repos/braket-plugin-fork/test/unit_tests/__pycache__/test_translation.cpython-310-pytest-7.4.0.pyc
log.ts:401 TRACE [File Watcher (parcel)] [DELETED] /Users/mudit.pandey/repos/braket-plugin-fork/test/unit_tests/__pycache__/test_translation.cpython-310-pytest-7.4.0.pyc.83298
log.ts:401 TRACE [File Watcher (parcel)] [DELETED] /Users/mudit.pandey/repos/braket-plugin-fork/test/unit_tests/__pycache__/test_translation.cpython-310-pytest-7.4.0.pyc.83300
log.ts:401 TRACE [File Watcher (parcel)] [DELETED] /Users/mudit.pandey/repos/braket-plugin-fork/test/unit_tests/__pycache__/test_translation.cpython-310-pytest-7.4.0.pyc.83301
log.ts:401 TRACE [File Watcher (parcel)]  >> normalized [DELETED] /Users/mudit.pandey/repos/braket-plugin-fork/test/unit_tests/__pycache__/test_translation.cpython-310-pytest-7.4.0.pyc.83295
log.ts:401 TRACE [File Watcher (parcel)]  >> normalized [DELETED] /Users/mudit.pandey/repos/braket-plugin-fork/test/unit_tests/__pycache__/test_translation.cpython-310-pytest-7.4.0.pyc.83298
log.ts:401 TRACE [File Watcher (parcel)]  >> normalized [DELETED] /Users/mudit.pandey/repos/braket-plugin-fork/test/unit_tests/__pycache__/test_translation.cpython-310-pytest-7.4.0.pyc.83299
log.ts:401 TRACE [File Watcher (parcel)]  >> normalized [DELETED] /Users/mudit.pandey/repos/braket-plugin-fork/test/unit_tests/__pycache__/test_translation.cpython-310-pytest-7.4.0.pyc.83302
log.ts:401 TRACE [File Watcher (parcel)]  >> normalized [DELETED] /Users/mudit.pandey/repos/braket-plugin-fork/test/unit_tests/__pycache__/test_translation.cpython-310-pytest-7.4.0.pyc.83306
log.ts:401 TRACE [File Watcher (parcel)]  >> normalized [DELETED] /Users/mudit.pandey/repos/braket-plugin-fork/test/unit_tests/__pycache__/test_translation.cpython-310-pytest-7.4.0.pyc.83309
log.ts:401 TRACE [File Watcher (parcel)]  >> normalized [DELETED] /Users/mudit.pandey/repos/braket-plugin-fork/test/unit_tests/__pycache__/test_translation.cpython-310-pytest-7.4.0.pyc.83300
log.ts:401 TRACE [File Watcher (parcel)]  >> normalized [DELETED] /Users/mudit.pandey/repos/braket-plugin-fork/test/unit_tests/__pycache__/test_translation.cpython-310-pytest-7.4.0.pyc.83301
log.ts:401 TRACE [File Watcher (parcel)]  >> normalized [ADDED] /Users/mudit.pandey/repos/braket-plugin-fork/test/unit_tests/__pycache__/test_translation.cpython-310-pytest-7.4.0.pyc
log.ts:401 TRACE [File Watcher (parcel)] [ADDED] /Users/mudit.pandey/repos/braket-plugin-fork/.coverage.MacBookAir-FVFG339QQ6LR.83301.031808
log.ts:401 TRACE [File Watcher (parcel)] [ADDED] /Users/mudit.pandey/repos/braket-plugin-fork/.coverage.MacBookAir-FVFG339QQ6LR.83306.705163
log.ts:401 TRACE [File Watcher (parcel)]  >> normalized [ADDED] /Users/mudit.pandey/repos/braket-plugin-fork/.coverage.MacBookAir-FVFG339QQ6LR.83301.031808
log.ts:401 TRACE [File Watcher (parcel)]  >> normalized [ADDED] /Users/mudit.pandey/repos/braket-plugin-fork/.coverage.MacBookAir-FVFG339QQ6LR.83306.705163
log.ts:401 TRACE [File Watcher (parcel)] [ADDED] /Users/mudit.pandey/repos/braket-plugin-fork/.coverage.MacBookAir-FVFG339QQ6LR.83299.207696
log.ts:401 TRACE [File Watcher (parcel)] [ADDED] /Users/mudit.pandey/repos/braket-plugin-fork/.coverage.MacBookAir-FVFG339QQ6LR.83300.822956
log.ts:401 TRACE [File Watcher (parcel)] [CHANGED] /Users/mudit.pandey/repos/braket-plugin-fork/.coverage.MacBookAir-FVFG339QQ6LR.83301.031808
log.ts:401 TRACE [File Watcher (parcel)] [CHANGED] /Users/mudit.pandey/repos/braket-plugin-fork/.coverage.MacBookAir-FVFG339QQ6LR.83306.705163
log.ts:401 TRACE [File Watcher (parcel)]  >> normalized [ADDED] /Users/mudit.pandey/repos/braket-plugin-fork/.coverage.MacBookAir-FVFG339QQ6LR.83299.207696
log.ts:401 TRACE [File Watcher (parcel)]  >> normalized [ADDED] /Users/mudit.pandey/repos/braket-plugin-fork/.coverage.MacBookAir-FVFG339QQ6LR.83300.822956
log.ts:401 TRACE [File Watcher (parcel)]  >> normalized [CHANGED] /Users/mudit.pandey/repos/braket-plugin-fork/.coverage.MacBookAir-FVFG339QQ6LR.83301.031808
log.ts:401 TRACE [File Watcher (parcel)]  >> normalized [CHANGED] /Users/mudit.pandey/repos/braket-plugin-fork/.coverage.MacBookAir-FVFG339QQ6LR.83306.705163
log.ts:401 TRACE [File Watcher (parcel)] [ADDED] /Users/mudit.pandey/repos/braket-plugin-fork/.coverage.MacBookAir-FVFG339QQ6LR.83298.055672
log.ts:401 TRACE [File Watcher (parcel)]  >> normalized [ADDED] /Users/mudit.pandey/repos/braket-plugin-fork/.coverage.MacBookAir-FVFG339QQ6LR.83298.055672
log.ts:401 TRACE [File Watcher (parcel)] [CHANGED] /Users/mudit.pandey/repos/braket-plugin-fork/.coverage.MacBookAir-FVFG339QQ6LR.83298.055672
log.ts:401 TRACE [File Watcher (parcel)] [ADDED] /Users/mudit.pandey/repos/braket-plugin-fork/.coverage.MacBookAir-FVFG339QQ6LR.83302.070035
log.ts:401 TRACE [File Watcher (parcel)]  >> normalized [CHANGED] /Users/mudit.pandey/repos/braket-plugin-fork/.coverage.MacBookAir-FVFG339QQ6LR.83298.055672
log.ts:401 TRACE [File Watcher (parcel)]  >> normalized [ADDED] /Users/mudit.pandey/repos/braket-plugin-fork/.coverage.MacBookAir-FVFG339QQ6LR.83302.070035
log.ts:401 TRACE [File Watcher (parcel)] [ADDED] /Users/mudit.pandey/repos/braket-plugin-fork/.coverage.MacBookAir-FVFG339QQ6LR.83309.636014
log.ts:401 TRACE [File Watcher (parcel)]  >> normalized [ADDED] /Users/mudit.pandey/repos/braket-plugin-fork/.coverage.MacBookAir-FVFG339QQ6LR.83309.636014
log.ts:401 TRACE [File Watcher (parcel)] [ADDED] /Users/mudit.pandey/repos/braket-plugin-fork/.coverage
log.ts:401 TRACE [File Watcher (parcel)] [ADDED] /Users/mudit.pandey/repos/braket-plugin-fork/.coverage.MacBookAir-FVFG339QQ6LR.83295.542263
log.ts:401 TRACE [File Watcher (parcel)] [DELETED] /Users/mudit.pandey/repos/braket-plugin-fork/.coverage.MacBookAir-FVFG339QQ6LR.83299.207696
log.ts:401 TRACE [File Watcher (parcel)] [DELETED] /Users/mudit.pandey/repos/braket-plugin-fork/.coverage.MacBookAir-FVFG339QQ6LR.83300.822956
log.ts:401 TRACE [File Watcher (parcel)] [DELETED] /Users/mudit.pandey/repos/braket-plugin-fork/.coverage.MacBookAir-FVFG339QQ6LR.83302.070035
log.ts:401 
karthiknadig commented 1 year ago

I think there might be two different problems here:

  1. I think the filtering for file watching should exclude pyc I think this might be causing the problem.
  2. For the Git extension issue it might be independent of this

/cc @eleanorjboyd Could you take a look at the pattern we use for file system watching in testing to see if we get *.pyc events?

eleanorjboyd commented 1 year ago

closing since the fix will be the same as https://github.com/microsoft/vscode-python/issues/21014. Thanks!