`
mryufeng
  • 浏览: 981813 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

lcnt 环境搭建

阅读更多
抄书:otp_doc_html_R13B04/lib/tools-2.6.5.1/doc/html/lcnt_chapter.html#id2252207

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:

cd $ERL_TOP
./configure --enable-lock-counter


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,

cd $ERL_TOP/erts/emulator
make lcnt FLAVOR=smp



and then starting Erlang with,

$ERL_TOP/bin/cerl -lcnt


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]
[kernel-poll:false] [lock-counting]


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.
分享到:
评论
1 楼 mryufeng 2010-03-05  
首次演示了
make Target FLAVOR=xxx 的使用
已经cerl 如何配合...

相关推荐

    正负脉冲发生器

    此信号发生器是由两个完全相同的可自加载计数器LCNT8组成的,它的输出信号的高低电平脉宽可分别由两组8位预置数进行控制。保证信号频率为1kHz,通过调整计数器可改变占空比。

    [宫水三叶的刷题日记]:状态机 DP1

    在递归函数`dfs(u, acnt, lcnt, cur, ans)`中,我们需要处理所有可能的决策,即在剩下的天数里,学生可以缺勤、迟到或按时到达。每次选择一种情况后,递归地更新状态并更新答案。在计算过程中,如果发现某个状态已经...

    正负脉宽数控调制信号发生器的VHDL程序设计.docx

    正负脉宽数控调制信号发生器的核心是由两个完全相同的可自加载加法计数器(LCNT8)组成。每个加法计数器都能够根据输入的预置数进行计数操作,并在达到预置数值后产生一个溢出信号。通过控制这两个加法计数器的预置...

    计算程序运行时间.pdf计算程序运行时间.pdf计算程序运行时间.pdf

    2. **并发环境**:在多线程或多进程环境中,直接使用这些方法可能会导致测量结果受到其他任务的影响。 3. **性能开销**:频繁地调用时间测量函数也会带来额外的性能开销,需要权衡利弊。 综上所述,根据具体的应用...

    EDA课程设——计正负脉宽可调信号发生器

    正负脉宽可调信号发生器是由两个完全相同的可自加载计数器LCNT8组成的,其输出信号的高低电平脉宽可分别由两组8位预置数进行控制。如果将初始值可预置的加法计数器的溢出信号作为本计数器的初始预置值加载信号LD,则...

Global site tag (gtag.js) - Google Analytics