<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<div name="messageBodySection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;">I also believe the current format for maps, which is key1, value1, key2, value2, ... is not that great for compression. Often, you'd have maps with exact the same keys (especially in Elixir with structs), and there, a pattern of key1, key2, ..., value1, value2, ..., should be much better (since the entire keys structure could be compressed between similar maps).</div>
<div name="messageSignatureSection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;"><br />
MichaĆ.</div>
<div name="messageReplySection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;">On 28 Jun 2018, 07:36 +0200, Aaron Seigo <aseigo@mykolab.com>, wrote:<br />
<blockquote type="cite" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #1abc9c;">On 2018-06-28 07:03, Dmitry Belyaev wrote:<br />
<blockquote type="cite" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #e67e22;">So it's not so bad as it's stated in the file, only 33 time worse than<br />
the advertised<br />
format.<br /></blockquote>
<br />
My bad; this came from a run of performance tests where the size of them<br />
map is increased incrementally. It is missing a zero in one of the<br />
lines; will fix.<br />
<br />
<blockquote type="cite" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #e67e22;">However after applying [compressed: 9] suggested by Fred Hebert, I see:<br />
<br />
iex(6)> :erlang.term_to_binary(tuple_map, compressed: 9) |> byte_size()<br />
|> (fn x -> x / 1024 / 1024 end).()<br />
0.38570117950439453<br /></blockquote>
<br />
There are three problems with this:<br />
<br />
a) that data does get decompressed at some point. It doesn't magically<br />
go away. It does, however, help with network usage.<br />
<br />
b) we trade time (to compress) for space (fewer byte to transmit), when<br />
that space isn't needed in the first place. The time required to<br />
compress, esp relative to the serialization time, is decidedly<br />
non-trivial. It takes several times as long to compress with zlib than<br />
it does to serialize. This could be improved by moving a more modern<br />
compression algorithm, though the cost is always non-zero of course. In<br />
our tests, it definitely paid to compress the actual data in the map,<br />
but there was very little need to compress the structural metadata when<br />
encoded efficiently.<br />
<br />
c) we don't always control the call to term_to_binary, or the equivalent<br />
eternal term generators, and so don't have access to compression e.g. on<br />
distribution messages<br />
<br />
I suppose we could propose using compression on (larger) distribution<br />
messages, which would help with the network saturation, and would be a<br />
better stop-gap than nothing, but it still leaves us with (a) and (b)<br />
above (and , and (c) everywhere else.<br />
<br />
--<br />
Aaron<br />
_______________________________________________<br />
erlang-questions mailing list<br />
erlang-questions@erlang.org<br />
http://erlang.org/mailman/listinfo/erlang-questions<br /></blockquote>
</div>
</body>
</html>