1

I'm trying to improve the speed of GWT compilation, in the GWT documentation I see they provide multiple ways. I was considering optimize and draftCompile arguments passed to the compiler. Documentation gives confusing description:

draftCompile ==> Compile quickly with minimal optimizations.

optimize ==> Sets the optimization level used by the compiler.  0=none 9=maximum.

I'm trying to find difference between these two and should I use both or they have same effect? What's their individual effect? I used optimize 0 and draftCompile together and didn't see any difference in compile time from when I use just optimize 0.
Googled a lot but not getting any precise explanation for this.
I'm new to GWT, (actually tasked to look at one of the legacy projects in my organization).

Looking for insights from experienced GWT programmers on this. Thanks.

Akshay Hiremath
  • 950
  • 2
  • 12
  • 34
  • 1
    if nobody answers in a day or so, i would advise you to ask for help on the gitter gwt channel: https://gitter.im/gwtproject/gwt (provide the link of this post there for others to find the answer) – Andrei F Jun 14 '22 at 10:46
  • 2
    Thanks @AndreiF, GWT doyen Colin answered the question. I see he is a very experienced voice in GWT everywhere on the internet :-) – Akshay Hiremath Jun 15 '22 at 19:45

1 Answers1

2

Among other things, the "draft" flag sets the optimization level to zero.

From https://github.com/gwtproject/gwt/blob/c32238861c4d58bc559d303ab44f91ddd4e10685/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerDraftCompile.java, the class that handles the -draftCompile flag:

  public boolean setFlag(boolean value) {
    int optimizeLevel =
        value ? OptionOptimize.OPTIMIZE_LEVEL_DRAFT : OptionOptimize.OPTIMIZE_LEVEL_DEFAULT;
    optimizeOption.setOptimizationLevel(optimizeLevel);

    clusterSimilarFunctionsOption.setClusterSimilarFunctions(!value);
    inlineLiteralParametersOption.setInlineLiteralParameters(!value);
    namespaceOption.setNamespace(JsNamespaceOption.PACKAGE);
    if (value) {
      optimizeDataflowOption.setOptimizeDataflow(false);
    }
    ordinalizeEnumsOption.setOrdinalizeEnums(!value);
    removeDuplicateFunctionsOption.setRemoveDuplicateFunctions(!value);

    return true;
  }
Colin Alworth
  • 17,801
  • 2
  • 26
  • 39
  • I’m not much familiar with the GWT compiler and its internal workings but it seems from the answer and the code snippet if I use draftCompile I can skip the optimize 0. Is this understanding right? – Akshay Hiremath Jun 15 '22 at 14:03
  • 1
    Correct, draft is sufficient, though you can also apply those other settings if you wish, after the draft flag. – Colin Alworth Jun 15 '22 at 18:23