Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-88818

Evaluate the performance benefits of hazard pointers

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Internal Code
    • Service Arch
    • Service Arch 2024-04-15, Service Arch 2024-04-29

      The primary objective is to evaluate the potential performance benefits of using hazard pointers for objects that support stale reads (e.g. replica-set configuration). The findings in this ticket will help us decide on the scheduling plan for SERVER-87020.

      We may mimic hazard pointers by creating a mutex protected shared pointer, where the mutex is optimized for readers (see SERVER-86656 for an example).

      template <class T>
      class EmulatedHazardPtr {
      public:
          EmulatedHazardPtr(const EmulatedHazardPtr& other) noexcept {
              std::shared_lock lk(other._mutex);
              _ptr = other._ptr;
          }
      
          T* get() const noexcept {
              std::shared_lock lk(_mutex);
              return _ptr.get();
          }
      
          void reset() noexcept {
              std::lock_guard lk(_mutex);
              _ptr.reset();
          }
          ...
      private:
          RWMutex _mutex;
          std::shared_ptr<T> _ptr;
      };
      

            Assignee:
            alex.li@mongodb.com Alex Li
            Reporter:
            amirsaman.memaripour@mongodb.com Amirsaman Memaripour
            Votes:
            0 Vote for this issue
            Watchers:
            17 Start watching this issue

              Created:
              Updated:
              Resolved: