erlbench and GEP[D] (Generic Erlang Port [Driver]) version 0.7 Released

Michael Truog <>
Sun Jan 23 08:56:16 CET 2011


An Erlang data structures comparison now exists for data indexed by
integers and data indexed by strings (lists of integers) here:
https://github.com/okeuday/erlbench
My latest results (non-HiPE/HiPE) are here:
http://okeuday.livejournal.com/16941.html

A new version (0.7) of GEP[D] (Generic Erlang Port [Driver]) is
available at:
https://github.com/okeuday/generic-erlang-port--driver-

GEP[D] uses C preprocessor macro expansion to automatically create
either an Erlang port or an Erlang port driver which generates the same
output.  A few differences exist, because there is the choice to use the
asynchronous thread pool for the port driver functions which return as
{Port, {async, Data}} instead of {Port, {data, Data}}.  The generated
port code now captures stdout and stderr which is sent as messages to
the Erlang process.  An example of the code configuration necessary to
generate bindings is below:

// specify all the functions to generate bindings for
// 
__________________________________________________________________________
//  || FUNCTION     || ARITY/TYPES             || RETURN TYPE || ASYNC
CALL ||
#define PORT_DRIVER_FUNCTIONS \
    ((sleep_test1,     1, (uint32_t),            
void,                   0)) \
    ((sleep_test2,     1, (uint32_t),            
void,                   1)) \
    ((integer_test1,   0, (),                    
uint64_t,               0)) \
    ((char_test1,      1, (char),                
char,                   0)) \
    ((char_test2,      1, (uchar),               
uchar,                  0)) \
    ((float_test1,     0, (),                    
float,                  0)) \
    ((pchar_test1,     1, (pchar_len),           
pchar,                  0)) \
    ((time_test1,      1, (time_t),              
pchar,                  0)) \
    ((float_test2,     1, (double),              
float,                  0)) \
    ((integer_test2,   4, (int8_t,int16_t,int32_t,int64_t),    
int32_t,  0)) \
    ((integer_test3,   4, (uint8_t,uint16_t,uint32_t,uint64_t),
uint32_t, 0)) \
    ((pchar_test2,     6, (pchar_len, char, pchar_len, char, \
                           pchar_len, char),                   
pchar,    0))
// specify the name of the driver, as provided to driver initialization
// (e.g., erl_ddll:load_driver/2, erlang:open_port/2, ErlDrvEntry, etc.)
#define PORT_DRIVER_NAME_PREFIX test_functions_port_driver
// specify the C include file with the functions that will be called
// from within the Erlang code
#define PORT_DRIVER_C_FUNCTIONS_HEADER_FILE "test_functions.h"

I know NIFs are nifty, but I still like being able to switch between
ports and port drivers without any code changes (PORT_DRIVER_FUNCTIONS
can be used to generate a port also).  NIFs are unable to use the Erlang
asynchronous thread pool, though usage of the asynchronous thread pool
can be a bad choice if you don't read about the problems already
mentioned on the mailing list (mainly, driver gets locked and no shared
job queue).  The generated port driver code uses port-level locking, so
you should be able to more fully utilize all the VM scheduler threads
with more than one instance of the same port driver (if your code is
thread-safe).


More information about the erlang-questions mailing list