Investigating benchmark u64 failures.
This commit is contained in:
parent
334f5592ea
commit
8b1d7da028
@ -72,8 +72,13 @@ class BM_SearchUint64 : public SearchUint64Benchmark {
|
|||||||
}
|
}
|
||||||
mymap_.rehash(mymap_.bucket_count());
|
mymap_.rehash(mymap_.bucket_count());
|
||||||
// Double check if everything is all right
|
// Double check if everything is all right
|
||||||
|
cerr << "Doing double check" << endl;
|
||||||
for (uint32_t i = 0; i < values_.size(); ++i) {
|
for (uint32_t i = 0; i < values_.size(); ++i) {
|
||||||
if (mymap_[values_[i]] != values_[i]) return false;
|
if (mymap_[values_[i]] != values_[i]) {
|
||||||
|
fprintf(stderr, "Looking for %u th key value %llu yielded %llu\n",
|
||||||
|
i ,values_[i], mymap_[values_[i]]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -95,12 +100,14 @@ using namespace cxxmph;
|
|||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
srandom(4);
|
srandom(4);
|
||||||
|
/*
|
||||||
Benchmark::Register(new BM_CreateUrls<mph_map<StringPiece, StringPiece>>("URLS100k"));
|
Benchmark::Register(new BM_CreateUrls<mph_map<StringPiece, StringPiece>>("URLS100k"));
|
||||||
Benchmark::Register(new BM_CreateUrls<unordered_map<StringPiece, StringPiece>>("URLS100k"));
|
Benchmark::Register(new BM_CreateUrls<unordered_map<StringPiece, StringPiece>>("URLS100k"));
|
||||||
Benchmark::Register(new BM_SearchUrls<mph_map<StringPiece, StringPiece>>("URLS100k", 10*1000 * 1000, 0));
|
Benchmark::Register(new BM_SearchUrls<mph_map<StringPiece, StringPiece>>("URLS100k", 10*1000 * 1000, 0));
|
||||||
Benchmark::Register(new BM_SearchUrls<unordered_map<StringPiece, StringPiece, Murmur3StringPiece>>("URLS100k", 10*1000 * 1000, 0));
|
Benchmark::Register(new BM_SearchUrls<unordered_map<StringPiece, StringPiece, Murmur3StringPiece>>("URLS100k", 10*1000 * 1000, 0));
|
||||||
Benchmark::Register(new BM_SearchUrls<mph_map<StringPiece, StringPiece>>("URLS100k", 10*1000 * 1000, 0.9));
|
Benchmark::Register(new BM_SearchUrls<mph_map<StringPiece, StringPiece>>("URLS100k", 10*1000 * 1000, 0.9));
|
||||||
Benchmark::Register(new BM_SearchUrls<unordered_map<StringPiece, StringPiece, Murmur3StringPiece>>("URLS100k", 10*1000 * 1000, 0.9));
|
Benchmark::Register(new BM_SearchUrls<unordered_map<StringPiece, StringPiece, Murmur3StringPiece>>("URLS100k", 10*1000 * 1000, 0.9));
|
||||||
|
*/
|
||||||
Benchmark::Register(new BM_SearchUint64<mph_map<uint64_t, uint64_t>>);
|
Benchmark::Register(new BM_SearchUint64<mph_map<uint64_t, uint64_t>>);
|
||||||
Benchmark::Register(new BM_SearchUint64<unordered_map<uint64_t, uint64_t>>);
|
Benchmark::Register(new BM_SearchUint64<unordered_map<uint64_t, uint64_t>>);
|
||||||
Benchmark::RunAll();
|
Benchmark::RunAll();
|
||||||
|
@ -79,11 +79,10 @@ class mph_map {
|
|||||||
inline const_iterator find(const key_type& k) const;
|
inline const_iterator find(const key_type& k) const;
|
||||||
typedef int32_t my_int32_t; // help macros
|
typedef int32_t my_int32_t; // help macros
|
||||||
inline int32_t index(const key_type& k) const;
|
inline int32_t index(const key_type& k) const;
|
||||||
inline int32_t index2(const key_type& k) const;
|
|
||||||
data_type& operator[](const key_type &k);
|
data_type& operator[](const key_type &k);
|
||||||
const data_type& operator[](const key_type &k) const;
|
const data_type& operator[](const key_type &k) const;
|
||||||
|
|
||||||
size_type bucket_count() const { return index_.perfect_hash_size() + slack_.bucket_count(); }
|
size_type bucket_count() const { return index_.minimal_perfect_hash_size() + slack_.bucket_count(); }
|
||||||
void rehash(size_type nbuckets /*ignored*/);
|
void rehash(size_type nbuckets /*ignored*/);
|
||||||
|
|
||||||
protected: // mimicking STL implementation
|
protected: // mimicking STL implementation
|
||||||
@ -154,13 +153,13 @@ MPH_MAP_METHOD_DECL(void_type, pack)() {
|
|||||||
make_iterator_first(begin()),
|
make_iterator_first(begin()),
|
||||||
make_iterator_first(end()), size_);
|
make_iterator_first(end()), size_);
|
||||||
if (!success) { exit(-1); }
|
if (!success) { exit(-1); }
|
||||||
vector<value_type> new_values(index_.perfect_hash_size());
|
vector<value_type> new_values(index_.minimal_perfect_hash_size());
|
||||||
new_values.reserve(new_values.size() * 2);
|
new_values.reserve(new_values.size() * 2);
|
||||||
vector<bool> new_present(index_.perfect_hash_size(), false);
|
vector<bool> new_present(index_.minimal_perfect_hash_size(), false);
|
||||||
new_present.reserve(new_present.size() * 2);
|
new_present.reserve(new_present.size() * 2);
|
||||||
for (iterator it = begin(), it_end = end(); it != it_end; ++it) {
|
for (iterator it = begin(), it_end = end(); it != it_end; ++it) {
|
||||||
size_type id = index_.perfect_hash(it->first);
|
size_type id = index_.minimal_perfect_hash(it->first);
|
||||||
assert(id < index_.perfect_hash_size());
|
assert(id < index_.minimal_perfect_hash_size());
|
||||||
assert(id < new_values.size());
|
assert(id < new_values.size());
|
||||||
new_values[id] = *it;
|
new_values[id] = *it;
|
||||||
new_present[id] = true;
|
new_present[id] = true;
|
||||||
@ -211,21 +210,11 @@ MPH_MAP_INLINE_METHOD_DECL(iterator, find)(const key_type& k) {
|
|||||||
return make_solid(&values_, &present_, vit);;
|
return make_solid(&values_, &present_, vit);;
|
||||||
}
|
}
|
||||||
|
|
||||||
MPH_MAP_INLINE_METHOD_DECL(my_int32_t, index2)(const key_type& k) const {
|
|
||||||
if (__builtin_expect(index_.perfect_hash_size(), 1)) {
|
|
||||||
auto perfect_hash = index_.perfect_hash(k);
|
|
||||||
return perfect_hash;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MPH_MAP_INLINE_METHOD_DECL(my_int32_t, index)(const key_type& k) const {
|
MPH_MAP_INLINE_METHOD_DECL(my_int32_t, index)(const key_type& k) const {
|
||||||
if (__builtin_expect(index_.perfect_hash_size(), 1)) {
|
if (__builtin_expect(index_.minimal_perfect_hash_size(), 1)) {
|
||||||
auto perfect_hash = index_.perfect_hash(k);
|
auto minimal_perfect_hash = index_.minimal_perfect_hash(k);
|
||||||
if (__builtin_expect(present_[perfect_hash], true)) {
|
if (__builtin_expect(present_[minimal_perfect_hash], true)) {
|
||||||
return perfect_hash;
|
return minimal_perfect_hash;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (__builtin_expect(!slack_.empty(), 0)) {
|
if (__builtin_expect(!slack_.empty(), 0)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user