Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8116655

Creating Paths is very slow

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • fx2.1
    • fx2.1
    • javafx
    • Windows 7, JDK 7, JavaFX 2.1 prev.

      I am investigating the potential of JavaFX to be used
      in a GIS environment. The workhorse of my current application
      are Paths, so I did some experiments with them.

      I wrote a little demo (ButterflyDemo2) which creates and displays 2000
      butterflies in various locations, sizes and colors on the screen.
      This reflects my use-case where I have a handfull of symbol geometries from which
      I have to create many more symbol nodes.

      I found that creating these paths from path elements is incredibly slow
      compared for example with the direct creation from an SVGPath. I also
      found that the main reason for this slowness is the fact that path elements
      are not immutable. Therefore a list of node references has to be maintained by
      each path element and the creation of these references slows down the
      path creation extemely.

      So in order to verify this I created immutable versions of all path elements
      by just overwriting the addNode method. With this change the path creation
      became much faster. Even faster than the SVGPath version.

      These are the results of running ButterflyDemo2
      with different settings in ButterflySwitches.

      Create butterflies directly as SVGPaths
      NUM_BUTTERFLIES = 2000 USE_PATH_ELEMENTS = false USE_IMMUTABLE_PATH_ELEMENTS = false
      2000 butterflies created in 2679ms. Total start time was 3337ms.
      ------------------------------------------------------------------------------------

      Create butterflies from shared PathElements which are derived from the SVGPaths.
      NUM_BUTTERFLIES = 2000 USE_PATH_ELEMENTS = true USE_IMMUTABLE_PATH_ELEMENTS = false
      Initializing path elements took 46ms.
      2000 butterflies created in 22483ms. Total start time was 23114ms.
      ------------------------------------------------------------------------------------

      Create butterflies from shared IMMUTABLE PathElements which are derived from the SVGPaths.
      NUM_BUTTERFLIES = 2000 USE_PATH_ELEMENTS = true USE_IMMUTABLE_PATH_ELEMENTS = true
      Initializing path elements took 54ms.
      2000 butterflies created in 1475ms. Total start time was 2155ms.

      In this example the inefficient implementation of the path elements slows down
      the path creation by a factor of 15 !!!

      As a conclusion I would stongly suggest to provide users with a choice to
      use really immutable path elements and also exploit this fact as much as possible
      internally. This way path creation (and may be even path rendering) could
      be much improved.

            psafrata Pavel Ĺ afrata
            dpausjfx Dr. Michael Paus (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: