Uploaded image for project: 'WiredTiger'
  1. WiredTiger
  2. WT-7092

Reduce calls to hash URI when opening/closing cached cursors by one

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • WT10.0.1, 4.4.7, 5.0.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • 3
    • Storage - Ra 2021-05-03

      When a cursor is opened we compute a hash value based on the given URI.  We use that to select a hash bucket and look for a cached cursor in that bucket.  If we can't find it, we create a new cursor.

      When a cursor is closed, we want to release it to the cache, and we potentially compute the hash value again.  We do this (paraphrased) code:

      if (cursor->uri_hash == 0)
         cursor->uri_hash = hash_function(uri);
      bucket = cursor->uri_hash % HASH_SIZE;
      TAILQ_INSERT_HEAD(&session->cursor_cache[bucket], cursor, q);

      When the cursor is first created, if we can fill cursor->uri_hash with the hash value that we computed when looking in the hash table, we'll do one less hash call in the life of the cursor.

      This might add up especially for use cases that have huge number of collections that are seldom reused in a session.

            Assignee:
            ravi.giri@mongodb.com Ravi Giri
            Reporter:
            donald.anderson@mongodb.com Donald Anderson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: