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

Migrate WiredTiger to the C11 memory model

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Duplicate
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • None
    • Not Needed

    Description

      It should be possible provide implementations of the following section of gcc.h in terms of C11 intrinsics given a sufficiently new version of GCC:

      https://github.com/wiredtiger/wiredtiger/blob/be18e7cf192c5ef7a6b782370a3765a0883a5186/src/include/gcc.h#L155-L236

      Doing so would make the code more portable. In particular, we would like to be able to target both -march=z9-109 -mtune=z10 and -march=z196 -mtune=zEC12 in MongoDB 3.4, which have different barrier instructions, but there is no preprocessor define which distinguishes these settings.

      We would need to find the appropriate incantation for each of

      • WT_PAUSE
      • WT_BARRIER
      • WT_WRITE_BARRIER
      • WT_READ_BARRIER
      • WT_FULL_BARRIER

      The following table contains a proposed mapping from the x86 primitives to the C11 equivalent.

      macro x86 C11 proposal
      WT_BARRIER

      __asm__ volatile("" ::: "memory")

      atomic_signal_fence(memory_order_acq_rel)

      WT_READ_BARRIER

      __asm__ volatile ("lfence" ::: "memory"

      atomic_thread_fence(memory_order_acquire)

      WT_WRITE_BARRIER

      __asm__ volatile ("sfence" ::: "memory"

      atomic_thread_fence(memory_order_release)

      WT_FULL_BARRIER

      __asm__ volatile ("mfence" ::: "memory")

      atomic_thread_fence(memory_order_acq_rel)

      These seem to be the only options, in terms of API calls, because all of the other C11 atomic operations act on specific memory addresses - only atomic_signal_fence and atomic_thread_fence do not.

      Attachments

        Activity

          People

            backlog-server-storage-engines Backlog - Storage Engines Team
            andrew.morrow@mongodb.com Andrew Morrow (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            13 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: