Rethink use of thread_local #18678

issue MarcoFalke openend this issue on April 16, 2020
  1. MarcoFalke commented at 9:10 pm on April 16, 2020: member

    Merely compiling Bitcoin Core with thread_local seems to correlate with massively degraded performance for both the RPC and P2P interface on low-end machines. See for example:

    If thread_local really is the source of the performance degradation, it should be disabled by default and only enabled by --enable-debug (for use in lock order debugging).

  2. MarcoFalke added the label Bug on Apr 16, 2020
  3. sipa deleted a comment on Apr 17, 2020
  4. laanwj commented at 9:20 am on April 30, 2020: member

    Yes, it’s onlly used in one place, given how static our thread setup is I think we could easily replace it with a map of thread id to name.

    Though naively I’d expect thread-local to be faster than a mutex-protected map. I’m surprised: do we really look up the thread name that often that this matters?

  5. MarcoFalke commented at 4:01 pm on April 30, 2020: member
    For some reason it seems to cause a slowdown from 6 minutes to 60 minutes. I don’t know where that came from, but if caused by thread_local, this is unacceptable.
  6. laanwj commented at 8:54 am on May 2, 2020: member

    It’s only used in one place. Do we have statistics how often these are called?

    Or does using thread_local at all, say, even in a place that is never called (or only once), add execution overhead throughout the entire program?

    I cannot quite reproduce this locally FWIW. Someone with an affected configuration should do a bit more probing.

  7. laanwj referenced this in commit 78031df4b1 on May 2, 2020
  8. laanwj commented at 10:47 am on May 2, 2020: member
    Can someone suffering from (assumed) thread_local related performance issues please test #18851?
  9. laanwj referenced this in commit c7933899e9 on May 2, 2020
  10. MarcoFalke removed the label Bug on May 2, 2020
  11. MarcoFalke added the label Brainstorming on May 2, 2020
  12. laanwj commented at 2:05 pm on May 4, 2020: member
    Closing as there is no thread_local issue (see #18538 (comment)).
  13. laanwj closed this on May 4, 2020

  14. MarcoFalke locked this on Feb 15, 2022

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: 2024-12-18 15:12 UTC

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