auth: fix performance problem when looking up permissions

data_resource lookup uses data_resource::name(), which uses sprint(), which
uses (indirectly) locale, which takes a global lock.  This is a bottleneck
on large machines.

Fix by not using name() during lookup.

Fixes #1419
Message-Id: <1467616296-17645-1-git-send-email-avi@scylladb.com>
This commit is contained in:
Avi Kivity
2016-07-04 10:11:36 +03:00
committed by Tomasz Grabiec
parent 49cba035ea
commit 76cc0c0cf9
2 changed files with 6 additions and 1 deletions

View File

@@ -97,7 +97,7 @@ namespace std {
template <>
struct hash<auth::data_resource> {
size_t operator()(const auth::data_resource & v) const {
return std::hash<sstring>()(v.name());
return v.hash_value();
}
};

View File

@@ -41,6 +41,7 @@
#pragma once
#include "utils/hash.hh"
#include <iosfwd>
#include <set>
#include <seastar/core/sstring.hh>
@@ -137,6 +138,10 @@ public:
bool operator==(const data_resource&) const;
bool operator<(const data_resource&) const;
size_t hash_value() const {
return utils::tuple_hash()(_ks, _cf);
}
};
/**