[erlang-questions] binary optimization

Joel Reymont joelr1@REDACTED
Sat Jul 18 13:46:28 CEST 2009


On Jul 18, 2009, at 12:41 PM, Mikael Pettersson wrote:

> In this code, either enumerate the possible values for Where and
> invoke them via an explicit case expression, or specialise  
> handle_info/3
> into a set of handle_info_.../2 functions, one for each possible  
> Where.

What exactly (and how much) would I be buying with this restructuring?

Would I be avoiding duplicating the binary, i.e. extra memory  
allocation?

Is there anything else?

> To elaborate, storing Token in an aggregate and passing that elsewhere
> forces the implementation to convert Token from the delayed sub binary
> representation to a proper Erlang term,

What is a delayed sub-binary representation? Is there a paper on this?

> A possible solution is to change send/3 to send/4
> with Token as an additional parameter, and then hope that send/4 is  
> nice
> enough so that the compiler can keep Token in its delayed sub binary
> representation.


Well, I do want to keep the token around in the state of the gen_server.
I guess converting to send/4 is not gonna buy me anything since I will
need to stuff Token into State in send/4. Am I right?

	Thanks, Joel

---
Mac hacker with a performance bent
http://www.linkedin.com/in/joelreymont



More information about the erlang-questions mailing list