davazp/graphql-mode

Performance issues with graphql-mode and Emacs-26.1

yorodm opened this issue ยท 5 comments

I'm having a noticeable lag running any editing command while using graphql-mode. I'm using version 20180303.2358 installed from melpa and Emacs 26.1. My schema file has around 300 lines

I can't reproduce this issue. Could you try provide an example schema that I can check?

@davazp I have the same problem. I use 20190320.757 and emacs 26.1.
You can test it on https://developer.github.com/v4/public_schema/schema.public.graphql,
which has 23234 lines, 49038 words, 435265 chars

I see these errors in (view-echo-area-messages):

Error during redisplay: (jit-lock-function 210790) signaled (scan-error "Unbalanced parentheses" 214811 435266)
Error during redisplay: (jit-lock-function 211290) signaled (scan-error "Unbalanced parentheses" 214811 435266)
Error during redisplay: (jit-lock-function 211790) signaled (scan-error "Unbalanced parentheses" 214811 435266)
Error during redisplay: (jit-lock-function 212290) signaled (scan-error "Unbalanced parentheses" 214811 435266)

fwiw, C-u 214811 right goes right after the opening bracket of this directive:

type OrganizationTeamsHovercardContext implements HovercardContext @preview(
  toggledBy: "hagar-preview") {

If I move around, I see more similar errors

Error during redisplay: (jit-lock-function 214812) signaled (scan-error "Unbalanced parentheses" 215868 435266)
Error during redisplay: (jit-lock-function 214344) signaled (scan-error "Unbalanced parentheses" 215868 435266)
Error during redisplay: (jit-lock-function 214338) signaled (scan-error "Unbalanced parentheses" 214811 435266)
Error during redisplay: (jit-lock-function 214303) signaled (scan-error "Unbalanced parentheses" 214811 435266)
Error during redisplay: (jit-lock-function 215312) signaled (scan-error "Unbalanced parentheses" 215310 435266)
Error during redisplay: (jit-lock-function 215868) signaled (scan-error "Unbalanced parentheses" 219367 435266)
Error during redisplay: (jit-lock-function 215812) signaled (scan-error "Unbalanced parentheses" 219367 435266)
Error during redisplay: (jit-lock-function 216368) signaled (scan-error "Unbalanced parentheses" 216363 435266)

Location 215868 goes after another similar directive:

type OrganizationsHovercardContext implements HovercardContext @preview(
  toggledBy: "hagar-preview") {

So I would suspect this line.

    ;; Directives
    ("@\\_<.+?\\_>" . font-lock-keyword-face)

I thought I know regexps but for the life of me I can't grok what's \_<...\_>

(later) Ahaa, found it

โ€˜\_<โ€™
     matches the empty string, but only at the beginning of a symbol.  A
     symbol is a sequence of one or more word or symbol constituent
     characters.  โ€˜\_<โ€™ matches at the beginning of the buffer (or
     string) only if a symbol-constituent character follows.

So the regexp sounds legit... The next suspect is (defun graphql--field-parameter-matcher

I also think it is graphql--field-parameter-matcher. It is using some movements commands to decide how to highlight commands. But of course, that assumes the syntax is right.

We could need to do some error handling, so it just doesn't highlight things that are not well formatted.

I will try to find some time, let me know about your findings if you look more into it! ๐Ÿ‘

I use graphql-mode in mmm-mode together with rjsx-mode. I have schema file with only 165 lines, but it lags badly on every cursor movement or mouse scroll, while in gql string literal block. Profiler shows that 71% of CPU is taken by graphql--field-parameter-matcher. I use it only for syntax highlighting. Is there a way to solve it?