• Re: Futexes ain't fast

    From jseigh@21:1/5 to Bonita Montero on Fri Aug 30 09:31:20 2024
    On 8/28/2024 8:09 AM, Bonita Montero wrote:
    I tested the operating-system specific mutex (CRITICAL_SECTION Or pthread_mutext_t) against a futex and a std::mutex. I guessed std::mutex
    uses th operating system specific mutex internally, but the times varied
    so much across Windows and Linux that I gues that std::mutex used at
    least a differently parametrized operating system mutex or maybe even completely own code.
    This are the times and each line has a further contender:


    They don't have to be fast, they just have to allow correct synchronization
    and allow performant fast paths. Can the api be improved for the latter? Certainly yes. It is an awkward api to use.

    Joe Seigh

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From jseigh@21:1/5 to Chris M. Thomasson on Fri Aug 30 20:36:06 2024
    On 8/30/24 15:45, Chris M. Thomasson wrote:
    On 8/30/2024 6:31 AM, jseigh wrote:
    ...

    They don't have to be fast, they just have to allow correct
    synchronization
    and allow performant fast paths.  Can the api be improved for the latter? >> Certainly yes.  It is an awkward api to use.

    100% agreed. Eventcounts are in the mix as well.


    You might take a look at folly's eventcount. It (I think) only calls
    futex wake if there are waiters, and only calls futex_wait if the
    eventcount hasn't been incremented. I did my own C version since I'm
    working in C for now.

    Joe Seigh

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)