process runtime, time and simulation in erlang

Erik Garrison <>
Fri Apr 14 20:53:19 CEST 2006

Is there a way to obtain the total runtime of a process in Erlang?  I'd
like to use the information to create a metronome process which scales
"time" in a simulated environment relative to system load.  Scaled time
will be used to throttle the rate at which requests to a simulated system
occur relative to wallclock time.

I can find the number of reductions completed by a process using
process_info(Pid, reductions).  Is there also a way to find out how much
runtime a given process has?  Is such a question meaningless when
processes are scheduled based upon the number of reductions they make?


For some background...

I'm building a simulated environment using Erlang to test the efficacy of
different distributed object caching and placement protocols.

Generally, things have been wonderful.  I *really* like Erlang and the
manner in simplifies problems of distributed systems.  The problem is that
I'm not just working with a distributed system; I'm simulating one.

Time is an important part of simulation, but when one system is emulating
a dozen, or a hundred others, wallclock time loses meaning relative to the
rate at which these processes operate.  For instance, when a system runs
one process continuously, it registers N reductions/millisecond, when it
runs ten of the same process concurrently, they each run N/10 red/ms.  If
each new process is understood to be running on a distinct node, then
in a real environment, each would run at the same rate relative to a
wallclock as the first process did when it had full access to the
resources of a single system.

If I can solve this problem, then I can make it much easier to simulate an
entire, concurrent, network environment on a single Erlang node.  I can
also rate-limit nodes, or build some conception of process "niceness"
within Erlang.  I fear that anything more than a simple hack to fix this
will require a patch to Erlang/OTP itself.

More information about the erlang-questions mailing list