[erlang-questions] Performance bottleneck of Custom Behavior
Raimo Niskanen
raimo+erlang-questions@REDACTED
Mon May 20 11:44:07 CEST 2019
On Wed, May 15, 2019 at 12:13:29PM +0200, Mikael Pettersson wrote:
> On Wed, May 15, 2019 at 11:35 AM Prakash Parmar
> <prakash.parmar@REDACTED> wrote:
> >
> > Hello All,
> >
> > We have a custom behavior based on gen_server with single callback function. After profiling the code we found that invoking a callback function is taking consider amount of time. The argument of callback is record of 50 elements. Did this huge record is a problem ?
>
> If this 50-element record is passed across process boundaries, then
> yes you may see some performance hit. As long as the value is simply
> passed around in a single process it shouldn't cause any issue.
And when you change a field in a record a new copy is created, which for a
50 element record can hurt performance both by the copying time and by the
increased load on the garbage collection.
We usually try to break down such a record into a tree structure of
records, so that an update does not require copying all elements.
--
/ Raimo Niskanen, Erlang/OTP, Ericsson AB
More information about the erlang-questions
mailing list