Skip to content

Semantic tokens: Tokenization appears to be really slow #86165

Closed

Description

@Tyriar

Testing #85976

It appears colors are not updated until typing has stopped for around 500ms, being this slow seems like a problem?

Kapture 2019-12-03 at 12 32 01

I'm not typing particularly fast in the above gif, compare this to today with tm grammars where the colorization is instant.

Activity

  1. changed the title [-]Tokenization appears to be really slow using semantic coloring[/-] [+]Semantic tokens: Tokenization appears to be really slow[/+] on Dec 3, 2019
  2. alexdima commented on Dec 4, 2019

    @alexdima
    Member

    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:

    1. reduce the delay.
    2. 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.
  3. octref commented on Dec 4, 2019

    @octref
    Contributor

    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.

  4. alexdima commented on Dec 5, 2019

    @alexdima
    Member

    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.

  5. added
    bug
    on Dec 5, 2019
  6. locked and limited conversation to collaborators on Jan 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugsemantic-tokensverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions