leodevbro / vscode-blockman

VSCode extension to highlight nested code blocks
https://github.com/leodevbro/vscode-blockman
MIT License
345 stars 16 forks source link

Makes typescript super slow #124

Open leonard-henriquez opened 9 months ago

leonard-henriquez commented 9 months ago

Type: Bug

When I activate Blockman on a large Typescript codebase, my VS Code which is usually super snappy becomes really really slow (10+ seconds when I try to access to type definitions)

Extension version: 1.7.5 VS Code version: Code 1.82.2 (Universal) (abd2f3db4bdb28f9e95536dfa84d8479f1eb312d, 2023-09-14T05:59:47.790Z) OS version: Darwin arm64 22.2.0 Modes:

System Info |Item|Value| |---|---| |CPUs|Apple M1 Pro (10 x 24)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
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)|8, 8, 7| |Memory (System)|32.00GB (2.30GB free)| |Process Argv|.| |Screen Reader|yes| |VM|0%|
leodevbro commented 9 months ago

Hello, please tell me the size of the specific file on which Blockman needs many seconds to render blocks.

I have tested Blockman on 5000 line TypeScript file and it needs no more than 1-2 seconds to render blocks. Often less than 1 second.

If your file has more than 5000 or more than 10000 lines, then I guess we cannot do much about it, because VS Code does not give extensions access to the natively optimized parsed tokens, so extensions have to parse/tokenize themselves and it is not optimized, because we, extension developers, don't always have the super knowledge and experience of writing optimized tokenization algorithms for so many languages.

So, after analyzing file, rendering blocks is always fast. The analyzation process is slow because of the VS Code limitation I mentioned above. I hope VS Code will soon give extensions access to the native tokens.

Also, one noteworthy thing is that Blockman uses 1.2 seconds (you can change this number) debouncing for every render and for every text change event to rerender blocks. You can change it to maybe 0.2 seconds, but probably it will be too much load on the CPU.

https://github.com/microsoft/vscode/issues/177452

BacemJ commented 8 months ago

I encountered the same issue not in first load but when scrolling up and down in the file it stuck to render the file has 158 lines only but it stuck. I loved the extension but it stuck in the rendering I use vs code in Windows 10

leodevbro commented 8 months ago

file has 158 lines only but it stuck

@BacemJ, this is very strange. 158 lines is very little code, I have never seen Blockman stuck on 100-200 lines file. Could you please provide the exact file text? So I will be able to test it on my environment, maybe the file has some kind of "edge case" code in it? I don't know.

leonard-henriquez commented 8 months ago

If your file has more than 5000 or more than 10000 lines, then I guess we cannot do much about it, because VS Code does not give extensions access to the natively optimized parsed tokens, so extensions have to parse/tokenize themselves and it is not optimized, because we, extension developers, don't always have the super knowledge and experience of writing optimized tokenization algorithms for so many languages.

Unfortunately that's the case because I have a few generated files (like the Prisma Client) that are a few thousands lines long. So I had to disable the Blockman extension :'(

leodevbro commented 8 months ago

@leonard-henriquez, maybe you don't need to completely disable or uninstall it. Blockman has customizable black list of file formats to ignore files with specific formats, for example: prisma, plaintext, markdown, css, less, scss, html, json, jsonc, typescriptreact, typescript, javascriptreact, javascript, python, go, dart, php, c, csharp, cpp, java.

Also Blockman has quick toggle (disable/enable) command to disable when it is not convenient to use it and reenable it quickly. Just press F1 and type blockman toggle and you will find two kinds of enable/disable toggle commands.

1] simple enable/disable 2] enable/disable with forced show/hide indent guides of VS Code.

barisx commented 7 months ago

it is super slow also on my mac. but i can't say cause of typescript. as far as i saw it has trying optimization. it renders only when i change new code sections.