Bug 480771 - References->Project is very slow (around 30-50 seconds)
Summary: References->Project is very slow (around 30-50 seconds)
Status: RESOLVED FIXED
Alias: None
Product: Orion (Archived)
Classification: ECD
Component: JS Tools (show other bugs)
Version: 10.0   Edit
Hardware: All All
: P1 normal (vote)
Target Milestone: 11.0   Edit
Assignee: Michael Rennie CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2015-10-27 09:11 EDT by Steve Northover CLA
Modified: 2015-11-16 11:36 EST (History)
2 users (show)

See Also:


Attachments
workaround (3.68 KB, patch)
2015-11-05 13:00 EST, Silenio Quarti CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Steve Northover CLA 2015-10-27 09:11:38 EDT
1) IMPORTANT: Reload the page first!
2) load minesweeper-require
3) open board.js
4) click on isSwept()
5) Tools->References->Project
6) BUG: It takes around 5 minutes for the references window to open

I can make this happen every time on my machine.  The project is very small so I don't know why it takes so long.
Comment 1 Steve Northover CLA 2015-10-27 09:12:47 EDT
I am using Chrome.
Comment 2 Michael Rennie CLA 2015-10-27 15:55:15 EDT
on orion.eclipse.org, I have never seen slowness like you mentioned. But on beta3 in a target site I can easily reproduce a significant slow-down (not 5 minutes but 30-40 seconds).

Its weird, the search finishes pretty fast and the first few refs are successfully passed through Tern, and then it seems to hang for a while while waiting for a read. I haven't figured out why yet.
Comment 3 Steve Northover CLA 2015-10-27 16:01:21 EDT
It sounds as if we are seeing the same thing.  I see it in other browsers too (IE).  The "5 minute" thing might be a stretch but it is long enough that I go to another window and do something else (because I know it will eventually come back).

Repeatable case:  We should be able to debug this.
Comment 4 Michael Rennie CLA 2015-10-28 14:25:48 EDT
(In reply to Steve Northover from comment #3)
> It sounds as if we are seeing the same thing.  I see it in other browsers
> too (IE).  The "5 minute" thing might be a stretch but it is long enough
> that I go to another window and do something else (because I know it will
> eventually come back).
> 
> Repeatable case:  We should be able to debug this.

Debugging through this and I found that there is a xhr request being sent out during the refs call that results in a 405 exception being logged. At that point the operation seems to hang until you click in the editor?? Up until the point of the exception, the global search runs fine as does the Tern worker.
Comment 5 Silenio Quarti CLA 2015-11-05 13:00:57 EST
Created attachment 257761 [details]
workaround

This patch probably does not belong in this bug. Only attaching it here because it works around the problem.

The search client already loaded the contents of which file in the search result so that it could calculate the start,end offsets of the matches.

This patch uses that contents to feed tern instead of loading it again. Which should be a performance improvement too.

Mike, does it make sense to send contents in the checkRef request?
Comment 6 Michael Rennie CLA 2015-11-05 14:51:58 EST
(In reply to Silenio Quarti from comment #5)
> Created attachment 257761 [details]
> workaround
> 
> This patch probably does not belong in this bug. Only attaching it here
> because it works around the problem.
> 
> The search client already loaded the contents of which file in the search
> result so that it could calculate the start,end offsets of the matches.
> 
> This patch uses that contents to feed tern instead of loading it again.
> Which should be a performance improvement too.
> 
> Mike, does it make sense to send contents in the checkRef request?

We could definitely send the contents over the wire (we do it for some other of the requests already to avoid calling back to the file client). The only downside is that this could cause mutli-parsing of the same file - if you send the contents along with the request, Tern assumes you want the text updated, which will cause the text to be re-parsed / re-inferred / etc.

The fix I am working on for bug 474420 should avoid this problem though.
Comment 7 Silenio Quarti CLA 2015-11-06 10:00:28 EST
> We could definitely send the contents over the wire (we do it for some other
> of the requests already to avoid calling back to the file client). The only
> downside is that this could cause mutli-parsing of the same file - if you
> send the contents along with the request, Tern assumes you want the text
> updated, which will cause the text to be re-parsed / re-inferred / etc.

Doesn't the check in line#38 of refs.js prevent the file from being re-parsed?
Comment 8 Michael Rennie CLA 2015-11-13 13:30:39 EST
I pushed an update that ensures Tern knows the query type *must* have a file. With this fix the code for 'afterLoad' etc is no longer even called.

http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=8937c2a90a5069842b055f7c82244f61770c83bb
Comment 9 Steve Northover CLA 2015-11-13 13:33:49 EST
Do we think the problem is fixed?
Comment 10 Silenio Quarti CLA 2015-11-13 16:21:00 EST
I have tried the cases that consistently failed for me and I am no longer able to reproduce them.
Comment 11 Michael Rennie CLA 2015-11-13 16:34:20 EST
(In reply to Silenio Quarti from comment #10)
> I have tried the cases that consistently failed for me and I am no longer
> able to reproduce them.

I would still like to send the text with the request (if would save a call to the file client), but the delays + hanging + etc are fixed.
Comment 12 Michael Rennie CLA 2015-11-13 16:35:47 EST
*** Bug 481959 has been marked as a duplicate of this bug. ***
Comment 13 Michael Rennie CLA 2015-11-13 17:54:00 EST
(In reply to Michael Rennie from comment #11)
> (In reply to Silenio Quarti from comment #10)
> > I have tried the cases that consistently failed for me and I am no longer
> > able to reproduce them.
> 
> I would still like to send the text with the request (if would save a call
> to the file client), but the delays + hanging + etc are fixed.

Cleaned up the code a bit and added support to send the file contents with the request:

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

I'll leave this open until we all have a chance to test.
Comment 14 Michael Rennie CLA 2015-11-13 18:35:10 EST
(In reply to Michael Rennie from comment #13)

> I'll leave this open until we all have a chance to test.

I found an odd case. Using the steps from bug 481959 on beta3:

1. refresh page
2. invoke Refs > Project
3. let it finish and immediately invoke it again -> hangs

there is something going on while resolving the dependencies, the second time you invoke it, Tern thinks it still has 12 outstanding look-ups, but everything was already fetched (there are 45 deps from mocha in this example)
Comment 15 Steve Northover CLA 2015-11-16 09:28:34 EST
The original problem is fixed for me.  Did you want to close this bug and open another one with the steps that make the problem keep happening?
Comment 16 Michael Rennie CLA 2015-11-16 11:36:19 EST
(In reply to Steve Northover from comment #15)
> The original problem is fixed for me.  Did you want to close this bug and
> open another one with the steps that make the problem keep happening?

Reopened bug 481959 to track the new hanging.

Closing fixed.