Performance issue in REPL (70x slower)

I’m not sure exactly when this happened, but at some point, running code in the VS Code REPL became incredibly slow. A simple test I’ve been using to verify this is the mul!() function as below, but all code I’ve tried has been significantly slower in the REPL. I’ve tried updating from Windows 10 to Windows 11, uninstalling and reinstalling VS Code, the Julia extension, compulsively keeping everying up to date, and uninstalling almost all other extensions, but so far nothing has helped. My VS Code and Julia Extension are fully up to date (1.95.3 and 1.127.2 respectively), but this has been going on for a couple months, so it doesn’t seem tied to a particular version. Hopefully this is just me doing something dumb, but any advice you can give on how I might figure this out and fix it would be incredibly helpful.

using LinearAlgebra, BenchmarkTools

function testmul!(a,b,c)
    mul!(a,b,c)
end

a = rand(10);
b = rand(10,10);
c = rand(10);

@benchmark testmul!(a,b,c)

From the REPL, I get the following:

BenchmarkTools.Trial: 10000 samples with 7 evaluations.
 Range (min … max):  4.729 μs …   9.271 μs  ┊ GC (min … max): 0.00% … 0.00%
 Time  (median):     4.800 μs               ┊ GC (median):    0.00%
 Time  (mean ± σ):   4.818 μs ± 187.393 ns  ┊ GC (mean ± σ):  0.00% ± 0.00%

    ▁▄▆█▄
  ▂▅█████▁▇▃▃▃▄▄▁▃▂▂▂▂▂▁▁▁▁▂▂▁▁▁▂▂▁▁▂▂▁▂▂▂▁▂▂▂▁▂▂▂▂▂▂▁▂▂▂▂▂▂▂ ▃
  4.73 μs         Histogram: frequency by time        5.46 μs <

 Memory estimate: 0 bytes, allocs estimate: 0.

julia> versioninfo()
Julia Version 1.11.1
Commit 8f5b7ca12a (2024-10-16 10:53 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 12 × AMD Ryzen 5 5600X 6-Core Processor
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, znver3)
Threads: 12 default, 0 interactive, 6 GC (on 12 virtual cores)
Environment:
  JULIA_EDITOR = code

but from a terminal within VS Code, or even outside of VS Code, I get a much faster result, like this one taken from a terminal opened within VS Code:

BenchmarkTools.Trial: 10000 samples with 982 evaluations.
 Range (min … max):  62.831 ns … 170.061 ns  ┊ GC (min … max): 0.00% … 0.00%
 Time  (median):     64.969 ns               ┊ GC (median):    0.00%
 Time  (mean ± σ):   65.656 ns ±   4.672 ns  ┊ GC (mean ± σ):  0.00% ± 0.00%

      ▃█▁
  ▂▂▃▄███▇▅▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▁▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂ ▂
  62.8 ns         Histogram: frequency by time         85.2 ns <

 Memory estimate: 0 bytes, allocs estimate: 0.


julia> versioninfo()
Julia Version 1.11.1
Commit 8f5b7ca12a (2024-10-16 10:53 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 12 × AMD Ryzen 5 5600X 6-Core Processor
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, znver3)
Threads: 1 default, 0 interactive, 1 GC (on 12 virtual cores)

I’ve also tested it using julia --threads=auto and the results are the same outside of the REPL despite the different number of threads used.

All of this was done on a fresh environment with the following Project and Manifest
Project:

[6e4b80f9] BenchmarkTools v1.5.0

Manifest:

  [6e4b80f9] BenchmarkTools v1.5.0
  [682c06a0] JSON v0.21.4
  [69de0a69] Parsers v2.8.1
  [aea7be01] PrecompileTools v1.2.1
  [21216c6a] Preferences v1.4.3
  [10745b16] Statistics v1.11.1
  [56f22d72] Artifacts v1.11.0
  [ade2ca70] Dates v1.11.0
  [8f399da3] Libdl v1.11.0
  [37e2e46d] LinearAlgebra v1.11.0
  [56ddb016] Logging v1.11.0
  [a63ad114] Mmap v1.11.0
  [de0858da] Printf v1.11.0
  [9abbd945] Profile v1.11.0
  [9a3f8284] Random v1.11.0
  [ea8e919c] SHA v0.7.0
  [fa267f1f] TOML v1.0.3
  [cf7118a7] UUIDs v1.11.0
  [4ec0a83e] Unicode v1.11.0
  [e66e0078] CompilerSupportLibraries_jll v1.1.1+0
  [4536629a] OpenBLAS_jll v0.3.27+1
  [8e850b90] libblastrampoline_jll v5.11.0+0
1 Like

Silly question but are you sure you’re not running within the debugger?

Fairly sure. I use shift+enter to interactively run code from files, or type it directly into the Julia REPL terminal. Is there some setting that would send everything through the debugger?

I’ve noticed that typing into the REPL often hangs, making me feel like it’s doing something in the background, but I’m not sure how to check what is happening if anything. For example, typing ]st sometimes takes several seconds for it to show in the REPL, and more than a minute to print results, whereas from a normal terminal it’s basically instantaneous.

If it helps, I get “fast” results using ipynb files as well, so it really is just the REPL that’s slow for me.

Perhaps some Julia VS Code extension setting is to blame? What’s your settings.json? This is mine:

{
    "editor.tabSize": 4,
    "terminal.integrated.commandsToSkipShell": [
      "language-julia.interrupt"
    ],
    "terminal.integrated.persistentSessionScrollback": 0,
    "terminal.integrated.scrollback": 2000,
    "editor.unicodeHighlight.ambiguousCharacters": false,
    "redhat.telemetry.enabled": true,
    "julia.additionalArgs": [
      "--warn-overwrite=yes",
    ],
    "julia.enableTelemetry": true,
    "julia.enableCrashReporter": true,
    "julia.NumThreads": 8,
    "julia.useRevise": false,
    "julia.executablePath": "/home/nsajko/tmp/jl/jl/julia-1.11.1/bin/julia",
    "julia.symbolCacheDownload": true,
    "workbench.colorTheme": "Solarized Light",
    "window.titleBarStyle": "custom",
    "window.customTitleBarVisibility": "windowed",
}

This is my json settings file. It looks like I have Revise enabled by default, but I’ve just tried disabling and reenabling it, and it didn’t change my benchmark results or the general feel of typing in the REPL.

{
    "terminal.integrated.commandsToSkipShell": [
        "language-julia.interrupt",
        "matlab.interrupt"
    ],
    "julia.NumThreads": "auto",
    "workbench.editorAssociations": {
        "*.ipynb": "jupyter.notebook.ipynb",
        "*.rda": "default"
    },
    "python.condaPath": "C:\\Users\\johnb\\miniconda3\\_conda.exe",
    "julia.enableTelemetry": false,
    "julia.symbolCacheDownload": true,
    "julia.trace.server": "messages",
    "julia.additionalArgs": ["--track-allocation=all"
    
    ],
    "notebook.lineNumbers": "on",
    "[python]": {
        "editor.formatOnType": true
    },
    "julia.enableCrashReporter": false,
    "git.autofetch": true,
    "notebook.output.wordWrap": true,
    "python.defaultInterpreterPath": "",
    "terminal.integrated.defaultProfile.windows": "Command Prompt",
    "arduino.useArduinoCli": true,
    "C_Cpp.default.compilerPath": "C:\\msys64\\ucrt64\\bin\\gcc.exe",
    "cmake.buildTask": true,
    "cmake.cmakePath": "C:\\Program Files\\CMake\\bin\\cmake.exe",
    "cmake.generator": "Ninja",
    "cmake.pinnedCommands": [
        "workbench.action.tasks.configureTaskRunner",
        "workbench.action.tasks.runTask"
    ],
    "terminal.integrated.suggest.enabled": true,
    "julia.cellDelimiters": [
        
        "^##(?!#)",
        "^#(\\s?)%%",
        "^#-"
    ]
}

Perhaps this one?

I strongly suspect this line:

According to the Julia documentation this causes Julia to measure allocation for each line of executed code.