Erlang receive / after performance strangeness

Evans, Matthew mevans@REDACTED
Thu Jul 2 21:12:03 CEST 2009


Hi,

This is interesting, not sure if it is expected or not.

Two functions below.

One WITH the timer on the receive loop:

get_asset_data(ProcessId, Offset, Misc) ->
    ProcessId ! {get_asset_data, self(), Offset, Misc},
    receive
        Data -> Data
    after 2000 ->
        {error, []}
    end.


One WITHOUT the timer on the receive loop:

get_asset_data(ProcessId, Offset, Misc) ->
    ProcessId ! {get_asset_data, self(), Offset, Misc},
    receive
        Data -> Data
    end.

When running on a VM the one WITH the timer gets about 9500 messages per second. The one WITHOUT gets 15000 messages per second.

That's quite a performance drop (this is on a VM, running version 12B).

Is that expected?

Thanks

Matt


More information about the erlang-questions mailing list