How to use High-Performance Erlang compiler with RabbitMQ

Use High-Performance Erlang (HiPE) compiler with RabbitMQ open source message broker.

What you need to know

High-Performance Erlang (HiPE) was an ASTEC (Advanced Software TEChnology) project at the Department of Information Technology of Uppsala University during 1998–2005.

Currently HiPE compilation is not supported since the release of the release of Erlang 22 (see OTP-15596 [2019-05-14]).

  OTP-15596    Application(s): erts, hipe, otp

               *** HIGHLIGHT ***

               In OTP 22, HiPE (the native code compiler) is not fully
               functional. The reasons for this are:

               There are new BEAM instructions for binary matching
               that the HiPE native code compiler does not support.

               The new optimizations in the Erlang compiler create new
               combination of instructions that HiPE currently does
               not handle correctly.

               If erlc is invoked with the +native option, and if any
               of the new binary matching instructions are used, the
               compiler will issue a warning and produce a BEAM file
               without native code.

Support for HiPE is dropped in recent releases, but there is an LLVM based just-in-time compiler for Erlang on the horizon.

RabbitMQ HiPE configuration

Use Erlang to display RabbitMQ version.

$ sudo rabbitmqctl eval "rabbit_misc:version()."
"3.6.16"

Use Erlang to display OTP release number.

$ sudo rabbitmqctl eval "rabbit_misc:otp_release()."
"19.2.1"

Use Erlang to display HiPE configuration option.

$ sudo rabbitmqctl eval "application:get_env(rabbit, hipe_enabled)."
{ok,false}

Set HiPE configuration option to true.

$ cat /etc/rabbitmq/rabbitmq.config 
[
  {rabbit, [{hipe_compile, true}]}
].

Restart RabbitMQ message broker.

$ sudo systemctl restart rabbitmq-server

Use Erlang to display hipe_enabled option.

$ sudo rabbitmqctl eval "application:get_env(rabbit, hipe_enabled)."
{ok,true}

Simple benchmarks

The following results were obtained in a controlled environment, but are not representative in any way.

HiPE disabled HiPE enabled Percentage difference (rounded)
Sending rate msg/s Receiving rate msg/s Sending rate msg/s Receiving rate msg/s Send Receive
One publisher/One consumer 28528 28528 43518 43518 +52% +52%
One publisher/Two consumers 17996 35993 26277 52552 +45% +46%
One publisher/Four consumers 11771 47048 16340 65361 +38% +39%
One publisher/Eight consumers 6656 51406 8625 68673 +29% +33%
One publisher/Sixteen consumers 3782 55109 4746 72729 +25% +31%

These benchmarks were created using RabbitMQ PerfTest.