]> 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)
committerSage Weil <sage@redhat.com>
Tue, 26 Jun 2018 21:58:49 +0000 (16:58 -0500)
Signed-off-by: Adam Kupczyk <akupczyk@redhat.com>
(cherry picked from commit 0cdeb682af87a0703f8650e013e4685af0633f3f)

src/common/hobject.h

index 9b3f38f4494697b85e9f2e01d0c6f30a021166de..09aefd16fdedfc9a7b446fae96f77710fc3d45cd 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