Sat Dec 28 11:16:09 CET 2019
That was it, thanks. And more importantly thanks for the explanations!
On 27/12/2019 22:54, Dániel Szoboszlay wrote:
> My guess the reason is that the iolist_to_binary(Value0) call compiles
> into a call_ext, while the is_binary(Value0) to a test assembly
> instruction. This means all live X registers have to be saved to the
> heap (and restored later) in the first case. Inlining the is_binary
> check can save you that (and a somewhat expensive external function
> call) when Value0 is already a binary. But how much a difference this is
> depends on how many live X registers you have at that point. Maybe try
> compiling the actual module with erlc -S and compare the generated
> assembly code with and without the if statement?
> On Fri, 27 Dec 2019 at 11:07, Loïc Hoguin <essen@REDACTED
> <mailto:essen@REDACTED>> wrote:
> I seem to be getting a small but noticeable performance improvement
> I change the following:
> Value = iolist_to_binary(Value0)
> Into the following:
> Value = if
> is_binary(Value0) -> Value0;
> true -> iolist_to_binary(Value0)
> At least when the input data is mostly binaries. Anyone else seeing
> The only difference between is_binary and iolist_to_binary seems to be
> that is_binary calls is_binary/binary_bitsize on the same if expression
> while iolist_to_binary has two if statements.
> What gives?
> Loïc Hoguin
More information about the erlang-questions