artemis-odb icon indicating copy to clipboard operation
artemis-odb copied to clipboard

[Performance] Reflection cache prevents GWT dead code elimination

Open DaanVanYperen opened this issue 3 years ago • 0 comments

Summary

Optimized GWT removes dead code. The reflection cache contains call sites for all methods on all included types and this prevents dead code elimination for those types, leading to larger js files.

Details

A proof on my last game with method callsites suppressed from the odb cache only (see file size): image (Just removing the call-sites breaks the cache obviously but there might be some improvements to be had here).

Compiled with:

    compiler {
        strict = true
        disableCastChecking = true
        disableAggressiveOptimization = false
        draftCompile = false
        optimize = 9
    }

Options

Solving this might yield an estimated ~10-20% size decrease of the final js. Definitely underlines why having two caches is a bad idea.

  • [ ] Document this behavior. It isn't too obvious if your knowledge of GWT is black-box.
  • [ ] Remove the need for a duplicate cache. Biggest win for ODB/GDX users. Problem is the forced GDX dep (is it a problem?).
  • [ ] Pruning the default included types where possible. We pull in large parts of the odb/gdx libraries by default.
  • [ ] Granular scoping of methods/fields to include? We use reflection for very specific use cases.

DaanVanYperen avatar Jul 21 '21 12:07 DaanVanYperen