ExportXMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Transactions
    • None
    • Storage Engines - Transactions
    • 19.697
    • None
    • None

      When a thread builds a snapshot in __txn_get_snapshot_int, it waits for any session that is in the middle of getting a transaction ID (is_allocating set). The wait loop only calls pause. It has no limit and never yields.

      Getting an ID takes a few instructions. If the OS takes that thread off the CPU inside this window, every thread that builds a snapshot spins until the thread runs again. This happens when more threads are ready to run than there are CPUs.

      We found it while testing the schema lock change for WT-18928. That change lets more writers run at the same time, so the spin became visible:

      • Linux machine, AMD Ryzen 5 3600 (6 cores, 12 threads), 200,000 tables, 32 writers, 100,000 writes/s, each write opens and closes a cursor;
      • __txn_get_snapshot_int takes 1.8-2.4% of CPU samples on develop and 19-22% with the WT-18928 change; about 90% of these samples are on pause;
      • the thread getting an ID is taken off the CPU inside this window 1.1 times per second on develop and 17.2 times per second with the change.

      Proposed fix: call yield after 1000 pauses. Short 200 s runs, 2 per build:

      • p99.9 write latency: develop 117-121 us, WT-18928 change 3,867 us, change + yield 125-168 us;
      • process CPU per run: develop 276-286 s, change 402-406 s, change + yield 298-315 s.

      Patch, scripts, exact wiredtiger_open config and raw results are attached.

            Assignee:
            [DO NOT USE] Backlog - Storage Engines Team
            Reporter:
            Mikhail Sotnikov (EXT)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: