[Boost-bugs] [Boost C++ Libraries] #13442: pmr::synchronized_pool_resource is affected by thread priority inversion

Subject: [Boost-bugs] [Boost C++ Libraries] #13442: pmr::synchronized_pool_resource is affected by thread priority inversion
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2018-02-07 09:41:11


#13442: pmr::synchronized_pool_resource is affected by thread priority inversion
------------------------------+---------------------------
 Reporter: enniobarbaro@… | Owner: Ion Gaztañaga
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: container
  Version: Boost 1.63.0 | Severity: Problem
 Keywords: |
------------------------------+---------------------------
 In our setup, we have several high priority threads that occasionally need
 to allocate memory using `synchronized_pool_resource::allocate`. Such
 memory is later released by a lower priority thread using
 `synchronized_pool_resource::deallocate`.

 It might sometimes happen that several `allocate` calls happen
 simultaneously with `deallocate`. Because of the spinlock implementation
 used by dlmalloc, the high priority threads are in a busy loop trying to
 acquire the lock, but the kernel might have no resources left to awake the
 "cleaner" thread that is currently holding the lock.

 Attached is a minimum example that Linux `SCHED_FIFO` scheduler.
 Running the program, on my system I can see:

    1) The program prints 'failed' several times, meaning that some calls
 to `allocate` blocked for more than a second.

    2) The total execution time is approximately 120 times slower than a
 version that does not use any thread priority.

 Inspecting the program with `perf` one can see that most of the time is
 spent inside `boost_cont_sync_lock`, in particular in `sched_yield`.

 A possible solution could be to switch to a pure pthread implementation by
 defining `USE_SPIN_LOCKS=0` before including `dlmalloc_2_8_6.c`

 System: `Linux SPC-LT48 4.9.0-4-amd64 #1 SMP Debian 4.9.65-3 (2017-12-03)
 x86_64 GNU/Linux`

-- 
Ticket URL: <https://svn.boost.org/trac10/ticket/13442>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2018-02-07 09:45:20 UTC