How to profile pthread mutex in linux?

前端 未结 5 1437
名媛妹妹
名媛妹妹 2021-02-01 19:20

I would like to know how to profile a pthread mutex to see if there are any locking contention points in my code. (who likes contentious code, right? :) I know how to do a more

5条回答
  •  清酒与你
    2021-02-01 20:07

    You didn't mention your OS. If it's linux, I've used LTT quite a bit for this sort of profiling. It can be useful in two modes:

    1. performance profiling -- e.g. profile your system for N seconds of standard use and then analyze the data

    2. exception profiling -- e.g. run it around the clock in "flight recorder" mode (record the last N seconds of activity) and on some exceptional condition trigger a stop to the flight recorder. Come in the next morning and analyze the data.

    I've been using and seeing 'mutexes' as the plural of mutex for years now without complaint. ;>

提交回复
热议问题