<div dir="ltr">2013/10/26 Tomas Abrahamsson <span dir="ltr"><<a href="mailto:tomas.abrahamsson@gmail.com" target="_blank">tomas.abrahamsson@gmail.com</a>></span><br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="im"><br>
> Here you go, Maps!<br>
><br>
> I've pushed a Maps branch to Erlang/OTPs repository at GitHub.<br>
<br>
</div>Hi, this is cool!<br>
<br>
I did some performance experiments with gpb, a google<br>
protobuf encoder/decoder, in which I had already implemented<br>
experimental support for maps. It seems map creation is fast!<br>
<br>
representation of msg<br>
records maps<br>
msg to binary: 27.6 MB/s 22.9 MB/s (83% of record speed)<br>
binary to msg: 27.3 MB/s 29.9 MB/s (110% of record speed)<br>
<br>
The figures are number of megabytes processed per second, so<br>
higher number means faster/better. The "binary to msg" involves<br>
creating a record or map, with several fields, once for each<br>
parsed message or sub message. The "msg to binary" uses a match<br>
for several message fields to assign each field to a variable,<br>
once for each message or sub message to encode. Included in<br>
these figures is of course also some binary processing.<br></blockquote><div><br></div><div><br></div><div>Oh, nice speed, even without any optimizations. =) </div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
<br>
I also stumbled upon an what appears to be a compiler error.<br>
Given this program:<br>
<br>
-module(mapbug).<br>
-export([verify_msg/1]).<br>
<br>
verify_msg(Msg) -><br>
v_msg_m1(Msg).<br>
<br>
v_msg_m1(#{f2 := F2}) -><br>
if is_list(F2) -> [v_type_uint32(Elem) || Elem <- F2];<br>
true -> ok<br>
end,<br>
ok;<br>
v_msg_m1(_X) -><br>
ok.<br>
<br>
v_type_uint32(_N) -><br>
ok.<br></blockquote><div><br></div><div>I believe I found the bug. My attention is a bit split right now so I'm not completely sure .. watching Vancouver Canucks beat the Blues, and watching WCS Season 3.</div>
<div><br></div><div>However I think the allocate stack above a fail label which may jump over a deallocate causes this problem. The following will solve the problem:</div><div><br></div><div><div><font face="courier new, monospace">diff --git a/lib/compiler/src/beam_block.erl b/lib/compiler/src/beam_block.erl</font></div>
<div><font face="courier new, monospace">index ed660ad..de455f7 100644</font></div><div><font face="courier new, monospace">--- a/lib/compiler/src/beam_block.erl</font></div><div><font face="courier new, monospace">+++ b/lib/compiler/src/beam_block.erl</font></div>
<div><font face="courier new, monospace">@@ -227,6 +227,7 @@ move_allocates_2(Alloc, [], Acc) -></font></div><div><font face="courier new, monospace"> </font></div><div><font face="courier new, monospace"> alloc_may_pass({set,_,_,{alloc,_,_}}) -> false;</font></div>
<div><font face="courier new, monospace"> alloc_may_pass({set,_,_,{set_tuple_element,_}}) -> false;</font></div><div><font face="courier new, monospace">+alloc_may_pass({set,_,_,{get_map_element,_,_}}) -> false;</font></div>
<div><font face="courier new, monospace"> alloc_may_pass({set,_,_,put_list}) -> false;</font></div><div><font face="courier new, monospace"> alloc_may_pass({set,_,_,put}) -> false;</font></div><div><font face="courier new, monospace"> alloc_may_pass({set,_,_,_}) -> true.</font></div>
</div><div><br></div><div>I will confer with Björn before pushing anything.</div><div><br></div><div>// Björn-Egil</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
compiling it results in:<br>
<br>
1> c("/path/to/mapbug", []).<br>
mapbug: function v_msg_m1/1+17:<br>
Internal consistency check failed - please report this bug.<br>
Instruction: return<br>
Error: {stack_frame,undecided}:<br>
<br>
error<br>
<br>
BRs<br>
<span class=""><font color="#888888">Tomas<br>
</font></span><div class=""><div class="h5">_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</div></div></blockquote></div><br></div></div>