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

Use java.lang.Long.bitCount in BitSetFactory

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Scala 2.10.0
    • Component/s: Misc Library
    • Labels:
      None
    • Environment:

      BitSet bitCount

      Description

      Long.bitCount and Integer.bitCount use bit folding to make this computation fast. In addition to that Hotspot knows these methods and can replace them with native opcode if the CPU supports them (JDK7).

      1. BitCountPerformance.scala
        0.8 kB
        Stefan Zeiger
      2. BitSetFactoryBitCount.diff
        0.9 kB
        Jira Admin

        Issue Links

          Activity

          Hide
          Simon Ochsenreither added a comment -

          The affected code is now (2.9 trunk) located in scala/collection/BitSetLike.scala.

          Show
          Simon Ochsenreither added a comment - The affected code is now (2.9 trunk) located in scala/collection/BitSetLike.scala.
          Hide
          Stefan Zeiger added a comment -

          Almost 10x performance improvement on Java 7 x64:

          C:\Users\szeiger\Desktop>scala BitCountPerformance
          bitCount: 637ms -> 1962026240
          popCount: 5242ms -> 1962026240

          C:\Users\szeiger\Desktop>java -version
          java version "1.7.0"
          Java(TM) SE Runtime Environment (build 1.7.0-b147)
          Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode)

          Show
          Stefan Zeiger added a comment - Almost 10x performance improvement on Java 7 x64: C:\Users\szeiger\Desktop>scala BitCountPerformance bitCount: 637ms -> 1962026240 popCount: 5242ms -> 1962026240 C:\Users\szeiger\Desktop>java -version java version "1.7.0" Java(TM) SE Runtime Environment (build 1.7.0-b147) Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode)
          Show
          Simon Ochsenreither added a comment - Fixed in https://github.com/scala/scala/commit/989c0d0693e27d06d1f70524b66527d1ef12f5a2 .

            People

            • Assignee:
              Stefan Zeiger
              Reporter:
              Matthias Mann
              TracCC:
              Johannes Rudolph, Simon Ochsenreither
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development