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

Typing hangs when code completion takes a while #163

Open
r4nt opened this issue Mar 18, 2015 · 3 comments
Open

Typing hangs when code completion takes a while #163

r4nt opened this issue Mar 18, 2015 · 3 comments

Comments

@r4nt
Copy link

r4nt commented Mar 18, 2015

I work in Clang, which has really large translation units. Apparently code completion takes a while there, and while that is on, I cannot type any more (I use instant completion). Is that a problem in company-mode or emacs-ycmd?

@r4nt
Copy link
Author

r4nt commented Mar 18, 2015

Repro:
$ for i in $(seq 20000) ; do echo "int f$i() {}"; done > t.cc
$ emacs -nw t.cc
Go anywhere and start typing
a (takes a while before "a" shows up)
b (takes a while before "b" shows up)
...

I also discussed this with company-mode:
company-mode/company-mode#325

@r4nt
Copy link
Author

r4nt commented Mar 19, 2015

Some data from @dgutov

Well, at least for this example I get this ELP output:
json-encode 49 40.373922852 0.8239576092
json-encode-list 12 30.454752527 2.5378960439
json-encode-alist 9 30.45463016 3.3838477955
ycmd-get-completions 3 10.515761361 3.5052537869
ycmd--request 5 10.504717434 2.1009434868
json-encode-string 30 9.9188939140 0.3306297971
js on-encode-char 927259 6.9621825919 7.508...e-06
json-encode-char0 927259 1.1932534209 1.286...e-06
ycmd-request-deferred 5 0.263508196 0.0527016392
ycmd-request 5 0.263467947 0.0526935894
ycmd-request--curl 5 0.263334671 0.0526669342
json-join 9 0.1421685389 0.0157965043
ycmd--standard-content-with-extras 3 0.0126280259 0.004209342
ycmd--standard-content 3 0.0126114730 0.0042038243
json-read 90 0.0070623759 7.847...e-05
...
That's 0.8sec, on average, spent in json-encode. Try evaluating (length (json-encode (ycmd--standard-> content))) in this buffer and see how long it takes (~3 seconds 0.5 sec for me). This is the data that has > to be generated before making the request.

So, the big file size is definitely a factor here. Do you have an example where the current file isn't
huge? I guess it's allowed to include a huge header, but then ycmd needs some file with project options
I'm not familiar with.

@dgutov
Copy link

dgutov commented Apr 9, 2015

So, this should be much improved in the current Emacs master.

If having the same in older Emacs versions, you could version-conditionally advise json-encode-string to use the new implementation, which you'd need to copy.

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

2 participants