• Mutex contention profiler

    From Mr Flibble@flibble@red-dwarf.jmc.corp to comp.theory on Sun Dec 21 21:36:49 2025
    From Newsgroup: comp.theory

    In neolib (C++ support library used by neoGFX) you can now profile
    spinlock mutex contention. #cpp #coding #gamedev

    static struct debug_mutexes : neolib::i_mutex_profiler_observer
    {
    void mutex_contended(neolib::i_lockable& aMutex, const std::chrono::microseconds& aContendedFor,
    neolib::mutex_lock_info const* aPreviousLocks,
    std::size_t aPreviousLocksCount) noexcept final
    {
    }
    } sDebugMutexes;

    service<neolib::i_mutex_profiler>().enable(std::chrono::microseconds{ 100 }, 10u, true);
    service<neolib::i_mutex_profiler>().subscribe(sDebugMutexes);

    /Flibble
    --
    meet ever shorter deadlines, known as "beat the clock"
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Chris M. Thomasson@chris.m.thomasson.1@gmail.com to comp.theory on Mon Dec 22 13:37:18 2025
    From Newsgroup: comp.theory

    On 12/21/2025 1:36 PM, Mr Flibble wrote:
    In neolib (C++ support library used by neoGFX) you can now profile
    spinlock mutex contention. #cpp #coding #gamedev

    static struct debug_mutexes : neolib::i_mutex_profiler_observer
    {
    void mutex_contended(neolib::i_lockable& aMutex, const std::chrono::microseconds& aContendedFor,
    neolib::mutex_lock_info const* aPreviousLocks, std::size_t aPreviousLocksCount) noexcept final
    {
    }
    } sDebugMutexes;

    service<neolib::i_mutex_profiler>().enable(std::chrono::microseconds{ 100 }, 10u, true);
    service<neolib::i_mutex_profiler>().subscribe(sDebugMutexes);

    spinlock mutex contention. Humm. Are you using spinlock, mutex or
    adaptive mutex?
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Mr Flibble@flibble@red-dwarf.jmc.corp to comp.theory on Mon Dec 22 21:49:30 2025
    From Newsgroup: comp.theory

    On Mon, 22 Dec 2025 13:37:18 -0800, Chris M. Thomasson wrote:

    On 12/21/2025 1:36 PM, Mr Flibble wrote:
    In neolib (C++ support library used by neoGFX) you can now profile
    spinlock mutex contention. #cpp #coding #gamedev

    static struct debug_mutexes :
    neolib::i_mutex_profiler_observer {
    void mutex_contended(neolib::i_lockable& aMutex, const
    std::chrono::microseconds& aContendedFor,
    neolib::mutex_lock_info const* aPreviousLocks,
    std::size_t aPreviousLocksCount) noexcept final
    {
    }
    } sDebugMutexes;

    service<neolib::i_mutex_profiler>().enable(std::chrono::microseconds{
    100 },
    10u, true);

    service<neolib::i_mutex_profiler>().subscribe(sDebugMutexes);

    spinlock mutex contention. Humm. Are you using spinlock, mutex or
    adaptive mutex?

    spinlock (non-pure).

    /Flibble
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Chris M. Thomasson@chris.m.thomasson.1@gmail.com to comp.theory on Mon Dec 22 13:51:11 2025
    From Newsgroup: comp.theory

    On 12/22/2025 1:49 PM, Mr Flibble wrote:
    On Mon, 22 Dec 2025 13:37:18 -0800, Chris M. Thomasson wrote:

    On 12/21/2025 1:36 PM, Mr Flibble wrote:
    In neolib (C++ support library used by neoGFX) you can now profile
    spinlock mutex contention. #cpp #coding #gamedev

    static struct debug_mutexes :
    neolib::i_mutex_profiler_observer {
    void mutex_contended(neolib::i_lockable& aMutex, const >>> std::chrono::microseconds& aContendedFor,
    neolib::mutex_lock_info const* aPreviousLocks,
    std::size_t aPreviousLocksCount) noexcept final
    {
    }
    } sDebugMutexes;

    service<neolib::i_mutex_profiler>().enable(std::chrono::microseconds{
    100 },
    10u, true);

    service<neolib::i_mutex_profiler>().subscribe(sDebugMutexes);

    spinlock mutex contention. Humm. Are you using spinlock, mutex or
    adaptive mutex?

    spinlock (non-pure).

    Well, I guess I can call an adaptive mutex a non-pure spinlock in a
    strange sense. :^)

    They spin several times before they hit the slow path, aka, waiting in
    the kernel.
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Mr Flibble@flibble@red-dwarf.jmc.corp to comp.theory on Mon Dec 22 21:55:13 2025
    From Newsgroup: comp.theory

    On Mon, 22 Dec 2025 13:51:11 -0800, Chris M. Thomasson wrote:

    On 12/22/2025 1:49 PM, Mr Flibble wrote:
    On Mon, 22 Dec 2025 13:37:18 -0800, Chris M. Thomasson wrote:

    On 12/21/2025 1:36 PM, Mr Flibble wrote:
    In neolib (C++ support library used by neoGFX) you can now profile
    spinlock mutex contention. #cpp #coding #gamedev

    static struct debug_mutexes :
    neolib::i_mutex_profiler_observer {
    void mutex_contended(neolib::i_lockable& aMutex,
    const
    std::chrono::microseconds& aContendedFor,
    neolib::mutex_lock_info const* aPreviousLocks,
    std::size_t aPreviousLocksCount) noexcept final
    {
    }
    } sDebugMutexes;

    service<neolib::i_mutex_profiler>().enable(std::chrono::microseconds{
    100 },
    10u, true);

    service<neolib::i_mutex_profiler>().subscribe(sDebugMutexes);

    spinlock mutex contention. Humm. Are you using spinlock, mutex or
    adaptive mutex?

    spinlock (non-pure).

    Well, I guess I can call an adaptive mutex a non-pure spinlock in a
    strange sense. :^)

    They spin several times before they hit the slow path, aka, waiting in
    the kernel.

    https://github.com/i42output/neolib/blob/master/include/neolib/core/ mutex.hpp#L152

    /Flibble
    --- Synchronet 3.21a-Linux NewsLink 1.2