Priority inversion? #8010

issue kazcw opened this issue on May 5, 2016
  1. kazcw commented at 6:49 PM on May 5, 2016: contributor

    During some lock debugging on a dual-core Linux system I noticed that threads are blocked acquiring cs_vNodes and cs_main for long periods when the system is under moderate load from unrelated processes -- the unlucky lock acquirer is waiting for single-digit seconds once every 10 minutes or so (not coinciding with new blocks) up to around a 30 second wait every few hours. It looks like ThreadMessageHandler is taking locks and then due to being set to THREAD_PRIORITY_BELOW_NORMAL, it's being descheduled (even in trivial lock-holding regions like GetHeight) and holding up for arbitrarily long periods other threads that use these core locks.

    So I'm wondering, what are the benefits of running the message handler at low priority?

  2. laanwj added the label P2P on May 5, 2016
  3. laanwj commented at 8:14 PM on May 5, 2016: member

    I wasn't aware that the message processing thread is run with lower priority. To me that makes little sense, as part of the validation work (or all validation work, in the case of -par=1) is done there.

    I'd be for removing SetThreadPriority functionality completely - it used to be used for the miner threads, but that has been removed, now the only call is for the message thread. And as you say that has doubtful utility...

  4. kazcw referenced this in commit e53e7c5473 on May 5, 2016
  5. laanwj commented at 8:39 PM on May 5, 2016: member

    Looks like this priority change always been there, from the first commit in git at least.

    Cannot find any prior discussion about it, anywhere.

    Good catch.

  6. laanwj closed this on May 6, 2016

  7. kazcw referenced this in commit 7304fb4a93 on May 7, 2016
  8. lateminer referenced this in commit e8222a467f on Oct 18, 2018
  9. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-02 12:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me