[erlang-questions] binary optimization

Mikael Pettersson mikpe@REDACTED
Sat Jul 18 11:25:55 CEST 2009


Joel Reymont writes:
 > How do I improve this?
 > 
 > src/flashbot.erl:120: Warning: NOT OPTIMIZED: compiler limitation:  
 > instruction {apply_last,2,6} prevents delayed sub binary optimization
 > 
 > 120: handle_info({tcp, _Sock, <<A:32, B:32, C:32, Bin/binary>>},  
 > Where, State) ->
 >      Delta = timer:now_diff(now(), {A, B, C}),
 >      ?MODULE:Where(Bin, State#state{latency = Delta});

Get rid of the apply, i.e. the ?MODULE:Where call. That would be good
for other performance reasons too.

I don't know the exact limitations for the delayed sub binary optimization,
but presumably the callee in the tailcall must be known at compile-time,
and must presumably only be called with a delayed sub binary. It _may_
even be as strict as only allowing self-referential tailcalls.


More information about the erlang-questions mailing list