Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-3754

Performance of BlockState.hashCode may be improved

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • None

      When I look at a profiler's output then the BlockState.hashCode() method looks suspicious. If the profile can be trusted, it seems to consume a significant share of the server's CPU. A BlockState object has two final fields: a Class and a String object. Therefore, the hashCode() method in BlockState will always return the same value when called on the same object multiple times. Maybe caching helps?

        1. Capture.PNG
          Capture.PNG
          46 kB
        2. Capture.PNG
          Capture.PNG
          99 kB
        3. Capture_hashCodeCalls_old.PNG
          Capture_hashCodeCalls_old.PNG
          55 kB
        4. Capture_hashCodeCalls_new.PNG
          Capture_hashCodeCalls_new.PNG
          33 kB
        5. Capture_alsoCachingBlockStateEnum_hashCode.PNG
          Capture_alsoCachingBlockStateEnum_hashCode.PNG
          93 kB

            Unassigned Unassigned
            donaldduck70 Donald Duck
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: