Scala Programming Language
  1. Scala Programming Language
  2. SI-7237

Insufficient task support detection mechanism chooses fails to choose ForkJoin even when available/supported

    Details

      Description

      The check in https://github.com/scala/scala/blob/master/src/library/scala/collection/parallel/package.scala#L44 ...

        private[parallel] def getTaskSupport: TaskSupport =
          if (scala.util.Properties.isJavaAtLeast("1.6")) {
            val vendor = scala.util.Properties.javaVmVendor
            if ((vendor contains "Oracle") || (vendor contains "Sun") || (vendor contains "Apple")) new ForkJoinTaskSupport
            else new ThreadPoolTaskSupport
          } else new ThreadPoolTaskSupport
      

      ... is not sufficient to choose the “best” task support library available.

      Example case is Avian where, despite the existence of ForkJoin, ThreadPools are used.

      One approach could be to check for scala.util.Properties.isJavaAtLeast("1.7")) and enable ForkJoin without further vendor checks, because one can reasonably expect that if a platform declares Java 7 support it actually does.

        Issue Links

          Activity

          Hide
          Simon Ochsenreither added a comment -

          Additionally, it would make sense to add some check to the detection code for a command line argument so that the task support choice can be overridden and therefore all code paths can be tested.
          One example of issues caused by not being able to test this code is SI-7236.

          Show
          Simon Ochsenreither added a comment - Additionally, it would make sense to add some check to the detection code for a command line argument so that the task support choice can be overridden and therefore all code paths can be tested. One example of issues caused by not being able to test this code is SI-7236 .
          Hide
          Simon Ochsenreither added a comment -

          Well, if we could figure out why the vendor checks where added in the first place (digging in the history brought up some issue related to IBM's VM, but no actual tests) we could probably simplify the whole decision mechanism a lot.

          Show
          Simon Ochsenreither added a comment - Well, if we could figure out why the vendor checks where added in the first place (digging in the history brought up some issue related to IBM's VM, but no actual tests) we could probably simplify the whole decision mechanism a lot.
          Hide
          Aleksandar Prokopec added a comment -

          This check was copied from the old stdlib actors library.
          Always enabling FJP under the following condition:

          scala.util.Properties.isJavaAtLeast("1.7"))
          

          looks ok to me. Feel free to open a pull request.

          Show
          Aleksandar Prokopec added a comment - This check was copied from the old stdlib actors library. Always enabling FJP under the following condition: scala.util.Properties.isJavaAtLeast("1.7")) looks ok to me. Feel free to open a pull request.
          Hide
          Simon Ochsenreither added a comment -

          I'm currently running the test suite on IBM's J9 version 6SR13, maybe this stuff can be dropped altogether. Otherwise we would have to devise a way to actually test it.

          Show
          Simon Ochsenreither added a comment - I'm currently running the test suite on IBM's J9 version 6SR13, maybe this stuff can be dropped altogether. Otherwise we would have to devise a way to actually test it.
          Hide
          Simon Ochsenreither added a comment -

          IBM J9 also hangs with ThreadPoolTaskSupport.

          Show
          Simon Ochsenreither added a comment - IBM J9 also hangs with ThreadPoolTaskSupport.
          Hide
          Simon Ochsenreither added a comment -

          ForkJoinTaskSupport works on Hotspot, Avian and J9, while ThreadPoolTaskSupport causes the test test/files/scalacheck/parallel-collections to reliably hang on all three.

          Therefore, always use ForkJoinTaskSupport:

          2.11: https://github.com/scala/scala/pull/2249
          2.10: https://github.com/scala/scala/pull/2252

          Show
          Simon Ochsenreither added a comment - ForkJoinTaskSupport works on Hotspot, Avian and J9, while ThreadPoolTaskSupport causes the test test/files/scalacheck/parallel-collections to reliably hang on all three. Therefore, always use ForkJoinTaskSupport: 2.11: https://github.com/scala/scala/pull/2249 2.10: https://github.com/scala/scala/pull/2252
          Show
          Simon Ochsenreither added a comment - Merged. 2.10 https://github.com/scala/scala/commit/67b8de7c3ca3896a8009c881c9395227d38e0250 2.11 https://github.com/scala/scala/commit/29a9c64fda44b5ce715e6bd9b8505b155ce64574 .
          Hide
          Adriaan Moors added a comment -
          Show
          Adriaan Moors added a comment - 2.9.4: https://github.com/scala/scala/pull/2412

            People

            • Assignee:
              Simon Ochsenreither
              Reporter:
              Simon Ochsenreither
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development