Cassandra
  1. Cassandra
  2. CASSANDRA-4152

cache the hashcode of DecoratedKey as it is immutable

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Trivial Trivial
    • Resolution: Won't Fix
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
      None

      Description

      cache the hashcode of the DecoratedKey on first hashCode() call. DecoratedKey is immutable so no need to run thru all ByteBuffer bytes of the key and do hashcode math.

      applied to trunk.

        Activity

        Dave Brosius created issue -
        Dave Brosius made changes -
        Field Original Value New Value
        Attachment cache_decoratedkey_hash.diff [ 12522666 ]
        Dave Brosius made changes -
        Status Open [ 1 ] Patch Available [ 10002 ]
        Hide
        Stu Hood added a comment -

        Since I'm sure someone else will ask: "What did the benchmark look like?"

        Show
        Stu Hood added a comment - Since I'm sure someone else will ask: "What did the benchmark look like?"
        Hide
        Jonathan Ellis added a comment - - edited

        Agreed that it's not obvious this is a good trade to make. We use DK all over the place, so expanding its memory footprint makes me cautious. Also, a lot of the collections it's used in rely on comparator instead of hash.

        That said, if you have profiled a path that shows this to be a bottleneck, I'm very interested.

        Show
        Jonathan Ellis added a comment - - edited Agreed that it's not obvious this is a good trade to make. We use DK all over the place, so expanding its memory footprint makes me cautious. Also, a lot of the collections it's used in rely on comparator instead of hash. That said, if you have profiled a path that shows this to be a bottleneck, I'm very interested.
        Dave Brosius made changes -
        Status Patch Available [ 10002 ] Resolved [ 5 ]
        Resolution Won't Fix [ 2 ]
        Hide
        Dave Brosius added a comment -

        perhaps consider generating the hashcode from the token, rather than the key. Granted the 64k Key is hopefully a corner case, but using the token would provide consistency in that case as well.

        Show
        Dave Brosius added a comment - perhaps consider generating the hashcode from the token, rather than the key. Granted the 64k Key is hopefully a corner case, but using the token would provide consistency in that case as well.
        Gavin made changes -
        Workflow no-reopen-closed, patch-avail [ 12662445 ] patch-available, re-open possible [ 12749222 ]
        Gavin made changes -
        Workflow patch-available, re-open possible [ 12749222 ] reopen-resolved, no closed status, patch-avail, testing [ 12754119 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Patch Available Patch Available
        1m 32s 1 Dave Brosius 14/Apr/12 05:15
        Patch Available Patch Available Resolved Resolved
        2d 16h 36m 1 Dave Brosius 16/Apr/12 21:52

          People

          • Assignee:
            Unassigned
            Reporter:
            Dave Brosius
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development