[erlang-questions] The "ei" API and passing *shared* binaries / parts

Rick van Rein rick@REDACTED
Thu Jun 22 08:48:42 CEST 2017


I have looked at the ei module, both documentation and code.  It looks
quite efficient, but I am missing something, and I wonder if it is
somewhere else.

I started a discussion in the Apache Qpid user forum about integration
their AMQP 1.0 API with Erlang; there does not seem to be a way of
getting to AMQP 1.0 from Erlang, and given that both are designed for
rock-solid software construction that would be a useful marriage.  And
the Go port has a variant API named "electron" that is aimed at
"synchronous" communication under the assumption of many small processes.

Having to pass a (very) large message into Erlang, and possibly out at
the other end, requires cloning the entire binary over ei, AFAIK. 
Although Erlang is rumoured to internally use malloc() for binaries,
with refcounting and parts pointing there (no doubt charging the
refcount) this functionality (shared memory allocation, sharing parts,
unsharing) does not seem to be available externally.  Nor did I find a
way of exchanging shared memory and parts over ei.  Did I miss it?  It
would improve efficiency in applications where Erlang is on the sending
or receiving end of AMQP, as well as an intermediate in the pathway.

There is one more use of such an ei facility -- and that is where an
existing parser in C is asked to decipher a block of text (like SIP,
XML, ...) or binary (AMQP, DNS, OpenPGP, ...) and return parts thereof
as components to work on.  It's a pitty to have to copy in both
directions, rather than using an existing malloc() and simply pointing
into it.

Are such facilities available but have I missed them?


More information about the erlang-questions mailing list