Monday, August 31, 2015

Re: Why code ends up in Left over Soyc report? How to analyze?


Yes, I understand what you mean, but I though that in GWT 2.7.0, GWT will create smaller code fragments that are shared between split points, and don't necessary be in the left over fragment (= initial download eventually).
So why does GWT not create a small left over for Total and then a big "left-over" shared code fragment that is shared between Ztoeslag and Declare and is loaded when one of these apps are loaded (as a left-over fragment), so it's not part of the initial left-over. 
This is for me the expected behavior, especially as Total is very little and hardly share any code with Ztoeslag and Declare like explained in the first post. 
What am I not understanding here?
 
You just have a single large App. By definition when using code splitting GWT will split your app into three major components:

1. a single initial fragment (contains code that is required by GWT to work and code that is in no split point at all)
2. any number of fragments that represent your split points (fragments might be less than split points if merging has been enabled)
3. a single left-over fragment (contains code that is required by multiple split points and will be downloaded before any other split point fragment is loaded)

(with "fragment" being a dedicated, downloadable *.js file)

Thats it. Something like multiple left-over fragments do not exists in GWT. Your IDE project of Total might be small, but the GWT app is large because you have inherited Ztoeslag and Declare into your Total app. The compiler does not care about the structure in your head ;) It just sees that single large Total app and the split points you have defined in your code. And if code is reachable through multiple split points then this code will end up in the left-over fragment. Its all just static code analysis.

Its really as simple as that. I am really unsure what you can not understand from that definition. InkomstenOverzichtCalculator2011 is reachable through two split points (createCodeSplitDeclare100 and the merged #4 from your UtilsTotal) so its in the left-over fragment. If you don't want it to be there, fix the two call chains so it becomes exclusive to a single split point.

The only thing that is configurable in code splitting is:
- fragmentCount: enables fragment merging. You can play with the number a bit to see different end results and choose what best fits your needs
- the initial fragment loading sequence [1]: That means if you know the order any user will execute the split points in your app then you can tell the compiler about it and the compiler will distribute shared code (thats normally in the left over fragment) a bit differently. But I assume that it is probably not very helpful here.

And to be complete because you might not know it: Since GWT 2.6 you can place GWT.runAsync(MySplitPoint.class, ....) multiple times into your code base and all occurrences will contribute to the same MySplitPoint split point. So if you use class literals to define your split points there is no need anymore to pipe everything through a single runAsync call. This gives you a bit more freedom in your code. 


[1] http://www.gwtproject.org/doc/latest/DevGuideCodeSplitting.html#sequence


-- J.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment