Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 465610

Summary: [tern] Provide progress when activating Tern content assist and improve worker load time
Product: [ECD] Orion Reporter: Michael Rennie <Michael_Rennie>
Component: JS ToolsAssignee: Michael Rennie <Michael_Rennie>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P1 CC: emoffatt, libingw, Silenio_Quarti
Version: 8.0   
Target Milestone: 9.0   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Work in progress
none
potential fix for worker loading none

Description Michael Rennie CLA 2015-04-27 11:33:29 EDT
It would be nice to know that the content assist system is doing something vs. being broken. Even with the fix from bug 464828, I see a delay sometimes in my target site while the worker is either loading / starting or crunching away on data.

Might be as simple as providing a callback for onProgress in the deferred.
Comment 1 Curtis Windatt CLA 2015-06-16 17:44:47 EDT
Created attachment 254485 [details]
Work in progress

Work in progress, displays a message while the promise is being resolved.  Problem is that it seems the promise never completes, need further debugging.  Also sets an error message when no proposals are returned (same look and feel as when no find results are found in editor).
Comment 3 Michael Rennie CLA 2015-06-17 15:00:36 EDT
Bumping the severity on this one, as something fishy is happening with worker communication.

Steps:
1. open a js and immediately hit Ctrl+space
2. nothing happens (we now see progress, but it never resolves
3. have a breakpoint in ternWorkerCore#onmessage and repeat steps - notice the worker is not even getting the message asking for proposals.

It seems that the request (postMessage) for proposals is not even making it to the worker / tern server, so we get a huge lag until you mash on Ctrl+space again. If, however, you wait a few seconds after the file opens and then hit Ctrl+space, assist is instantaneous.
Comment 4 Michael Rennie CLA 2015-06-17 15:22:33 EDT
(In reply to Michael Rennie from comment #3)

> It seems that the request (postMessage) for proposals is not even making it
> to the worker / tern server, so we get a huge lag until you mash on
> Ctrl+space again. If, however, you wait a few seconds after the file opens
> and then hit Ctrl+space, assist is instantaneous.

Took some tracings of the messages when the page first loads (without doing anything after load), and got:

javascriptPlugin.js:120 start_server postmessage sent
javascriptPlugin.js:142 js plugin main got: "server_ready"
javascriptPlugin.js:219 js plugin prefs got: "server_ready"
ternAssist.js:367 tern assist got: "server_ready"
javascriptPlugin.js:142 js plugin main got: "installed_plugins"
javascriptPlugin.js:219 js plugin prefs got: "installed_plugins"
ternAssist.js:367 tern assist got: "installed_plugins"

Reloading the page and immediately hitting Ctrl+space yields:

javascriptPlugin.js:120 start_server postmessage sent
javascriptPlugin.js:142 js plugin main got: "server_ready"
javascriptPlugin.js:219 js plugin prefs got: "server_ready"
ternAssist.js:367 tern assist got: "server_ready"
javascriptPlugin.js:200 js plugin envs got: "server_ready"
javascriptPlugin.js:142 js plugin main got: "installed_plugins"
javascriptPlugin.js:219 js plugin prefs got: "installed_plugins"
ternAssist.js:367 tern assist got: "installed_plugins"
javascriptPlugin.js:200 js plugin envs got: "installed_plugins"

So as we can see the assist request is not done at all (there is tracing in ternAssist to log 'assist post message sent'). Investigating.
Comment 5 Michael Rennie CLA 2015-06-17 19:36:12 EDT
Created attachment 254524 [details]
potential fix for worker loading

Here is a patch that:
1. cuts down the worker loading time
2. ensures the progress completes (and dismisses)
3. allows content assist to be presented in the 1-3 second range in the 'first operation" scenario.

As it turns out, the problem could be that requirejs is causing the delay, more details about it can be found:

https://groups.google.com/forum/#!topic/requirejs/rHUlpdaSAXU
https://github.com/jrburke/requirejs/issues/1220
https://groups.google.com/forum/#!topic/requirejs/YYu7DerPNOA

where the underlying problem is that each dependency that the worker loads using requirejs results in a separate importScripts call - which all happen serially, and as one of the comments in a link above points out can actually be much slower in a worker than in a 'normal' page.
Comment 6 Silenio Quarti CLA 2015-06-18 10:49:12 EDT
+1 for 9.0


(In reply to Michael Rennie from comment #5)
 
> where the underlying problem is that each dependency that the worker loads
> using requirejs results in a separate importScripts call - which all happen
> serially, and as one of the comments in a link above points out can actually
> be much slower in a worker than in a 'normal' page.

This is a problem at dev time since we load many separate js files, but it should not be an issue in the built code.
Comment 7 Michael Rennie CLA 2015-06-18 11:06:07 EDT
Fixed in:

http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=cf2cc4d0e87a072497dfc2bae8b22fb52ae3a889

I opened bug 470500 to investigate speeding up loading (mentioned in comment #5)