]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/performance: improved hash calculation for hobject_t and ghobject_t
authorAdam Kupczyk <akupczyk@redhat.com>
Tue, 29 May 2018 10:43:33 +0000 (12:43 +0200)
committerAdam Kupczyk <akupczyk@redhat.com>
Tue, 29 May 2018 14:16:44 +0000 (16:16 +0200)
Signed-off-by: Adam Kupczyk <akupczyk@redhat.com>
src/common/hobject.h

index 03abd4bd5517388dee9adae98e4fa42ffbd61768..c2d2c6b31863b4e66a61c24bb1d85e69f66068f0 100644 (file)
@@ -300,8 +300,13 @@ WRITE_CLASS_ENCODER(hobject_t)
 namespace std {
   template<> struct hash<hobject_t> {
     size_t operator()(const hobject_t &r) const {
-      static rjhash<uint64_t> I;
-      return r.get_hash() ^ I(r.snap);
+      static std::hash<object_t> H;
+      static rjhash<uint64_t> RJ;
+      size_t hash;
+      hash = H(r.oid);
+      hash = RJ(hash ^ r.get_hash());
+      hash = RJ(hash ^ r.snap);
+      return hash;
     }
   };
 } // namespace std
@@ -473,8 +478,12 @@ WRITE_CLASS_ENCODER(ghobject_t)
 namespace std {
   template<> struct hash<ghobject_t> {
     size_t operator()(const ghobject_t &r) const {
-      static rjhash<uint64_t> I;
-      return r.hobj.get_hash() ^ I(r.hobj.snap);
+      static rjhash<uint64_t> RJ;
+      static hash<hobject_t> HO;
+      size_t hash = HO(r.hobj);
+      hash = RJ(hash ^ r.generation);
+      hash = hash ^ r.shard_id.id;
+      return hash;
     }
   };
 } // namespace std