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

Correct the comment about WT's memory model in gcc.h

    • Type: Icon: Technical Debt Technical Debt
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • WT11.3.0, 8.1.0-rc0
    • Affects Version/s: None
    • Component/s: Not Applicable
    • None
    • Storage Engines
    • 13
    • Megabat - 2024-05-14, 2024-05-28 - FOLLOW ON SPRINT, 2024-06-11 - Dinosaurs go rawr

      In gcc.h, we have some comment documenting the WT memory model. However, there seems to be some content that is not correct anymore. For example:

      WiredTiger additionally requires atomic writes for 64-bit memory locations, and so cannot run on machines with a 32-bit memory bus.

      I think wt also requires atomic reads for 64-bit memory locations. According to Mathias, there is nothing to do with the memory bus. wt should be able to run with 32-bit memory bus.

      Lock and unlock operations imply both read and write barriers.

      In the mutex_inline.h implementation, our spinlock implementation actually uses acquire for lock and release for unlock, which indicates lock in a read barrier and unlock is a write barrier not full barriers means that memory accesses outside are allowed to move into the critical section, but not out (roach motel semantics). In particular, this allows accesses before the critical section to happen after accesses after the critical section, as long as they are both moved inside first. This turns out to be fine for the vast majority of algorithms, because the stuff outside the critical section usually doesn't depend on ordering, and when it does, it is usually fine if it happens inside a locked region.

      Therefore, this line seems also wrong:

      In summary, locking > barriers > volatile

            Assignee:
            luke.pearson@mongodb.com Luke Pearson
            Reporter:
            chenhao.qu@mongodb.com Chenhao Qu
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: