title: TBB Concurrent Hash map
body: <p>I am implementing tbb's concurrent hash map to compare the performance of it against a suite of other concurrent hash tables.</p>
  
  <p>However the performance I get out of it is horrendous, I just can't believe it is that slow compared to other concurrent hash tables</p>
  
  <p>Here is my implementation of it:</p>
  
  <pre><code>class TBB: public TestDs{
      typedef tbb::concurrent_hash_map&lt;int,int, HashCompare&lt;int&gt; &gt; hash_t;
  private:
          hash_t _ds;
  public:
          TBB(const Configuration&amp; config) : _ds(config.initial_count) {
          }
  
      bool containsKey(int key) {
          hash_t::accessor a;
  
          if(_ds.find(a,key)){
              return true;
          }
          else 
              return false;
      }
  
      int get(int key) {
          hash_t::accessor a;
  
          if(_ds.find(a,key)){
               return (int)(a-&gt;second);
          }
          else 
              return 0;
      }
  
      int put(int key, int value) {
          return _ds.insert( std::make_pair(key, value) );
      }
  
      int remove(int key) {
          return _ds.erase(key);
      }
  
      int size() {
          return _ds.size();
      }
      const char* name() {
          return "TBB";
      }
      void print() {}
      void shutdown() {}
  
  };
  </code></pre>
  
  <p>Does anyone see any issue with my implementation or know of any reason why it may perform slow?
  It takes over 30 mins for it to insert 200,000 elements in a single thread environment. To put that in perspective, nearly all the other tables perform this test in less than 5 mins.</p>
  
  <p>Here is my build code:</p>
  
  <pre><code>-w  -DNDEBUG -g -msse2 -m32  -DINTEL -D_REENTRANT -lrt -pthread -fno-strict-aliasing -l cds -l tbb -lllalloc 
  </code></pre>
  
  <p>UPDATE: I have adjusted my testing code to prefill the hash tables to 1000, instead of 100,000.
  When running it again, tbb performs 92 op/sec while, another implementation performs 89431 op/sec. (64 thread environment)...Just saying something doesn't seem right....</p>
  
  <p>Additional Info: Computer is a HP Z600 Workstation with 6gb of ram and 6 cores.</p>
  
  <p>Notice Cross positing at : <a href="http://software.intel.com/en-us/forums/showthread.php?t=86119">http://software.intel.com/en-us/forums/showthread.php?t=86119</a></p>