fprof(3)
π fprof(3) β Erlang Module Definition π
β¨ NAME β¨
fprofβ a time profiling tool that uses trace to file for minimal runtime performance impact. π
πΈ DESCRIPTION πΈ
Okay so this module is literally here to profile a program and find out how the execution time is used. Tracing to file is used to minimize the runtime performance degradation.
The fprof module uses tracing to collect profiling data, so there is no need for special compilation of any module you want to profile. When it starts tracing, fprof will erase all previous tracing in the node and set the necessary trace flags on the profiling target processes, plus local call trace on all functions in all loaded modules and all modules to be loaded. When it stops tracing, fprof disables all tracing in the node. Periodt.
fprof presents both own time β like, how much time a function used for its own execution β and accumulated time, which includes called functions. All presented times are collected using trace timestamps. fprof tries to collect CPU time timestamps if the host machine OS supports it. So the times can be wallclock times, and OS scheduling will randomly strike all called functions in a presumably fair way.
However, if the profiling time is short, and the host machine OS does not support high resolution CPU time measurements, a few OS schedulings can show up as ridiculously long execution times for functions doing practically nothing. For real, it has been observed that a function that was more or less just composing a tuple was running 100 times slower than normal. When tracing was repeated, the execution time was normal. π
Profiling is essentially done in 3 steps:
- Tracing: to a file. The trace data contains entries for function calls, returns to function, process scheduling, other process related events (for example
spawn), and garbage collection. All trace entries are timestamped. π¦ - Profiling: the trace file is read, the execution call stack is simulated, and raw profile data is calculated from the simulated call stack and the trace timestamps. The profile data is stored in the
fprofserver state. During this step the trace data may be dumped in text format to file or console. β¨ - Analysing: the raw profile data is sorted, filtered and dumped in text format either to file or console. The text format intended to be both readable for a human reader, as well as parsable with the standard erlang parsing tools. π
Since fprof sends trace data to a file, the runtime performance degradation is minimized, but still far from negligible β especially for programs that themselves use the filesystem heavily. Where the trace file is placed is also important. For example, on Unix systems /tmp is usually a good choice since it is essentially a RAM disk, while any network-mounted disk is a bad idea. π
fprof can also skip the file step and trace to a tracer process that does the profiling in runtime.
π Analysis format π
This section describes the output format of the analyse/1 function.
The format is parsable with the standard Erlang parsing tools erl_scan and erl_parse, file:consult/1, or io:read/2. The parse format is not described here β it should be easy enough for the interested reader to try it out. Note that some flags to analyse/1 will affect the format.
The following example was run on Erlang/OTP R8 on Solaris 8; all OTP internals in this example are version dependent.
As an example, we will use the following function, which is a slightly modified benchmark function from module file:
-module(foo).
-export([create_file_slow/2]).
create_file_slow(Name, N) when is_integer(N), N >= 0 ->
{ok, FD} =
file:open(Name, [raw, write, delayed_write, binary]),
if N > 256 ->
ok = file:write(FD,
lists:map(fun (X) -> <<X:32/unsigned>> end,
lists:seq(0, 255))),
ok = create_file_slow(FD, 256, N);
true ->
ok = create_file_slow(FD, 0, N)
end,
ok = file:close(FD).
create_file_slow(FD, M, M) ->
ok;
create_file_slow(FD, M, N) ->
ok = file:write(FD, <<M:32/unsigned>>),
create_file_slow(FD, M+1, N).
Let's have a look at the printout after running:
1> fprof:apply(foo, create_file_slow, [junk, 1024]).
2> fprof:profile().
3> fprof:analyse().
The printout starts with:
%% Analysis results:
{ analysis_options,
[{callers, true},
{sort, acc},
{totals, false},
{details, true}]}.
% CNT ACC OWN
[{ totals, 9627, 1691.119, 1659.074}]. %%%
The CNT column shows the total number of function calls that was found in the trace. In the ACC column is the total time of the trace from first timestamp to last. And in the OWN column is the sum of the execution time in functions found in the trace, not including called functions. In this case it is very close to the ACC time since the emulator had practically nothing to do except executing our test program.
All time values in the printout are in milliseconds.
The printout continues:
% CNT ACC OWN
[{ "<0.28.0>", 9627,undefined, 1659.074}]. %%
This is the printout header of one process. The printout contains only this one process since we called fprof:apply/3 that traces only the current process. Therefore the CNT and OWN columns perfectly matches the totals above. The ACC column is undefined since summing the ACC times of all calls in the process makes no sense β one would get something like the ACC value from totals above multiplied by the average depth of the call stack.
All paragraphs up to the next process header only concerns function calls within this process.
Now we come to something more interesting:
{[{undefined, 0, 1691.076, 0.030}],
{ {fprof,apply_start_stop,4}, 0, 1691.076, 0.030}, %
[{{foo,create_file_slow,2}, 1, 1691.046, 0.103},
{suspend, 1, 0.000, 0.000}]}.
{[{{fprof,apply_start_stop,4}, 1, 1691.046, 0.103}],
{ {foo,create_file_slow,2}, 1, 1691.046, 0.103}, %
[{{file,close,1}, 1, 1398.873, 0.019},
{{foo,create_file_slow,3}, 1, 249.678, 0.029},
{{file,open,2}, 1, 20.778, 0.055},
{{lists,map,2}, 1, 16.590, 0.043},
{{lists,seq,2}, 1, 4.708, 0.017},
{{file,write,2}, 1, 0.316, 0.021}]}.
The printout consists of one paragraph per called function. The function marked with % is the one the paragraph concerns β foo:create_file_slow/2. Above the marked function are the calling functions β those that has called the marked, and below are those called by the marked function.
The paragraphs are per default sorted in descending order of the ACC column for the marked function. The calling list and called list within one paragraph are also per default sorted in descending order of their ACC column.
The columns are:
CNTβ the number of times the function has been calledACCβ the time spent in the function including called functionsOWNβ the time spent in the function not including called functions
The rows for the calling functions contain statistics for the marked function with the constraint that only the occasions when a call was made from the row's function to the marked function are accounted for.
The row for the marked function simply contains the sum of all calling rows.
The rows for the called functions contains statistics for the row's function with the constraint that only the occasions when a call was made from the marked to the row's function are accounted for.
So, we see that foo:create_file_slow/2 used very little time for its own execution. It spent most of its time in file:close/1. The function foo:create_file_slow/3 that writes 3/4 of the file contents is the second biggest time thief. π
We also see that the call to file:write/2 that writes 1/4 of the file contents takes very little time in itself. What takes time is to build the data (lists:seq/2 and lists:map/2).
The function undefined that has called fprof:apply_start_stop/4 is an unknown function because that call was not recorded in the trace. It was only recorded that the execution returned from fprof:apply_start_stop/4 to some other function above in the call stack, or that the process exited from there.
Let's continue down the printout to find:
{[{{foo,create_file_slow,2}, 1, 249.678, 0.029},
{{foo,create_file_slow,3}, 768, 0.000, 23.294}],
{ {foo,create_file_slow,3}, 769, 249.678, 23.323}, %
[{{file,write,2}, 768, 220.314, 14.539},
{suspend, 57, 6.041, 0.000},
{{foo,create_file_slow,3}, 768, 0.000, 23.294}]}.
If you compare with the code you will see there also that foo:create_file_slow/3 was called only from foo:create_file_slow/2 and itself, and called only file:write/2, note the number of calls to file:write/2. But here we see that suspend was called a few times. This is a pseudo function that indicates that the process was suspended while executing in foo:create_file_slow/3, and since there is no receive or erlang:yield/0 in the code, it must be Erlang scheduling suspensions, or the trace file driver compensating for large file write operations (these are regarded as a schedule out followed by a schedule in to the same process).
Let's go find that suspend entry, bestie:
{[{{file,write,2}, 53, 6.281, 0.000},
{{foo,create_file_slow,3}, 57, 6.041, 0.000},
{{prim_file,drv_command,4}, 50, 4.582, 0.000},
{{prim_file,drv_get_response,1}, 34, 2.986, 0.000},
{{lists,map,2}, 10, 2.104, 0.000},
{{prim_file,write,2}, 17, 1.852, 0.000},
{{erlang,port_command,2}, 15, 1.713, 0.000},
{{prim_file,drv_command,2}, 22, 1.482, 0.000},
{{prim_file,translate_response,2}, 11, 1.441, 0.000},
{{prim_file,'-drv_command/2-fun-0-',1}, 15, 1.340, 0.000},
{{lists,seq,4}, 3, 0.880, 0.000},
{{foo,'-create_file_slow/2-fun-0-',1}, 5, 0.523, 0.000},
{{erlang,bump_reductions,1}, 4, 0.503, 0.000},
{{prim_file,open_int_setopts,3}, 1, 0.165, 0.000},
{{prim_file,i32,4}, 1, 0.109, 0.000},
{{fprof,apply_start_stop,4}, 1, 0.000, 0.000}],
{ suspend, 299, 32.002, 0.000}, %
[ ]}.
Okay so literally no function has a long suspend time, which means nobody was stuck waiting in a receive statement. π
Actually, prim_file:drv_command/4 does contain a receive, but in this test program the message is already sitting in the process receive buffer when the receive gets entered. Also the total suspend time for the whole test run? Super small. π¦
The suspend pseudo function has an OWN time of zero β that's on purpose, so the process total OWN time doesn't include time spent suspended. Whether suspend time is really ACC or OWN time is, like, a whole philosophical question tbh. π€
Now let's peek at another iconic pseudo function, garbage_collect: β¨
{[{{prim_file,drv_command,4}, 25, 0.873, 0.873},
{{prim_file,write,2}, 16, 0.692, 0.692},
{{lists,map,2}, 2, 0.195, 0.195}],
{ garbage_collect, 43, 1.760, 1.760}, %
[ ]}.
Here, literally no function stands out, which is very normal. π
The garbage_collect pseudo function does not have an OWN time of zero like suspend does β instead it's equal to the ACC time.
Garbage collection often happens while a process is suspended, but fprof hides that fact by pretending the suspended function was first unsuspended and then garbage collected. Otherwise the printout would show garbage_collect being called from suspend, but not which function actually caused the garbage collection. π§
Now let's get back to the test code: π
{[{{foo,create_file_slow,3}, 768, 220.314, 14.539},
{{foo,create_file_slow,2}, 1, 0.316, 0.021}],
{ {file,write,2}, 769, 220.630, 14.560}, %
[{{prim_file,write,2}, 769, 199.789, 22.573},
{suspend, 53, 6.281, 0.000}]}.
Not unexpectedly, we see that file:write/2 was called from foo:create_file_slow/3 and foo:create_file_slow/2. The number of calls in each case and the used time also confirm the previous results. π
We see that file:write/2 only calls prim_file:write/2, but let's not go digging into the internals of the kernel application. π
If we do dig down anyway, we find the call to the linked-in driver that does the file operations towards the host operating system: π₯
{[{{prim_file,drv_command,4}, 772, 1458.356, 1456.643}],
{ {erlang,port_command,2}, 772, 1458.356, 1456.643}, %
[{suspend, 15, 1.713, 0.000}]}.
This is 86 % of the total run time, and like we saw before, the close operation is the absolute biggest contributor. We find a comparison ratio a little bit up in the call stack: π
{[{{prim_file,close,1}, 1, 1398.748, 0.024},
{{prim_file,write,2}, 769, 174.672, 12.810},
{{prim_file,open_int,4}, 1, 19.755, 0.017},
{{prim_file,open_int_setopts,3}, 1, 0.147, 0.016}],
{ {prim_file,drv_command,2}, 772, 1593.322, 12.867}, %
[{{prim_file,drv_command,4}, 772, 1578.973, 27.265},
{suspend, 22, 1.482, 0.000}]}.
The time for file operations in the linked-in driver breaks down as 1 % for open, 11 % for write, and 87 % for close. All that data is probably buffered in the operating system until the close. πΎ
The observant reader might notice that the ACC times for prim_file:drv_command/2 and prim_file:drv_command/4 aren't equal between the paragraphs above, even though it's easy to believe that prim_file:drv_command/2 is just a passthrough function. ποΈ
The missing time shows up in the paragraph for prim_file:drv_command/4, where it's evident that not only prim_file:drv_command/2 is called but also a fun: π
{[{{prim_file,drv_command,2}, 772, 1578.973, 27.265}],
{ {prim_file,drv_command,4}, 772, 1578.973, 27.265}, %
[{{erlang,port_command,2}, 772, 1458.356, 1456.643},
{{prim_file,'-drv_command/2-fun-0-',1}, 772, 87.897, 12.736},
{suspend, 50, 4.582, 0.000},
{garbage_collect, 25, 0.873, 0.873}]}.
And some more missing time can be explained by the fact that prim_file:open_int/4 calls prim_file:drv_command/2 both directly and through prim_file:open_int_setopts/3, which complicates the picture. π
{[{{prim_file,open,2}, 1, 20.309, 0.029},
{{prim_file,open_int,4}, 1, 0.000, 0.057}],
{ {prim_file,open_int,4}, 2, 20.309, 0.086}, %
[{{prim_file,drv_command,2}, 1, 19.755, 0.017},
{{prim_file,open_int_setopts,3}, 1, 0.360, 0.032},
{{prim_file,drv_open,2}, 1, 0.071, 0.030},
{{erlang,list_to_binary,1}, 1, 0.020, 0.020},
{{prim_file,i32,1}, 1, 0.017, 0.017},
{{prim_file,open_int,4}, 1, 0.000, 0.057}]}.
{[{{prim_file,open_int,4}, 1, 0.360, 0.032},
{{prim_file,open_int_setopts,3}, 1, 0.000, 0.016}],
{ {prim_file,open_int_setopts,3}, 2, 0.360, 0.048}, %
[{suspend, 1, 0.165, 0.000},
{{prim_file,drv_command,2}, 1, 0.147, 0.016},
{{prim_file,open_int_setopts,3}, 1, 0.000, 0.016}]}.
β¨ Notes on accuracy of measurements β¨
The actual supervision of execution times is itself a CPU-intensive activity. A message gets written on the trace file for every single function call that the profiled code makes. π
The ACC time calculation is sometimes hard to get right, because it's hard to define. This happens especially when a function occurs in multiple instances in the call stack β like calling itself, maybe through other functions, and maybe even non-tail recursively. π€―
To produce sensible results, fprof tries not to charge any function more than once for ACC time. The instance highest up (with the longest duration) in the call stack gets chosen. π
Sometimes a function can unexpectedly waste a lot (some 10 ms or more, depending on host machine OS) of OWN (and ACC) time, even functions that do practically nothing at all. The problem might be that the OS chose to schedule out the Erlang runtime system process for a while, and if the OS doesn't support high resolution CPU time measurements, fprof will use wallclock time for its calculations, and it will look like functions are randomly burning virtual machine time. π
π See Also π
fprof- The File Trace Profiler,dbg,eprof
π DATA TYPES π
analyse_option() ::
append | callers |
{callers, boolean()} |
{cols, Cols :: non_neg_integer()} |
dest |
{dest, Dest :: pid() | (Destfile :: file:filename())} |
details |
{details, boolean()} |
no_callers | no_details |
{sort, SortSpec :: acc | own} |
totals |
{totals, boolean()}.
apply_option() ::
continue |
{procs, PidList :: [pid()]} |
start |
(TraceStartOption :: trace_option()).
pid_spec() :: pid() | atom().
profile_option() ::
append | dump |
{dump, pid() | (Dump :: (Dumpfile :: file:filename() | []))} |
file |
{file, Filename :: file:filename()} |
start | stop.
trace_option() ::
cpu_time |
{cpu_time, boolean()} |
file |
{file, Filename :: file:filename()} |
{procs, PidSpec :: pid_spec()} |
{procs, [PidSpec :: pid_spec()]} |
start | stop |
{tracer, Tracer :: pid() | port()} |
verbose |
{verbose, boolean()}.
π¦ FUNCTIONS π¦
Here's the signature, bestie: β¨
analyse(OptionName) ->
ok | {error, Reason} | {'EXIT', ServerPid, Reason}
when
OptionName :: atom(),
ServerPid :: pid(),
Reason :: term();
({OptionName, OptionValue}) ->
ok | {error, Reason} | {'EXIT', ServerPid, Reason}
when
OptionName :: atom(),
OptionValue :: term(),
ServerPid :: pid(),
Reason :: term();
(OptionList) ->
ok | {error, Reason} | {'EXIT', ServerPid, Reason}
when
OptionList :: [Option],
Option :: analyse_option(),
ServerPid :: pid(),
Reason :: term().
This one analyses raw profile data in the fprof server. π
If Arg is an atom, this call is equivalent to analyse([Arg]). β¨
If Arg is a tuple {Option, _}, this call is equivalent to analyse([Option]). π
Otherwise Arg must be a list of valid options. π
If called when no raw profile data is available, {error, no_profile} is returned. π«
Destfile is used to call file:open/2. π
Option description:
dest|{dest, Dest}β where the analysis goes, bestie π . leave this off (or literally just saydest) and it lands at the caller's group leader. otherwiseDestis either the pid/0 of an I/O device or a filename. oh and if your filename is[], we quietly use"fprof.analysis"instead. cute, right?appendβ appends the analysis onto the destination file instead of yeeting what's already there. β οΈ only legal together with{dest, Destfile}, no exceptions.{cols, Cols}β sets how many columns wide your analysis text is. don't pass it and it defaults to80. vibes.callers|{callers, true}β prints the callers-and-called info in the analysis. this is the default, so it's already on, periodt.{callers, false}|no_callersβ suppresses that callers/called printing. if you're not about that context life.{sort, SortSpec}β sorts the analysis by theACCcolumn (that's the default) or theOWNcolumn. peek at Analysis Format below for the deets.totals|{totals, true}β throw in an extra section with call stats for all calls, no matter the process. π{totals, false}β suppresses the totals section. this is the default, so no totals unless you ask.details|{details, true}β prints call stats for each individual process. also the default. slay.{details, false}|no_detailsβ suppresses those per-process call stats. bye.
apply π§
apply(Module, Function, Args) -> term()
when
Module :: module(),
Function :: atom(),
Args :: [term()];
(Func, Args, OptionList) -> term()
when
Func ::
fun() | {Module :: module(), Function :: atom()},
Args :: [term()],
OptionList :: [Option],
Option :: apply_option().
Calls the given function wrapped up all snug in trace([start, ...]) and trace(stop). it's giving sandwiched. π₯ͺ
so if the function args (Arg1, Arg2, and Arg3) are Module (an atom), Function (an atom), and Args (a list), then the function gets called via erlang:apply(Module, Function, Args). β¨
and if the args are Func (a fun), Args (a list), and OptionList (a list of options), the fun gets called via erlang:apply(Func, Args).
some effort is made to keep the trace clean from unnecessary trace messages, no cap π§Ό β tracing is started and stopped from a spawned process, while erlang:apply/2 is called in the current process, only surrounded by receive and send statements towards the trace-starting process. that trace-starting process exits when it is not needed any more. it's giving main character who leaves the party when the job's done π
TraceStartOption is any option allowed for trace/1. the options [start, {procs, [self() | PidList]} | OptList] are given to trace/1, where OptList is OptionList with the continue, start and {procs, _} options removed.
the continue option inhibits the call to trace(stop) and leaves it up to the caller to stop tracing at a suitable time. ie. your timing, your rules. β°
profile π©·
profile(OptionName) ->
ok |
{ok, Tracer} |
{error, Reason} |
{'EXIT', ServerPid, Reason}
when
OptionName :: atom(),
Tracer :: pid(),
ServerPid :: pid(),
Reason :: term();
({OptionName, OptionValue}) ->
ok |
{ok, Tracer} |
{error, Reason} |
{'EXIT', ServerPid, Reason}
when
OptionName :: atom(),
OptionValue :: term(),
Tracer :: pid(),
ServerPid :: pid(),
Reason :: term();
(OptionList) ->
ok |
{ok, Tracer} |
{error, Reason} |
{'EXIT', ServerPid, Reason}
when
OptionList :: [Option],
Option :: profile_option(),
Tracer :: pid(),
ServerPid :: pid(),
Reason :: term().
okay so this one compiles a trace into raw profile data, which the fprof server then holds onto. πΎ
- if Arg is an atom, this call is equivalent to
profile([Arg]). - if Arg is a tuple
{OptionName, OptionValue}, this call is equivalent toprofile([Arg]). - otherwise, Arg has got to be a list of options.
Dumpfile is used to call file:open/2, and Filename is used to call dbg:trace_port(file, Filename).
here are the supported options, bestie:
file|{file, Filename}β reads the fileFilenameand creates raw profile data that gets stored in RAM by thefprofserver. if you pass the optionfile, or literally none of these options, the filefprof.traceis read. the call returns once the whole trace has been read, with the return valueokif it went well. π«Ά this option is not allowed with thestartorstopoptions.dump|{dump, Dump}β where the trace text dump goes. if you don't give this option, no dump is generated. if you give it as justdump, the destination is the caller's group leader. otherwise Dump is either the pid of an I/O device or a filename. and if the filename is[],"fprof.dump"is used instead. this option cannot be combined with thestopoption. π«appendβ appends the trace text dump to the destination file. π only allowed with the{dump, Dumpfile}option.startβ starts a tracer process that profiles trace data in runtime. the call returns immediately with the return value{ok, Tracer}if it's successful. this option is not allowed with thestop,file, or{file, Filename}options. πββοΈstopβ stops the tracer process that profiles trace data in runtime. the return value isokif it worked. this option cannot be combined with thestart,file, or{file, Filename}options. π
start π
start() -> {ok, Pid} | {error, {already_started, Pid}}
when Pid :: pid().
Starts the fprof server. π
ngl, you'll seldom have any need to call this directly, because the server is automatically started by any function that needs it. it's already doing its own thing.
stop π
stop(Reason) -> ok when Reason :: term().
Stops the fprof server.
the Reason you supply becomes the exit reason for the server process. by default, any Reason other than kill sends a request to the server and waits for it to clean up, reply, and exit. but if Reason is kill, the server is bluntly killed. no cleanup, no goodbyes, just gone π
if the fprof server is not running, this function returns immediately. nothing to do, bye.
NOTE: when the fprof server is stopped, the collected raw profile data is lost. gone. evaporated. so collect what you need first, bestie. π
trace π¦
trace(verbose) ->
ok | {error, Reason} | {'EXIT', ServerPid, Reason}
when ServerPid :: pid(), Reason :: term();
(OptionName) ->
ok | {error, Reason} | {'EXIT', ServerPid, Reason}
when
OptionName :: atom(),
ServerPid :: pid(),
Reason :: term();
({OptionName, OptionValue}) ->
ok | {error, Reason} | {'EXIT', ServerPid, Reason}
when
OptionName :: atom(),
OptionValue :: term(),
ServerPid :: pid(),
Reason :: term();
(OptionList) ->
ok | {error, Reason} | {'EXIT', ServerPid, Reason}
when
OptionList :: [Option],
Option :: trace_option(),
ServerPid :: pid(),
Reason :: term().
Starts or stops tracing. the moment of truth β¨
- if Arg is the atom
verbose, this call is equivalent totrace([start, verbose]). - if Arg is an atom, this call is equivalent to
trace([Arg]). - if Arg is a tuple
{OptionName, OptionValue}, this call is equivalent totrace([Arg]). - otherwise, Arg has to be a list of trace options.
PidSpec and Tracer are used in calls to erlang:trace(PidSpec, true, [{tracer, Tracer} | Flags]), and Filename is used to call dbg:trace_port(file, Filename).
okay option descriptions, let's go π:
stopβ stops a runningfproftrace and clears all tracing from the node. either optionstoporstartmust be specified, but not both. pick a lane πstartβ clears all tracing from the node and starts a brand newfproftrace. either optionstartorstopmust be specified, but not both.verbose|{verbose, boolean()}β theverboseor{verbose, true}options add some trace flags thatfprofdoes not need, but that can be interesting for general debugging purposes. only allowed with thestartoption. for the nosy queens πcpu_time|{cpu_time, boolean()}β thecpu_timeor{cpu_time, true}options make the timestamps in the trace be in CPU time instead of the default wallclock time. only allowed with thestartoption. β±οΈ
NOTE: getting correct values out of cpu_time can be difficult. the best way to get correct values is to run using a single scheduler and bind that scheduler to a specific CPU. for example:
erl +S 1 +sbt db
{procs, PidSpec}|{procs, [PidSpec]}β specifies which processes should be traced. if this option is not given, the calling process is traced. and all processes spawned by the traced processes are also traced. π± only allowed with thestartoption.file|{file, Filename}β specifies the filename of the trace. if the optionfileis given, or none of these options are given, the filefprof.traceis used. this option is only allowed with thestartoption, but not with the{tracer, Tracer}option. π{tracer, Tracer}β bestie, this one says trace to a process or port instead of tracing to a file. Only allowed with thestartoption, and NOT with the{file, Filename}option β so don't try to do both, that's not the vibe π«π
Now the big one, hold onto your headphones π§
trace(start, Filename) ->
ok | {error, Reason} | {'EXIT', ServerPid, Reason}
when
Filename :: file:filename(),
ServerPid :: pid(),
Reason :: term();
(verbose, Filename) ->
ok | {error, Reason} | {'EXIT', ServerPid, Reason}
when
Filename :: file:filename(),
ServerPid :: pid(),
Reason :: term();
(OptionName, OptionValue) ->
ok | {error, Reason} | {'EXIT', ServerPid, Reason}
when
OptionName :: atom(),
OptionValue :: term(),
ServerPid :: pid(),
Reason :: term().
Okay so what does this actually DO? It starts or stops tracing. That's it, that's the whole job, and it eats π
Here's the tea on how each shape of the call works π
- If
Whatis the atomstart, this call is literally just the same astrace([start, {file, Value}]). Same energy, shorter outfit β¨ - If
Whatis the atomverbose, this call is literally just the same astrace([start, verbose, {file, Value}]). Extra chatty mode unlocked π₯ - If
Whatis a tuple{OptionName, OptionValue}, this call is literally just the same astrace([What]). Boom, one-tuple delegation, iconic π
And that's a wrap, bestie!! π You just read the whole fprof page and honestly? Slay. This little masterpiece comes to you courtesy of Ericsson AB, riding with tools 4.2.2, and it lives happily in section 3 of the manual (that's the library-functions section, iykyk π¦). Go trace something and make it iconic πβ¨πΈ
π¦ where this page comes from
- ubuntu stonking: erlang-doc 1:29.0.6+dfsg-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms