efficient / libcuckoo

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

universal_benchmark reports a fatal error with --upserts parameter #123

Closed xingdl2007 closed 4 years ago

xingdl2007 commented 4 years ago

./universal_benchmark --reads 70 --inserts 10 --erases 10 --updates 5 --upserts 5 Generating keys Pre-filling table Running operations FATAL ERROR: tbl.insert(key(insert_seq), Gen::get(local_value))(0) is false on line 178

It seems that UPSERT branch in mix funciton is incorrect:

     case UPSERT:
         // Pick a number from the full distribution, but cap it to the
         // insert_seq, so we don't insert a number greater than
         // insert_seq.
         n = std::max(find_seq, insert_seq);
         find_seq_update();
         tbl.upsert(key(n), upsert_fn, Gen<VALUE>::get(local_value));
         if (n == insert_seq) {
           ++insert_seq;
         }
         break;

which should be

    case UPSERT:
         // Pick a number from the full distribution, but cap it to the
         // insert_seq, so we don't insert a number greater than
         // insert_seq.
         n = std::min(find_seq, insert_seq);
         tbl.upsert(key(n), upsert_fn, Gen<VALUE>::get(local_value));
         if (n == insert_seq) {
           ++insert_seq;
         } else {
           find_seq_update();
        }
         break;
manugoyal commented 4 years ago

You're totally right, thanks for pointing this out! Fixed in 6e17870f698c55b40b401938f1f20c1809a02ef6.