Uploaded image for project: 'Velocity'
  1. Velocity
  2. VELOCITY-606

Velocity 1.5 performance bottlenecks

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.5
    • 1.6
    • Engine
    • None
    • Win XP, 1 Gb, single core, Maven 2, JUnitPerf, JRat, cached Velocity templates with a ClassLoader

    Description

      I did some quite extensive profiling to identify performance bottlenecks in Velocity 1.5.

      Using Maven 2, JUnitPerf and JRat I was able to identify these methods as top bottlenecks:

      org.apache.velocity.util.introspection ClassMap - findMethod(String,Object[])
      org.apache.velocity.util.introspection IntrospectorBase - getMethod(Class,String,Object[])
      org.apache.velocity.runtime.parser.node SimpleNode - literal()
      org.apache.velocity.runtime.parser.node SimpleNode - render(InternalContextAdapter,Writer)
      org.apache.commons.collections ExtendedProperties - getBoolean(String,boolean)
      org.apache.velocity.runtime.parser.node ASTReference - render(InternalContextAdapter,Writer)

      The first two eat over 50% of the CPU with many threads. See attached screenshots.

      Interestingly enough the synchronized
      org.apache.velocity.runtime RuntimeInstance getTemplate(String,String)

      isn't a big problem when templates are cached. However, if all resources are not cached it becomes a serious performance bottleneck. ResourceCacheImpl also uses a synchronized map which slows things down.

      I think these bottlenecks could be at least made less worse by reducing synchronization by using ConcurrentHashMap and StringBuilder that ship with JDK 1.5. I'm investigating what kind of benefits could be achieved with those.

      Attachments

        1. velocity-1.5-250-threads-loadtest.PNG
          127 kB
          Jarkko Viinamäki
        2. velocity-1.5-50-threads-loadtest.PNG
          127 kB
          Jarkko Viinamäki
        3. velocity-1.6-dev-concurrentmods.patch
          26 kB
          Jarkko Viinamäki
        4. velocity-1.6-dev-concurrentpatch-250-threads-loadtest.PNG
          119 kB
          Jarkko Viinamäki
        5. velocity-1.6-head-20080725-test.vm.PNG
          116 kB
          Jarkko Viinamäki
        6. VELOCITY-606.patch
          21 kB
          Nathan Bubna
        7. VELOCITY-606-light.patch
          11 kB
          Nathan Bubna

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            wyla Jarkko Viinamäki
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment