Vscode: Syntax coloring is slow

Created on 26 Feb 2018  路  10Comments  路  Source: microsoft/vscode

Issue Type

Bug

Description

Syntax coloring is slow and I can see white text for a while. How come in Sublime Text I don't? Otherwise I like VSCode more.

VS Code Info

VS Code version: Code 1.20.1 (f88bbf9137d24d36d968ea6b2911786bfe103002, 2018-02-13T15:23:28.607Z)
OS version: Darwin x64 17.4.0


System Info

|Item|Value|
|---|---|
|CPUs|Intel(R) Core(TM) i7-4558U CPU @ 2.80GHz (4 x 2800)|
|Load (avg)|2, 2, 2|
|Memory (System)|16.00GB (1.10GB free)|
|Process Argv|/Applications/Visual Studio Code.app/Contents/MacOS/Electron -psn_0_127007|
|Screen Reader|no|
|VM|0%|

Extensions (2)

Extension|Author (truncated)|Version
---|---|---
indent4to2|Com|0.1.2
vscode-eslint|dba|1.4.6


Reproduces only with extensions

*out-of-scope tokenization under-discussion

Most helpful comment

This is still not fixed. Try a 60k LOC C++ file. It takes 10 seconds to color it. Pathetic.

All 10 comments

To confirm, this reproduces only when extensions are enabled? If so, this is likely caused by an extension. How large/what type of file does this happen for?

Extensions don't seem to affect. It happens even to a small file but the delay is less than one second and that's only a minor nuisance. But with longer code file with 1000 lines the delay can be more than one second. JS or JSX seem to be slower than CSS. Anyway, this is weird because I have quite powerful machine and this is not even a heavy computational operation.

I can repro easily. Open "tsc.js" from TypeScript node module (npm install typescript, "tsc.js" is located in "node_modules/typescript/lib"), then use "Ctrl+End" to jump the end. You'll see the code is not syntax highlighted. Wait about 1 minute, then the highlight shows up.

Our current tokenization engine goes from the top to the bottom and this engine with a rich grammar (TypeScript) can be slow.

@rebornix Can we do anything about this on the TypeScript grammar side of things?

@mjbvz right now the problem with our grammars is we only know the time is spent in Regex searching but we don't know which part

  • Are the grammar regexes too flat, which make the regex matching fail too late?
  • Are the grammar stacks too deep, which uses a bunch of time push/pop in the stack?
  • Is there any hot path in typescript grammar matching? If there is one, can we increase the priority of that path a bit to reduce stacks?

Maybe we can try to add some tracing into vscode-textmate and find something interesting.

This issue is being closed to keep the number of issues in our inbox on a manageable level, we are closing issues that are not going to be addressed in the foreseeable future: We look at the number of votes the issue has received and the number of duplicate issues filed. If you disagree and feel that this issue is crucial: We are happy to listen and to reconsider.

If you wonder what we are up to, please see our roadmap and issue reporting guidelines.

Thanks for your understanding and happy coding!

This is still not fixed. Try a 60k LOC C++ file. It takes 10 seconds to color it. Pathetic.

For C++, could the line be colored gray if the line starts with // before the advanced syntax coloring system kicks in? When commenting in and out single lines is mainly when I notice the delay.

For anyone arriving, this is a dupe of https://github.com/microsoft/vscode/issues/64681

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chrisdias picture chrisdias  路  3Comments

trstringer picture trstringer  路  3Comments

DovydasNavickas picture DovydasNavickas  路  3Comments

lukehoban picture lukehoban  路  3Comments

trstringer picture trstringer  路  3Comments