ternjs / tern_for_sublime

Sublime Text package adding Tern support
MIT License
801 stars 52 forks source link

Completion performance #57

Closed silverwind closed 9 years ago

silverwind commented 9 years ago

I'm using tern and this plugin on Windows, and I noticed a considerable lag after entering two characters (before completion comes up).

When you start typing a sequence of charactes, the first one appears instantly, but on the second character, the editor freezes momentarily and it takes around 1-2 seconds for the other typed characters and the completion to appear. Re-typing these same two characters again works instantly, probably because of some caching mechanism.

I realize this may be caused by other plugins installed, here's the relevant ones that run alongside tern:

silverwind commented 9 years ago

A quick test with TernJS shows that it isn't affected by this lag, so I'll be using that in the meantime. Let me know if you need any more info!

marijnh commented 9 years ago

Is this project specific (does it happen when you just open a tiny file with no dependencies)?

silverwind commented 9 years ago

Yeah, It happens on a 30-line file with no deps too. I just wiped my whole "Packages" and "Installed Packages" to return to a fresh state and then installed just Package Control and tern_for_sublime through git (while previously updating tern), and still had the lag.

marijnh commented 9 years ago

That's bad. Maybe something is going wrong with spawning the server process. If you want to investigate this further, you could start the server manually in a different shell (go to your project dir and start path/to/tern/bin/tern, passing --verbose). Then start ST and try a completion, seeing if it still takes that long, and if it does, looking at the speed at which the console output appears to figure out where the delay happens (before request, during request, after response).

silverwind commented 9 years ago

I'm trying this, but it appears that sublime's plugin_host starts its own tern (and node) process and connects to it, instead of connecting to my tern started in another terminal. Any idea how to force it to use my other tern process?

jaksim commented 9 years ago

The opener.open call in make_request_py3 takes 1 second on my Windows 8.1 machine when localhost gets resolved to ipv6 address instead of ipv4 (I didn't look into what's actually the root cause of this though. Sorry.). Changing localhost to 127.0.0.1 in the plugin code fixes it (so does changing prefix policies in Windows to prefer ipv4 over ipv6, but that doesn't seem like an acceptable solution).

marijnh commented 9 years ago

Okay, that's an interesting bug. I guess that 127.0.0.1 being localhost on windows is a pretty safe bet, so attached patch just makes that change.

@silverwind Does this help?

silverwind commented 9 years ago

@marijnh completion performance is instant again, but as I was curious, I checked an earlier revision of this package but couldn't reproduce the lag anymore with it.

There have been a few Sublime Text updates recently, which might also have helped. Thanks!

cron13 commented 7 years ago

this issue actual also for mac os 10.13.1