Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax coloring is slow #44373

Closed
torava opened this issue Feb 26, 2018 · 10 comments
Closed

Syntax coloring is slow #44373

torava opened this issue Feb 26, 2018 · 10 comments
Assignees
Labels
*out-of-scope Posted issue is not in scope of VS Code tokenization Text tokenization under-discussion Issue is under discussion for relevance, priority, approach

Comments

@torava
Copy link

torava commented Feb 26, 2018

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 (f88bbf9, 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
@RMacfarlane
Copy link
Contributor

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?

@torava
Copy link
Author

torava commented Feb 26, 2018

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.

@cnshenj
Copy link

cnshenj commented Mar 29, 2018

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.

@rebornix
Copy link
Member

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

@rebornix rebornix added tokenization Text tokenization under-discussion Issue is under discussion for relevance, priority, approach and removed editor labels Mar 29, 2018
@mjbvz
Copy link
Collaborator

mjbvz commented Apr 27, 2018

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

@rebornix
Copy link
Member

@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.

@mjbvz mjbvz added the *out-of-scope Posted issue is not in scope of VS Code label Sep 10, 2018
@vscodebot
Copy link

vscodebot bot commented Sep 10, 2018

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!

@vscodebot vscodebot bot closed this as completed Sep 10, 2018
@ci70
Copy link

ci70 commented Dec 1, 2018

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

@xyproto
Copy link

xyproto commented Oct 22, 2019

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.

@jasonwilliams
Copy link
Contributor

For anyone arriving, this is a dupe of #64681

@microsoft microsoft locked as resolved and limited conversation to collaborators Jun 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*out-of-scope Posted issue is not in scope of VS Code tokenization Text tokenization under-discussion Issue is under discussion for relevance, priority, approach
Projects
None yet
Development

No branches or pull requests

8 participants