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

Performance issues with graphql-mode and Emacs-26.1 #18

Open
yorodm opened this issue Sep 13, 2018 · 5 comments
Open

Performance issues with graphql-mode and Emacs-26.1 #18

yorodm opened this issue Sep 13, 2018 · 5 comments

Comments

@yorodm
Copy link

yorodm commented Sep 13, 2018

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

@davazp
Copy link
Owner

davazp commented Sep 15, 2018

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

@VladimirAlexiev
Copy link

VladimirAlexiev commented Apr 23, 2019

@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") {

@VladimirAlexiev
Copy link

VladimirAlexiev commented Apr 23, 2019

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

@davazp
Copy link
Owner

davazp commented Apr 24, 2019

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! 👍

@farynaio
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants