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

keep cached cursors buffers for a while

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • WT11.3.0, 8.1.0-rc0
    • Affects Version/s: None
    • Component/s: Not Applicable
    • Labels:
      None
    • Storage Engines
    • v8.0

      Currently, when a cursor is cached, its key and value and bound key buffers are freed.  This does not perform optimally for workloads with a lot of simple point reads.  For example, suppose I have some active table T - active enough that it is never closed.  So eventually all the sessions servicing user requests will have a cached cursor on T, call it C.  And maybe there are lots of requests like this:

        # pseudocode ahead!
        S = get_cached_session() 
        C = session.open_cursor(T)
        C.set_key(key_id)
        C.search()
        value = C.get_value()
        C.close()
        cache_session(S)

      When we do the search, we'll retrieve the value and put it into WT_CURSOR.value .  That operation allocates it own buffer in WT_CURSOR.value.  That will be kept and potentially can be reused as long as the cursor is open.  But for workloads that do lots of simple requests like the above, we don't use the buffer for value again - the C.close() puts the cursor in a cached state and releases the memory for the value (and key and bound keys as well).

      I think we can do better by leveraging the session cached cursor sweep.  That is, we wouldn't free key/value/upper_bound/lower_bound when the cursor is put into the cached state.  Periodically, the sweep is invoked, we visit every cached cursor about once a minute or two.  We could free buffers at the time (simple, but crude) or more sophisticated - have a count on a cursor that says how many times the sweep has visited without the cursor being reused.  Simple may be good enough here.

      (component: cursors)

            Assignee:
            donald.anderson@mongodb.com Donald Anderson
            Reporter:
            donald.anderson@mongodb.com Donald Anderson
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: