efficient / libcuckoo

A high-performance, concurrent hash table
Other
1.62k stars 275 forks source link

hashpower changed #129

Open whatsthecraic opened 4 years ago

whatsthecraic commented 4 years ago

HI there,

while concurrently inserting in a hash table, the library raises the exception hashpower_changed:

  // This exception is thrown whenever we try to lock a bucket, but the
  // hashpower is not what was expected
  class hashpower_changed {};

  // After taking a lock on the table for the given bucket, this function will
  // check the hashpower to make sure it is the same as what it was before the
  // lock was taken. If it isn't unlock the bucket and throw a
  // hashpower_changed exception.
  inline void check_hashpower(size_type hp, spinlock &lock) const {
    if (hashpower() != hp) {
      lock.unlock();
      LIBCUCKOO_DBG("%s", "hashpower changed\n");
      throw hashpower_changed();
    }
  }

stack trace:

#0  0x00007ffff7cb0bbe in __cxxabiv1::__cxa_throw (obj=0x7fff7c000ba0, tinfo=0x5735f8 <typeinfo for cuckoohash_map<unsigned long, long, std::hash<unsigned long>, std::equal_to<unsigned long>, std::allocator<std::pair<unsigned long const, 
long> >, 4ul>::hashpower_changed>, dest=0x0) at /export/scratch2/dleo/temp/d20200723-7173-7q975d/gcc-10.2.0/libstdc++-v3/libsupc++/eh_throw.cc:78
#1  0x000000000049263f in cuckoohash_map<unsigned long, long, std::hash<unsigned long>, std::equal_to<unsigned long>, std::allocator<std::pair<unsigned long const, long> >, 4ul>::check_hashpower (this=0x7fffffffb580, hp=16, lock=...) at .
./third-party/libcuckoo/cuckoohash_map.hh:936
#2  0x0000000000498d14 in cuckoohash_map<unsigned long, long, std::hash<unsigned long>, std::equal_to<unsigned long>, std::allocator<std::pair<unsigned long const, long> >, 4ul>::lock_one (this=0x7fffffffb580, hp=16, i=87) at ../third-par
ty/libcuckoo/cuckoohash_map.hh:991
#3  0x0000000000498a54 in cuckoohash_map<unsigned long, long, std::hash<unsigned long>, std::equal_to<unsigned long>, std::allocator<std::pair<unsigned long const, long> >, 4ul>::slot_search<std::integral_constant<bool, false> > (this=0x7
fffffffb580, hp=16, i1=32472, i2=49204) at ../third-party/libcuckoo/cuckoohash_map.hh:1645
#4  0x0000000000495937 in cuckoohash_map<unsigned long, long, std::hash<unsigned long>, std::equal_to<unsigned long>, std::allocator<std::pair<unsigned long const, long> >, 4ul>::cuckoopath_search<std::integral_constant<bool, false> > (th
is=0x7fffffffb580, hp=16, cuckoo_path=..., i1=32472, i2=49204) at ../third-party/libcuckoo/cuckoohash_map.hh:1422
#5  0x0000000000492a44 in cuckoohash_map<unsigned long, long, std::hash<unsigned long>, std::equal_to<unsigned long>, std::allocator<std::pair<unsigned long const, long> >, 4ul>::run_cuckoo<std::integral_constant<bool, false> > (this=0x7f
ffffffb580, b=..., insert_bucket=@0x7fffe35e48d8: 0, insert_slot=@0x7fffe35e48d0: 0) at ../third-party/libcuckoo/cuckoohash_map.hh:1384
#6  0x000000000048fe6d in cuckoohash_map<unsigned long, long, std::hash<unsigned long>, std::equal_to<unsigned long>, std::allocator<std::pair<unsigned long const, long> >, 4ul>::cuckoo_insert<std::integral_constant<bool, false>, unsigned
 long> (this=0x7fffffffb580, hv=..., b=..., key=@0x83c3e20: 10321624) at ../third-party/libcuckoo/cuckoohash_map.hh:1262
#7  0x000000000048dd6e in cuckoohash_map<unsigned long, long, std::hash<unsigned long>, std::equal_to<unsigned long>, std::allocator<std::pair<unsigned long const, long> >, 4ul>::cuckoo_insert_loop<std::integral_constant<bool, false>, uns
igned long> (this=0x7fffffffb580, hv=..., b=..., key=@0x83c3e20: 10321624) at ../third-party/libcuckoo/cuckoohash_map.hh:1200
#8  0x000000000048bbe4 in cuckoohash_map<unsigned long, long, std::hash<unsigned long>, std::equal_to<unsigned long>, std::allocator<std::pair<unsigned long const, long> >, 4ul>::uprase_fn<unsigned long&, cuckoohash_map<unsigned long, lon
g, std::hash<unsigned long>, std::equal_to<unsigned long>, std::allocator<std::pair<unsigned long const, long> >, 4ul>::upsert<unsigned long&, cuckoohash_map<unsigned long, long, std::hash<unsigned long>, std::equal_to<unsigned long>, std
::allocator<std::pair<unsigned long const, long> >, 4ul>::insert<unsigned long&, long&>(unsigned long&, long&)::{lambda(long&)#1}, long&>(unsigned long&, cuckoohash_map<unsigned long, long, std::hash<unsigned long>, std::equal_to<unsigned
 long>, std::allocator<std::pair<unsigned long const, long> >, 4ul>::insert<unsigned long&, long&>(unsigned long&, long&)::{lambda(long&)#1}, long&)::{lambda(long&)#1}, long&>(unsigned long&, cuckoohash_map<unsigned long, long, std::hash<
unsigned long>, std::equal_to<unsigned long>, std::allocator<std::pair<unsigned long const, long> >, 4ul>::insert<unsigned long&, long&>(unsigned long&, long&)::{lambda(long&)#1}, long&) (this=0x7fffffffb580, key=@0x83c3e20: 10321624, fn=
...) at ../third-party/libcuckoo/cuckoohash_map.hh:574
#9  0x00000000004899a0 in cuckoohash_map<unsigned long, long, std::hash<unsigned long>, std::equal_to<unsigned long>, std::allocator<std::pair<unsigned long const, long> >, 4ul>::upsert<unsigned long&, cuckoohash_map<unsigned long, long, 
std::hash<unsigned long>, std::equal_to<unsigned long>, std::allocator<std::pair<unsigned long const, long> >, 4ul>::insert<unsigned long&, long&>(unsigned long&, long&)::{lambda(long&)#1}, long&>(unsigned long&, cuckoohash_map<unsigned l
ong, long, std::hash<unsigned long>, std::equal_to<unsigned long>, std::allocator<std::pair<unsigned long const, long> >, 4ul>::insert<unsigned long&, long&>(unsigned long&, long&)::{lambda(long&)#1}, long&) (this=0x7fffffffb580, key=@0x8
3c3e20: 10321624, fn=...) at ../third-party/libcuckoo/cuckoohash_map.hh:594
#10 0x0000000000487f47 in cuckoohash_map<unsigned long, long, std::hash<unsigned long>, std::equal_to<unsigned long>, std::allocator<std::pair<unsigned long const, long> >, 4ul>::insert<unsigned long&, long&> (this=0x7fffffffb580, key=@0x
83c3e20: 10321624) at ../third-party/libcuckoo/cuckoohash_map.hh:653

fedora 30 linux 5.0.17, gcc 10.1, debug build, libcuckoo @ f3138045810b2c2e9b59dbede296b4a5194af4f9

Can you elaborate what this is and how to solve?

Thanks

manugoyal commented 4 years ago

Hello! That is very interesting. The library should be catching the hashpower_changed exception here. So I'm curious how it managed to propagate out of run_cuckoo (line 1384 on your stack trace).

Do you happen to have a way to reproduce this issue, or somehow find out why we're not catching the hashpower_changed exception?

whatsthecraic commented 4 years ago

Hi there. I've only caught this error once, while concurrently running 40 logical threads on a server with 40 physical threads. I'm not able to provide you more context atm. The compiler was actually GCC v10.2 rather than GCC v10.1.