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

Ternjs Timeout configuration #1881

Closed
DonnieWest opened this issue Jan 6, 2016 · 15 comments · Fixed by #2657
Closed

Ternjs Timeout configuration #1881

DonnieWest opened this issue Jan 6, 2016 · 15 comments · Fixed by #2657

Comments

@DonnieWest
Copy link

In ternjs I can set the request timeout for the server like this:

let g:tern_request_timeout = 6000

Is there a way to configure ternjs like this in YouCompleteMe?

Edit: No there isn't. The reason this parameter exists in Tern is because of ternjs' relative slowness in parsing larger projects. With YouCompleteMe I'm now getting "Read timeout" errors that I didn't get with tern_for_vim.

Is there some other workaround or can we implement #742? Changing the timeout manually in the project seems to make this issue go away and give me proper completions

@micbou
Copy link
Collaborator

micbou commented Jan 6, 2016

A workaround is to change the value of TIMEOUT_SECONDS in python/ycm/client/completion_request.py.
We are not currently providing an option to change this value because 0.5 second is already a long time. Maybe we should reconsider this with the new Javascript completer.

@puremourning
Copy link
Member

Why do you feel you need to change the timeout? Are you hitting a problem of some sort? Would be keen to understand the problem.

On 6 Jan 2016, at 10:15, micbou notifications@github.com wrote:

A workaround is to change the value of TIMEOUT_SECONDS in python/ycm/client/completion_request.py.
We are not currently providing an option to change this value because 0.5 second is already a long time. Maybe we should reconsider this with the new Javascript completer.


Reply to this email directly or view it on GitHub.

@DonnieWest
Copy link
Author

So, I'm going through an Ember book that has it's project source code here:

https://github.com/abuiles/borrowers

When I get home I'll edit this with the .tern-project that I'm using, but, completions take significantly longer than 0.5 seconds on any given file.

@puremourning
Copy link
Member

Interesting, thanks. I'll take a look at it, as it will be a useful "large" javascript project to test with.

TBH I don't think that a timeout of anything more that 0.5s is really a solution, in the sense that if you're not getting completions "instantly" then either ycmd or Tern are not really doing their job properly. Waiting for even 1/2 a second is a poor user experience.

FWIW, the tern completer was using Tern's timeout option, but this was causing crashes in Tern. The crash fixed, but we haven't re-enabled the timeout yet, as ycmd has its own timeout mechanism. Using this large project as an example will help us determine what level of timeout, optimisation, etc. is required.

In the meantime, if you're comfortable hacking ycmd, you can checkout tern master in third_party/ycmd/third_party/tern submodule re-add the timeout code to ycmd's tern completer in third_party/ycmd/ycmd/completers/javascript/tern_completer.py

@puremourning
Copy link
Member

@DonnieWest did you get round to digging out your .tern-project ? I'm keen to test YCM + tern on a large javascript project.

@DonnieWest
Copy link
Author

Sorry! Here you go. A good portion of what you see here isn't necessary but is some of the hacking I've done to get tern.js to give halfway decent completions.

Condensing ember.js also seems to work better in general, but still gives issues here

{
  "libs": [
    "browser"
  ],
  "loadEagerly": [
    "bower_components/ember/ember.js"
  ],
  "dontLoad":[
    "node_modules",
    "dist",
    "tmp",
    "vendor"
  ],
  "exclude": [
    "node_modules/**",
    ".git/**",
    "*.min.js",
    "*.prod.js",
    "*.debug.js",
    "tmp",
    "vendor"
  ],
  "plugins": {
    "node": {},
    "complete_strings": {},
    "es_modules": {}
  }
}

@sbuljac
Copy link

sbuljac commented Jan 12, 2016

I am also keep getting timeout errors. After first error everything starts to lag and ycm is useless. Everything work fine before tern integration (with tern plugin).
btw. I am using Neovim.

@vheon
Copy link
Contributor

vheon commented Jan 12, 2016

After first error everything starts to lag and ycm is useless

@sbuljac What do you mean "useless".

I am using Neovim.

I don't think that this is the problem but could you try with regular vim?

@puremourning
Copy link
Member

I think we need to update tern and add the tern timeout. I think tern server is spending too much time doing requests. See my post above for a workaround.

On 12 Jan 2016, at 21:21, Andrea Cedraro notifications@github.com wrote:

After first error everything starts to lag and ycm is useless

@sbuljac What do you mean "useless".

I am using Neovim.

I don't think that this is the problem but could you try with regular vim?


Reply to this email directly or view it on GitHub.

@vheon
Copy link
Contributor

vheon commented Jan 12, 2016

@puremourning even if we add Tern.js timeout how would it be useful when YCM still has a timeout of 0.5s? Is it for the cache?

@sbuljac
Copy link

sbuljac commented Jan 12, 2016

Please ignore my previous comment. It was Tern fault on the end, I made some config changes at the same time I recompiled Ycm, after timout message Ycm need a lot time to complete if at all...
btw.
I don't think tern is slow, I used it with ycm and tern_for_vim for quite some time and everything worked

@puremourning
Copy link
Member

I mean it will limit cpu usage of tern server for a given request rather than unlimited. That leads to general better UX I believe.

On 12 Jan 2016, at 22:03, Andrea Cedraro notifications@github.com wrote:

@puremourning even if we add Tern.js timeout how would it be useful when YCM still has a timeout of 0.5s? Is it for the cache?


Reply to this email directly or view it on GitHub.

@puremourning
Copy link
Member

FYI - i have tried the tern update to fixes crashes on timeouts, but it isn't working, so we're stuck with what we have for now. ternjs/tern#702 (comment)

@DonnieWest
Copy link
Author

Well, definitely thanks for checking this out and all the effort you've put into it 👍

@mwcz
Copy link

mwcz commented Jul 19, 2016

Is the recommended workaround still to edit python/ycm/client/completion_request.py? Thanks!

zzbot added a commit that referenced this issue Jun 25, 2017
[READY] Rewrite completion system

There is a number of issues with the current completion system:
 - UI is blocked until the completions are returned by the server, the request timed out, or a key is pressed by the user. This leads to a rough experience when completions take too much time: cursor disappearing and timeout errors (see #2192 and #2574). Users even [increase the timeout by manually editing the `completion_request.py` file](https://github.com/Valloric/YouCompleteMe/blob/master/python/ycm/client/completion_request.py#L30) to avoid these errors, which exacerbate the issue and, in some cases, make the plugin unusable (see #2574).
 - no fuzzy matching from omnifunc when forcing semantic completion. See #961;
 - no fuzzy matching when deleting characters. Vim filtering is used instead:

![completion-bug-deleting-characters](https://cloud.githubusercontent.com/assets/10026824/26276156/f298c6de-3d71-11e7-92da-d22186239c27.gif)
Neovim and MacVim are not affected.
 - completion menu disappears after deleting a character and inserting one:

![completion-bug-reinserting-character](https://cloud.githubusercontent.com/assets/10026824/26276192/b3ed0f7a-3d72-11e7-8c64-523a0a59cbdc.gif)
Neovim and MacVim are not affected.
 - ignore the start column returned by the server. See PR #2489.
 - subject to flickers. This one depends a lot on the version of Vim. Completion is almost flicker-free in Neovim and MacVim. Not too bad in console Vim (except in fast terminal like [alacritty](https://github.com/jwilm/alacritty)). Awful in gVim GTK2 (a bit better on GTK3) and gVim on Windows.

This PR is an attempt at fixing all of these issues while reducing flickers as best as possible (due to how completion works in Vim, a flicker-free experience is impossible to achieve). Here's how:
 - poll for completions using a timer and call `completefunc` once the completions are ready. Use the start column returned by the server in `completefunc`;
 - immediately display the last completions on the `TextChangedI` event to prevent the popup menu disappearing while waiting for the completions. This reduces flickering;
 - use the `InsertCharPre` event to close the completion menu just before inserting a character. This way the `TextChangedI` event is triggered when the character is inserted (this event is not fired when the completion menu is visible). This replaces the `refresh` option set to `always` in `completefunc` and the `s:cursor_moved` hack;
 - remap the backspace key to close the completion menu when deleting a character and thus triggering the `TextChangedI` event;
 - send a request with `force_semantic` set to `True` when forcing semantic completion instead of calling the omnifunc. This fixes the issue where there is no fuzzy matching for custom omnifuncs.

Here's a demo where I added a spin animation on the command line while loading the completions to show that it doesn't block the Vim UI:

![async-completion-for-real](https://cloud.githubusercontent.com/assets/10026824/26277295/0f16a718-3d86-11e7-90f3-8a56bbf53f9f.gif)

Fixes #961.
Fixes #1282.
Fixes #1881.
Fixes #2192.
Fixes #2500.
Fixes #2574.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2657)
<!-- Reviewable:end -->
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants