Skip to content

very slow barriers (possibly futex?) #7055

@SteffenSeckler

Description

@SteffenSeckler

Windows Build Number

Microsoft Windows [Version 10.0.21390.1010]

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

5.10.16

Distro Version

Ubuntu 18.04, Ubuntu 20.04

Other Software

Docker Desktop 3.3.3

g++11 (required!)

Repro Steps

I have been testing c++11's std::barrier and it appeared VERY slow on WSL2.

Steps to reproduce:

  1. download and unpack test.zip
  2. mkdir build && cd build
  3. CC=gcc-11 CXX=g++-11 cmake .. && cmake --build .
  4. ./test

Expected Behavior

Timing results are similar to both docker on Linux (using gcc) and msvc on windows.

docker on Linux using gcc-11:

executing with_race:
 bool with_race(): 15889 instead of 20000 at iteration 0
 took: INVALID -- has a race.
executing with_atomic:
 took: 234 ms.
executing with_lock:
 took: 3489 ms.
executing with_omp_barrier:
 took: 11503 ms.
executing with_barrier:
 took: 27354 ms.

msvc (requires V16.10) on windows:

executing with_race:
 with_race: 19463 instead of 20000 at iteration 56
 took: INVALID -- has a race.
executing with_atomic:
 took: 238 ms.
executing with_lock:
 took: 1055 ms.
executing with_omp_barrier:
 took: 4144 ms.
executing with_barrier:
 took: 6422 ms.

Actual Behavior

Execution of the variant with std::barrier takes significantly (40x) longer compared to variant using openmp barriers.

executing with_race:
 bool with_race(): 10742 instead of 20000 at iteration 204
 took: INVALID -- has a race.
executing with_atomic:
 took: 177 ms.
executing with_lock:
 took: 806 ms.
executing with_omp_barrier:
 took: 2457 ms.
executing with_barrier:
 took: 96298 ms.

I am not completely certain how to determine the cause of this slowness, but when pausing the application in debug mode, it mostly resides in syscalls to futexes.

Diagnostic Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-investigationlikely actionable and/or needs more investigation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions