[erlang-questions] The inner workings of erlang:element/2

Björn Gustavsson bjorn@REDACTED
Thu Sep 10 13:02:02 CEST 2015

On Thu, Sep 10, 2015 at 11:01 AM, Adam Krupicka <akrupicka@REDACTED> wrote:
> Hello,
> I was recently profiling some code and noticed that erlang:element/2
> doesn't show up in neither eprof nor fprof. How is this possible? Is the
> compiler being smart here and rewriting
> X = erlang:element(3, A)
> with
> {_, _, X} = A?

No. element/2 is implemented using a special instruction (or
actually one of several different instructions depending on
the context of the call).

In general, any BIF that may be called in a guard are
implemented using instructions that don't support
tracing (i.e. don't show up in eprof/fprof).


Björn Gustavsson, Erlang/OTP, Ericsson AB

More information about the erlang-questions mailing list