Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 362539 - Investigate performance of putting runtime in one big file
Summary: Investigate performance of putting runtime in one big file
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: EDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P1 major (vote)
Target Milestone: ---   Edit
Assignee: Tony Chen CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-01 01:51 EDT by Tony Chen CLA
Modified: 2017-02-23 14:20 EST (History)
6 users (show)

See Also:


Attachments
combine js runtime (5.52 KB, patch)
2011-11-15 08:08 EST, Tony Chen CLA
lasher: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tony Chen CLA 2011-11-01 01:51:11 EDT

    
Comment 1 Tony Chen CLA 2011-11-01 01:55:32 EDT
EDT JS runtime is downloaded as multiple small js files in sequence. This potentially has a performance problem. Recent performance tests with DojoSample shows that EDT runs a little big slower then RBD. We need a more deep investigation on the two difference approaches (download runtime as one big js, or download as separate small js.).
Comment 2 Tony Chen CLA 2011-11-01 01:57:32 EDT
(In reply to comment #1)
> EDT JS runtime is downloaded as multiple small js files in sequence. This
> potentially has a performance problem. Recent performance tests with DojoSample
> shows that EDT runs a little big slower then RBD. We need a more deep
                               bit 
> investigation on the two difference approaches (download runtime as one big js,
> or download as separate small js.).
Comment 3 Tony Chen CLA 2011-11-15 08:06:14 EST
I did some experiment to combine the runtime into one file. Currently, we have 65 js files for the EGL runtime, after combined, the size is about 700k. I can see VE is visibly faster when using the combined runtime. I also believe using a combined runtime will make the VE performance problem described in bug 360348 less likely to happen. 

Brian and I have discussed two solutions to do this. 

Solution A. We have to create a real combined runtime js file, and put it in plugin /org.eclipse.edt.runtime.javascript/runtime. It is very straight forward. We don't have to modify any VE or Deployment code. Just little modification to the generate the HTML so it load the combined runtime instead of 65 separate files. 
However, somebody has to keep the combined file up-to-date whenever anything is changed in one of the 65 runtime js files. We might be able to do this in build, or use ant script to help

Solution B. We can add some logic in FileLocator so that it will automatically assemble a combined runtime file at initialization. We have build some nice infrastructure so that our VE or Deployer always looking for files through FileLocator. This solution would not require any "maintenance" effort in the future. 

I'm attaching a patch for solution B.
Comment 4 Tony Chen CLA 2011-11-15 08:08:29 EST
Created attachment 207021 [details]
combine js runtime
Comment 5 Justin Spadea CLA 2011-11-15 10:07:36 EST
I think I prefer solution B; it aids in development such that when we change the runtime files we don't need to run any scripts to recreate the big file for our workspace. It also prevents adding yet more "magic" to the builds.
Comment 6 Justin Spadea CLA 2011-11-15 16:53:53 EST
I ran some tests with Tony's patch. I had the HTML generator inject some timestamps right before and right after files are downloaded and the page is displayed. I used a small, medium, and large handler to see if it's a percentage gain or a flat gain. XULRunner and WebKit had similar numbers.

Small app:
ONE FILE:	83
MANY FILES:	183
faster by 100ms

Medium app:
ONE FILE:	730
MANY FILES:	840
faster by 110ms

Large app:
ONE FILE:	1950
MANY FILES:	2100
faster by 150ms

For small apps it does feel snappier, but once you have several widgets the gain is much less. If you think about a page with 20 TextFields, it only downloads TextField.js once and then renders 20 widgets. Thus larger apps have smaller savings because most of the wait is on the rendering and not the download. I'd be interested to hear others opinions on how much better it feels with "real" apps.
Comment 7 Tony Chen CLA 2011-11-16 09:48:55 EST
Justin, 

I did similar measurement as you did. The result shows that there's a flat gain around 250ms. I'm measuring the time from HTML file is generated to EVServer gets the first ___getevent from browser. (the difference with your number is probably because of different machine performance).

1 widget 
ONE FILE: 378ms
MANY FILES: 641ms
faster by:  263ms

13 widgets
ONE FILE: 688
MANY FILES: 941ms
faster by:  253ms

13 widgets
ONE FILE: 688
MANY FILES: 941ms
faster by:  253ms

11 widgets(101 instances)
ONE FILE: 589
MANY FILES: 826ms
faster by:  237ms


Although this does not seem to be a huge improvement, I'm still interested in putting this into 0.7. To get good user experience with VE, we really need the response time to be sub seconds, and to get to that, 250ms is also important. 

In deployed application, there's usually a bigger network latency. If we are doing too many round trip with the server, it could hurt the performance.
Comment 8 Will Smythe CLA 2011-11-16 15:22:27 EST
I tried the patch. The size of the combined .js file is really big (711KB). 81KB of it is related to org.eclipse.edt.eunit.runtime -- is this necessary during dev/debug/deployment?

We should also investigate how to minify the combined .js file --- I bet we could cut it down by 50% if it was minified.
Comment 9 Will Smythe CLA 2011-11-16 15:30:23 EST
jscompress.com takes the combined JS from 711KB to 325KB. Without eunit-related code, the compressed size becomes 265KB.

(Not suggesting we use jscompress, but pointing out the significant size reduction if we use something)
Comment 10 fahua jin CLA 2011-11-16 18:38:12 EST
(In reply to comment #9)
> jscompress.com takes the combined JS from 711KB to 325KB. Without eunit-related
> code, the compressed size becomes 265KB.
> 
> (Not suggesting we use jscompress, but pointing out the significant size
> reduction if we use something)

Compress the JS file will require additional CPU time in both server & browser side. Since our VE is in the same machine, download the JS file would not spend too much of time.
Comment 11 Will Smythe CLA 2011-11-16 20:01:53 EST
It would probably be good to do some measurements to prove that out (so, measure the time it takes to serve up the compressed vs. uncompressed file).

Also, I would think the browser would spend less time (who knows how much) parsing 250KB vs. 700KB. So, I tend to think there is value in making the file as small as possible.
Comment 12 Brian Svihovec CLA 2011-11-16 22:50:27 EST
It looks like the constant for Constants.RUI_RUNTIME_JAVASCRIPT_ALL_IN_ONE_FILE is missing.
Comment 13 Tony Chen CLA 2011-11-16 23:26:21 EST
Part of patch got into cvs together with Justin's fix for another issue. 

I just checkin the rest files so there won't be a compiling problem. The function is turned off by a flag in the code. We can turn that on after we decided to ship it.
Comment 14 Tony Chen CLA 2011-11-16 23:37:39 EST
We are not doing shinksafe because it needs CQ and was too late to start it when we realize. Neither are we doing compress probably because it was too late in 0.7. 

Both are proved feature for performance improvement in RBD. I think the target is to get both into the next release.  

combine runtime is just another performance improvement attempt. And all these 3 can be applied separately, does not needs to depend on each other. 


(In reply to comment #11)
> It would probably be good to do some measurements to prove that out (so,
> measure the time it takes to serve up the compressed vs. uncompressed file).
> 
> Also, I would think the browser would spend less time (who knows how much)
> parsing 250KB vs. 700KB. So, I tend to think there is value in making the file
> as small as possible.
Comment 15 Justin Spadea CLA 2011-11-17 10:01:30 EST
I did not notice that the file I modified also had Tony's change - that should not have been committed. Also, right now the flag to use a single big file is on not off. Should I turn it off? (The flag's purpose was to make it easy to switch back and forth for the performance testing)
Comment 16 Justin Spadea CLA 2011-11-17 13:30:57 EST
After speaking with Brian, we'll leave it enabled for now.

I put in a small change to FileLocator.java - the temp files were not being deleted on shutdown so after starting Eclipse several times I noticed lots of those 700k files in /tmp. I added: allInOneFile.deleteOnExit();
Comment 17 Tony Chen CLA 2011-11-17 20:59:13 EST
It's a good catch. Thanks!
Comment 18 Tony Chen CLA 2011-11-17 23:43:30 EST
Closing this bug, the fix is in.