PROF(3)                                                   PROF(3)

     NAME
          prof - profiling device

     SYNOPSIS
          bind #P /prof

          /prof/ctl
          /prof/n/name
          /prof/n/path
          /prof/n/histogram
          /prof/n/pctl

     DESCRIPTION
          The prof device serves a two-level directory structure. The
          first level contains a control file ctl and zero or more
          numbered directories each corresponding to a module being
          profiled. Inside each of these numbered directories are fur-
          ther files which describe the particular module being pro-
          filed.

          The write-only control file ctl provides the facilities to
          profile a module. Messages written to this file initiate and
          control the profiling.

          module name
                    Add the module or the module whose path is name to
                    the list of modules to be profiled.

          start     Start profiling all modules in the above list or,
                    if the list is empty, start profiling all modules
                    loaded by the kernel. The profiling is done by
                    sampling.

          startcp   As above but do coverage profiling. All instruc-
                    tions executed in the wanted modules are counted.

          startmp   As above but do memory profiling. All heap memory
                    allocations are associated with a line of limbo
                    source and all deallocations with the line that
                    did the allocation.

          stop      Stop all profiling.

          end       Stop all profiling and free all memory associated
                    with the modules being profiled.  The profiler
                    returns to it's initial state with no modules
                    under profile.

          interval i
                    Change the sampling interval to i ms. The default

     Page 1                       Plan 9             (printed 4/20/24)

     PROF(3)                                                   PROF(3)

                    sampling rate is 100 ms.

          The second level directories contain information about each
          module under profile.

          The read-only file name contains the name of the module in
          the form it appears in it's module source file.

          The read-only file path contains the path of the dis file
          that implements the module.

          The write-only control file pctl allows finer control of the
          profiling of a module. It is not used at present.

          The read-only file histogram contains statistics about the
          profiled module. The file contains a list of pairs of inte-
          gers seperated by a space. The first number of the pair is a
          program counter value representing the address of a dis
          instruction. Addresses start from 0 and the list is in order
          of increasing address. The second number is the frequency
          with which this address was sampled. Each read of this file
          returns the next pair in the list. The frequency is guaran-
          teed to be non-zero.

          When coverage profiling the second number of each pair is
          the number of times that dis instruction was executed, when
          memory profiling it's the amount of memory in bytes.

     SOURCE
          /emu/port/devprof.c

     BUGS
          The device profiles on a global basis and therefore does not
          distinguish between multiple profilers running at once.

          The coverage profiling can only be done on dis instructions.

          The device can do only one of time, coverage or memory pro-
          filing at once.

     Page 2                       Plan 9             (printed 4/20/24)