lcnt 环境搭建 - erlang非业余研究更新时间: 2015-05-04 00:00:00 责任编辑: Author_N16
lcnt - The Lock Profiler
Internally in the Erlang runtime system locks are used to protect resources from being updated from multiple threads in a fatal way. Locks are necessary to ensure that the runtime system works properly but it also introduces a couple of limitations. Lock contention and locking overhead.
With lock contention we mean when one thread locks a resource and another thread, or threads, tries to acquire the same resource at the same time. The lock will deny the other thread access to the resource and the thread will be blocked from continuing its execution. The second thread has to wait until the first thread has completed its access to the resource and unlocked it. The lcnt tool measures these lock conflicts.
Locks has an inherent cost in execution time and memory space. It takes time initialize, destroy, aquiring or releasing locks. To decrease lock contention it some times necessary to use finer grained locking strategies. This will usually also increase the locking overhead and hence there is a tradeoff between lock contention and overhead. In general, lock contention increases with the number of threads running concurrently. The lcnt tool does not measure locking overhead.
5.1 Enabling lock-counting
For investigation of locks in the emulator we use an internal tool called lcnt (short for lock-count). The VM needs to be compiled with this option enabled. To enable this, use:
Another way to enable this alongside a normal VM is to compile it at emulator directory level, much like a debug build. To compile it this way do the following,
make lcnt FLAVOR=smp
and then starting Erlang with,
To verify that you lock-counting enabled check that [lock-counting] appears in the status text when the VM is started.
Erlang R13B03 (erts-5.7.4) [source] [64-bit] [smp:8:8] [rq:8] [async-threads:0] [hipe]
5.2 Getting started
Once you have a lock counting enabled VM the module lcnt can be used. The module is intended to be used from the current running nodes shell. To access remote nodes use lcnt:clear(Node) and lcnt:collect(Node).
All locks are continuously monitored and its statistics updated. Use lcnt:clear/0 to initially clear all counters before running any specific tests. This command will also reset the duration timer internally.
To retrieve lock statistics information use, lcnt:collect/0,1. The collect operation will start a lcnt server if it not already started. All collected data will be built into an erlang term and uploaded to the server and a duration time will also be uploaded. This duration is the time between lcnt:clear/0,1 and lcnt:collect/0,1.
Once the data is collected to the server it can be filtered, sorted and printed in many different ways.
See the reference manual for a description of each function.
- • 关于"无法为更新定位行"的有关问题，多谢
- • jquery惯用技巧及常用方法列表
- • ibatis insert后如何用selecyKey返回联合主键的值
- • DevExpress报表参数有关问题
- • 谈一下Struts的ActionForm之隐性绑定
- • 英特尔下一代笔记本平台英文名定为Centrino2
- • C语言不强调函数前向声明导致的异常
- • QQ会员新增QQ头像每日自动更换功能_QQ会员有福了 免费答题赢黄钻
- • 推荐给大家一款FLASH游戏N game忍者游戏 - shz2008bj
- ibatis insert后如何用selecyKey返回联合主键的值_程序异常
- QQ会员新增QQ头像每日自动更换功能_QQ会员有福了 免费答题赢黄钻_程序异常
- 推荐给大家一款FLASH游戏N game忍者游戏 - shz2008bj _程序异常