You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Semantic tokens: Tokenization appears to be really slow #86165
changed the title [-]Tokenization appears to be really slow using semantic coloring[/-][+]Semantic tokens: Tokenization appears to be really slow[/+]on Dec 3, 2019
TM grammars are interpreted synchronously in the renderer process, and in most typing situations, while actually typing. (the exception would be when opening a very large file and typing at the bottom of it before tokenization has reached the bottom). So, in most cases, the TM grammar is running synchronously on typing...
Today, the request is made 500ms after the last typing stops. Since we never actually cancel the request (to simplify a server implementation which now only needs to remember the last result), I think we could change this in two directions:
reduce the delay.
do not always postpone the request on typing, i.e. make the request at X ms after the first typing, not after the last typing.
Today, the request is made 500ms after the last typing stops. Since we never actually cancel the request (to simplify a server implementation which now only needs to remember the last result)
But even if you do 2, server can still be simple and only remember last (latest) result, can't it?
Naive server always parse all and return all tokens so this is not a concern.
An incremental server could:
Put content change events and semantic token requests in a queue
When popping a content change, apply it to AST
When popping a semantic token request, answer it by computing answer from AST
Drop the semantic token request if cancelled
Currently the typing experience in TS is ok since it still has TM grammar. For languages that's completely using semantic highlighting, I imagine it would be annoying if when I go from func() to func(a: b, c: d, e: f) I see a: b, c: d, e: f all in white until the very end.
For languages that's completely using semantic highlighting
IMHO I would not want that we ship languages only with semantic highlighting because that means color/style flashing all the time while typing. I think there is a fine balance between what one puts in the TM grammar and between what one puts in the semantic tokens, but IMHO they are two stories that work together and not exclusive.
Activity
[-]Tokenization appears to be really slow using semantic coloring[/-][+]Semantic tokens: Tokenization appears to be really slow[/+]alexdima commentedon Dec 4, 2019
TM grammars are interpreted synchronously in the renderer process, and in most typing situations, while actually typing. (the exception would be when opening a very large file and typing at the bottom of it before tokenization has reached the bottom). So, in most cases, the TM grammar is running synchronously on typing...
Today, the request is made 500ms after the last typing stops. Since we never actually cancel the request (to simplify a server implementation which now only needs to remember the last result), I think we could change this in two directions:
octref commentedon Dec 4, 2019
But even if you do 2, server can still be simple and only remember last (latest) result, can't it?
Naive server always parse all and return all tokens so this is not a concern.
An incremental server could:
Currently the typing experience in TS is ok since it still has TM grammar. For languages that's completely using semantic highlighting, I imagine it would be annoying if when I go from
func()tofunc(a: b, c: d, e: f)I seea: b, c: d, e: fall in white until the very end.alexdima commentedon Dec 5, 2019
IMHO I would not want that we ship languages only with semantic highlighting because that means color/style flashing all the time while typing. I think there is a fine balance between what one puts in the TM grammar and between what one puts in the semantic tokens, but IMHO they are two stories that work together and not exclusive.