[erlang-questions] Are you using {packet, http} ?

Paulo Sérgio Almeida psa@REDACTED
Wed Jul 16 12:34:37 CEST 2008


Sverker Eriksson wrote:
> A message from the OTP team:
> 
> There is an undocumented socket packet mode that provides HTTP parsing. 
> We are planning to make this packet mode official and possibly also 
> change the format of the tuples returned in this mode. One current big 

Nice!

I use {active, once}, but will have no problem changing the code to 
adapt to the new message format.

As you are making it official, here is something you may consider as 
well, if not now, maybe for a future version: supporting the "binary" 
option. As it is now, the binary option is ignored (at least when 
returning the path and headers, which is almost all that matters in the 
most common case, "GET"). This means that several lists of chars will be 
created which (specially in 64 bit architectures) may use several KBytes 
per request, just for the headers. If binaries were returned, memory 
consumption would be better and it would make less pressure on GC (I 
guess). Considering that pattern matching on binaries in nice and 
efficient nowadays, it would be an interesting feature.

A possibility would be the implementation to return sub-binaries 
pointing to the single block in the memory in the common case when the 
request arrives in a single TCP packet. It would be very efficient. The 
programmer would have to be aware of the implications, and not get hold 
of sub-binaries. But I see this as a minor issue. Headers are typically 
either ignored or acted upon to decide something and discarded soon 
afterwards, not stored for the long term (is this true?).

In any case chosing "binary" is optional anyway, we can always choose 
getting lists.

Regards,
Paulo




More information about the erlang-questions mailing list