gwtproject / gwt

GWT Open Source Project
http://www.gwtproject.org
1.52k stars 375 forks source link

Most bytes in SOYC report can't be attributed to a package #9250

Open ekuefler opened 8 years ago

ekuefler commented 8 years ago

I have a ~7MB GWT application with no split points. When creating a SOYC report, the items in the "Package breakdown" and "Code Type Breakdown" account for only a small portion of this (1.4MB). I get a message at the bottom of the Code Type Breakdown stating that "5747524 bytes of the JavaScript output cannot be attributed to any package or code type". That's almost 80% of my app, which makes the report not very useful.

Why would my code not be accounted for and what can I do to fix it?

rluble commented 8 years ago

That is most likely a regression in the GWT compiler. There have been several fixes since December, is it still the case that most of the code is unaccounted for?

ekuefler commented 8 years ago

Yeah, things definitely look improved - after switching to 2.8RC2 I'm down to about 6% unattributed. Still curious where that's coming from, but the report is usable now.

rluble commented 8 years ago

The unattributed code contains for example interned strings (this is mostly due to the fact that the accounting is done at a JS statement level and interned strings appear in a single statement, also statements are attributed to a single cause and string interning by its nature each interned definition has multiple causes).

The attribution is computed in GenerateJavaScriptAST by calls to addMethodDefinitionStatement and addTypeDefinitionStatement as statements are created. We must be missing some there (I fixed quite a few there) and also special care has to be taken by the JavaScript optimizations (this information is stored in JavaToJavaScriptMap). We might have some JavaScript AST optimizations or JavaScript source transformers that mess some of these, I don't know for sure. Feel free to play with this and send patches.

I helps to see what types of lines are unattributed to know where is the problem.