<p dir="auto">The code generated for loading big fields is currently very bad. Here is a small example:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="mutable struct Mut
    data::NTuple{10, Int}
end

struct Immut
    data::NTuple{10, Int}
end

load(x, i::Int) = @inbounds x.data[i]"><pre class="notranslate"><span class="pl-k">mutable struct</span> Mut
    data<span class="pl-k">::</span><span class="pl-c1">NTuple{10, Int}</span>
<span class="pl-k">end</span>

<span class="pl-k">struct</span> Immut
    data<span class="pl-k">::</span><span class="pl-c1">NTuple{10, Int}</span>
<span class="pl-k">end</span>

<span class="pl-en">load</span>(x, i<span class="pl-k">::</span><span class="pl-c1">Int</span>) <span class="pl-k">=</span> <span class="pl-c1">@inbounds</span> x<span class="pl-k">.</span>data[i]</pre></div>
<p dir="auto">Comparing the generated code (on the offial julia-0.7.0 linux x64 binaries):<br>
<code class="notranslate">code_native(load, (Immut, Int))</code></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="mov	rax, qword ptr [rdi + 8*rsi - 8]
ret"><pre class="notranslate"><code class="notranslate">mov	rax, qword ptr [rdi + 8*rsi - 8]
ret
</code></pre></div>
<p dir="auto">with:<br>
<code class="notranslate">code_native(load, (Mut, Int))</code></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="movups	xmm0, xmmword ptr [rdi]
movups	xmm1, xmmword ptr [rdi + 16]
movups	xmm2, xmmword ptr [rdi + 32]
movups	xmm3, xmmword ptr [rdi + 48]
movups	xmm4, xmmword ptr [rdi + 64]
movaps	xmmword ptr [rsp - 88], xmm0
movaps	xmmword ptr [rsp - 72], xmm1
movaps	xmmword ptr [rsp - 56], xmm2
movaps	xmmword ptr [rsp - 40], xmm3
movaps	xmmword ptr [rsp - 24], xmm4
mov	rax, qword ptr [rsp + 8*rsi - 96]
ret"><pre class="notranslate"><code class="notranslate">movups	xmm0, xmmword ptr [rdi]
movups	xmm1, xmmword ptr [rdi + 16]
movups	xmm2, xmmword ptr [rdi + 32]
movups	xmm3, xmmword ptr [rdi + 48]
movups	xmm4, xmmword ptr [rdi + 64]
movaps	xmmword ptr [rsp - 88], xmm0
movaps	xmmword ptr [rsp - 72], xmm1
movaps	xmmword ptr [rsp - 56], xmm2
movaps	xmmword ptr [rsp - 40], xmm3
movaps	xmmword ptr [rsp - 24], xmm4
mov	rax, qword ptr [rsp + 8*rsi - 96]
ret
</code></pre></div>
<p dir="auto">In the mutable case, the tuple is first copied to the stack and then loaded from there.<br>
This currently makes <code class="notranslate">MArray</code> (from <code class="notranslate">StaticArrays</code>) very slow in some cases, e.g. <code class="notranslate">sort!</code> slows down proportional to the size of the MArray. It would be possible to do the loads through a pointer, but this inhibits a lot of optimisations on the Julia side.</p>
<p dir="auto">I looked at the emitted llvm code, and in the difference is apparently, that in the mutable case Julia generates <code class="notranslate">alloca + load + store</code> and in the immutable one just a <code class="notranslate">getelementptr</code>, LLVM is not able to optimize this code.</p>
<p dir="auto">It looks like the logging facilities (e.g. <code class="notranslate">@info</code>, <code class="notranslate">@warn</code>, etc.) have docstrings but are not in the manual. It would be great to have a section of the manual devoted to logging now that we have the framework for it.</p>