Skip to content

Add mcfgthread#2

Open
lhmouse wants to merge 2 commits intomarkwaterman:masterfrom
lhmouse:master
Open

Add mcfgthread#2
lhmouse wants to merge 2 commits intomarkwaterman:masterfrom
lhmouse:master

Conversation

@lhmouse
Copy link

@lhmouse lhmouse commented Oct 17, 2024

The mcfgthread library https://github.com/lhmouse/mcfgthread implements fast mutex and condition variables on Windows. To test mcfgthread, it's necessary to set up an environment in an MSYS2 UCRT64 shell:

  # pacman -S mingw-w64-ucrt-x86_64-{cmake,pkgconf,ninja,boost,mcfgthread}
  # cmake .
  # ninja
  # ./MutexShootout.exe
  Usage: D:\lh_mouse\GitHub\MutexShootout\MutexShootout.exe threadCount nolocks|std|boost|cs0|cs4k|srw|mcf|mcf0i

mcf allows the locking and unlocking functions to be inlined, while mcf0i calls external functions.

Results:

  $ ./MutexShootout.exe 16 srw
  srw_mutex:        29.3014
  $ ./MutexShootout.exe 16 mcf
  mcf_mutex:        14.2265
  $ ./MutexShootout.exe 16 mcf0i
  mcf_mutex (noinline): 13.4116

@lhmouse
Copy link
Author

lhmouse commented Oct 17, 2024

The mcfgthread library <https://github.com/lhmouse/mcfgthread> implements
fast mutex and condition variables on Windows. To test mcfgthread, it's
necessary to set up an environment in an MSYS2 UCRT64 shell:

  # pacman -S mingw-w64-ucrt-x86_64-{cmake,pkgconf,ninja,boost,mcfgthread}
  # cmake .
  # ninja
  # ./MutexShootout.exe
  Usage: D:\lh_mouse\GitHub\MutexShootout\MutexShootout.exe threadCount nolocks|std|boost|cs0|cs4k|srw|mcf|mcf0i

`mcf` allows the locking and unlocking functions to be inlined, while
`mcf0i` calls external functions.

Results:

  $ ./MutexShootout.exe 16 srw
  srw_mutex:        29.3014
  $ ./MutexShootout.exe 16 mcf
  mcf_mutex:        14.2265
  $ ./MutexShootout.exe 16 mcf0i
  mcf_mutex (noinline): 13.4116

Signed-off-by: LIU Hao <lh_mouse@126.com>
@lhmouse
Copy link
Author

lhmouse commented Oct 18, 2024

Here are test results on Windows 11 on ARM 24H2 (Dev channel) on Huawei MateBook E Go 2023, with an 8-core Snapdragon 8cx Gen 3, using Clang 18 as the compiler:

1 thread

  • CLANGARM64 ~/GitHub/MutexShootout
  • $ for s in nolocks std boost cs0 cs4k srw mcf mcf0i; do ./MutexShootout.exe 1 $s; done
    No locking: 35.8718
    std::mutex: 37.1544
    boost::mutex: 37.821
    cs_mutex_nospin: 36.7659
    cs_mutex_4K: 36.7416
    srw_mutex: 36.4696
    mcf_mutex: 36.675
    mcf_mutex (noinline): 36.6938

4 threads

  • CLANGARM64 ~/GitHub/MutexShootout
  • $ for s in std boost cs0 cs4k srw mcf mcf0i; do ./MutexShootout.exe 4 $s; done
    std::mutex: 43.9401
    boost::mutex: 59.4707
    cs_mutex_nospin: 68.5111
    cs_mutex_4K: 49.7991
    srw_mutex: 44.9692
    mcf_mutex: 51.0564
    mcf_mutex (noinline): 51.0674

8 threads

  • CLANGARM64 ~/GitHub/MutexShootout
  • $ for s in std boost cs0 cs4k srw mcf mcf0i; do ./MutexShootout.exe 8 $s; done
    std::mutex: 53.0173
    boost::mutex: 62.0042
    cs_mutex_nospin: 64.7601
    cs_mutex_4K: 63.4763
    srw_mutex: 54.9078
    mcf_mutex: 57.6587
    mcf_mutex (noinline): 56.6434

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant