I am trying to wrap my head around this one: Functions like similar and copy seem to make 2 allocations if the array is sufficiently large. Can you help me understand why?
I get the same number of allocations for copy, which I guess makes sense, because it is probably implemented in terms of similar.
Am I simply doing something wrong with the @btime macro?
If this is real, how could I copy an array with just one allocation?
Or is that not a good idea for reasons I am not aware of?
Just a guess: some implementation detail that changes the undelying low level algoritm (or the array implementation itself) depending on object size ??
Yeah, it’s well-known, and it’s ‘always’ been this way. I can’t exactly explain what happens, but you can find the exact size where it occurs by trial and error (I think it’s some length 2^n edit: Oops, n=11 as you already found).
I wouldn’t worry about it, unless you are simply curious.
This is curious, I see identical output of @code_llvm and @code_native (modulo some auto-generated function names as far as I can tell), is there a chance that this is a benchmarking artefact?
Thanks @everyone you for your input! For me it was mostly about knowing that I’m not doing something obviously stupid.
The C code really helped for digging deeper. After searching a little bit, I eventually found the corresponding documentation page, which explains this in quite some detail.