Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-323

Compilation speedup

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.0-beta-4
    • 1.0-beta-5
    • class generator
    • None

    Description

      I have done a bit of profiling on groovy compiler and it turned out that for simple test (10 times compiling 4kb groovy script), 75% of time was spent in CompileUnit.loadClass. It is trivial to cache results of this calls. With attached patch, time for running test was reduced from 6500ms to 1800ms - almost 4x speedup for this single method. Cost is rather small - map with type->class (and most important NO_CLASS) cache.

      After removing this hotspot, another loadClass hotspots have appeared - it would be best to search for everything which has loadClass in name and refactor/cache everything which is not really needed or can be done in different way. Loadclass call is extremly heavy - it should be avoided at all costs, even if this means having cache of answers at many levels.

      Another problem is control-flow through exceptions, which is enforced through ClassLoader.loadClass. With cache, it could be possibly avoided - exceptions are also quite heavy, especially if they are thrown always for common case of non-class identifier. But this is major change, not for this patch.

      Attachments

        1. ListTest.groovy
          4 kB
          Artur Biesiadowski
        2. patch.txt
          3 kB
          Artur Biesiadowski

        Activity

          People

            jstrachan James Strachan
            abies Artur Biesiadowski
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: