logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

lcnt - A runtime system Lock Profiling tool.

Convenience Functions

       The following functions are used for convenience.

Description

       The  lcnt  module  is  used to profile the internal ethread locks in the Erlang Runtime System. With lcnt
       enabled, internal counters in the runtime system are updated each time a  lock  is  taken.  The  counters
       stores  information  about the number of acquisition tries and the number of collisions that has occurred
       during the acquisition tries. The counters also record the waiting time a lock has caused for  a  blocked
       thread when a collision has occurred.

       The  data  produced by the lock counters will give an estimate on how well the runtime system will behave
       from a parallelizable view point for the scenarios tested. This tool was mainly developed to help  Erlang
       runtime developers iron out potential and generic bottlenecks.

       Locks  in  the emulator are named after what type of resource they protect and where in the emulator they
       are initialized, those are lock 'classes'. Most of those locks are also instantiated several  times,  and
       given  unique  identifiers,  to  increase  locking granularity. Typically an instantiated lock protects a
       disjunct set of the resource, for example ets tables, processes or ports. In other cases  it  protects  a
       specific range of a resource, for example pix_lock which protects index to process mappings, and is given
       a  unique  number  within  the  class.  A  unique  lock  in  lcnt  is referenced by a name (class) and an
       identifier: {Name,Id}.

       Some locks in the system are static and  protects  global  resources,  for  example  bif_timers  and  the
       run_queue  locks.  Other  locks are dynamic and not necessarily long lived, for example process locks and
       ets-table locks. The statistics data from short lived locks can be stored separately when the  locks  are
       deleted.   This   behavior  is  by  default  turned  off  to  save  memory  but  can  be  turned  on  via
       lcnt:rt_opt({copy_save,true}). The lcnt:apply/1,2,3 functions enables this behavior during profiling.

Exports

rt_collect()->[lock_counter_data()]

              Types:

                 lock_counter_data() = term()

              Same as rt_collect(node()).

       rt_collect(Node)->[lock_counter_data()]

              Types:

                 Node = node()
                 lock_counter_data() = term()

              Returns a list of raw lock counter data.

       rt_clear()->ok

              Same as rt_clear(node()).

       rt_clear(Node)->ok

              Types:

                 Node = node()

              Clear the internal counters. Same as lcnt:clear(Node).

       rt_mask()->[category_atom()]

              Types:

                 category_atom() = atom()

              Same as rt_mask(node()).

       rt_mask(Node)->[category_atom()]

              Types:

                 Node = node()
                 category_atom() = atom()

              Refer to rt_mask/2. for a list of valid categories. All categories are enabled by default.

       rt_mask(Categories)->ok|{error,copy_save_enabled}

              Types:

                 Categories = [category_atom()]
                 category_atom() = atom()

              Same as rt_mask(node(),Categories).

       rt_mask(Node,Categories)->ok|{error,copy_save_enabled}

              Types:

                 Node = node()
                 Categories = [category_atom()]
                 category_atom() = atom()

              Sets the lock category mask to the given categories.

              This will fail if the copy_save option is enabled; see lcnt:rt_opt/2.

              Valid categories are:

                * allocator

                * db (ETS tables)

                * debug

                * distribution

                * generic

                * io

                * process

                * scheduler

              This list is subject to change at any time, as is the category any given lock may belong to.

       rt_opt(Option)->boolean()

              Types:

                 Option = {Type, Value :: boolean()}
                 Type = copy_save | process_locks

              Same as rt_opt(node(),{Type,Value}).

       rt_opt(Node,Option)->boolean()

              Types:

                 Node = node()
                 Option = {Type, Value :: boolean()}
                 Type = copy_save | process_locks

              Option description:

                {copy_save,boolean()}:
                  Retains the statistics of destroyed locks.
                  Default: falseWarning:
                This  option  will use a lot of memory when enabled, which must be reclaimed with lcnt:rt_clear.
                Note that it makes no distinction between locks that were destroyed and locks for which counting
                was disabled, so enabling this option will disable changes to the lock category mask.

                {process_locks,boolean()}:
                  Profile process locks, equal to adding process to the lock category mask; see lcnt:rt_mask/2
                  Default: true

Internal Runtime Lock Counter Controllers

       The following functions control the behavior of the internal counters.

Name

       lcnt - A runtime system Lock Profiling tool.

See Also

       LCNT User's Guide

Ericsson AB                                        tools 3.5.2                                        lcnt(3erl)

See Also