<p dir="auto">Output of a session of mine:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="fn factorial(x: int) -&gt; int {
    if x &lt;= 0 { 1 } else { x * factorial(x - 1) }
}

fn main() {
    let x = 4;
    println!(&quot;{}&quot;, factorial(x));
}"><pre class="notranslate"><span class="pl-k">fn</span> <span class="pl-en">factorial</span><span class="pl-kos">(</span><span class="pl-s1">x</span><span class="pl-kos">:</span> <span class="pl-smi">int</span><span class="pl-kos">)</span> -&gt; <span class="pl-smi">int</span> <span class="pl-kos">{</span>
    <span class="pl-k">if</span> x &lt;= <span class="pl-c1">0</span> <span class="pl-kos">{</span> <span class="pl-c1">1</span> <span class="pl-kos">}</span> <span class="pl-k">else</span> <span class="pl-kos">{</span> x <span class="pl-c1">*</span> <span class="pl-en">factorial</span><span class="pl-kos">(</span>x - <span class="pl-c1">1</span><span class="pl-kos">)</span> <span class="pl-kos">}</span>
<span class="pl-kos">}</span>

<span class="pl-k">fn</span> <span class="pl-en">main</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">let</span> x = <span class="pl-c1">4</span><span class="pl-kos">;</span>
    <span class="pl-en">println</span><span class="pl-en">!</span><span class="pl-kos">(</span><span class="pl-s">"{}"</span>, factorial<span class="pl-kos">(</span>x<span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ rustc -g inspect.rs  
$ lldb ./inspect        
Current executable set to './inspect' (x86_64).
(lldb) b main
Breakpoint 1: 2 locations.
(lldb) r
Process 45203 launched: './inspect' (x86_64)
Process 45203 stopped
* thread #1: tid = 0x370ce1, 0x0000000100001780 inspect`main, queue = 'com.apple.main-thread', stop reason = breakpoint 1.2
    frame #0: 0x0000000100001780 inspect`main
inspect`main:
-&gt; 0x100001780:  cmpq   %gs:0x330, %rsp
   0x100001789:  ja     0x1000017a5               ; main + 37
   0x10000178b:  movabsq $0x18, %r10
   0x100001795:  movabsq $0x0, %r11
(lldb) c
Process 45203 resuming
Process 45203 stopped
* thread #2: tid = 0x370cf7, 0x00000001000016b4 inspect`inspect::main + 52 at inspect.rs:6, stop reason = breakpoint 1.1
    frame #0: 0x00000001000016b4 inspect`inspect::main + 52 at inspect.rs:6
   3    }
   4   
   5    fn main() {
-&gt; 6        let x = 4;
   7        println!(&quot;{}&quot;, factorial(x));
   8    }
(lldb) print factorial(5)
Error [IRForTarget]: Size of result type 'long (long)' couldn't be determined
error: warning: function 'factorial' has internal linkage but is not defined
note: used here
error: The expression could not be prepared to run in the target
(lldb) "><pre class="notranslate"><code class="notranslate">$ rustc -g inspect.rs  
$ lldb ./inspect        
Current executable set to './inspect' (x86_64).
(lldb) b main
Breakpoint 1: 2 locations.
(lldb) r
Process 45203 launched: './inspect' (x86_64)
Process 45203 stopped
* thread #1: tid = 0x370ce1, 0x0000000100001780 inspect`main, queue = 'com.apple.main-thread', stop reason = breakpoint 1.2
    frame #0: 0x0000000100001780 inspect`main
inspect`main:
-&gt; 0x100001780:  cmpq   %gs:0x330, %rsp
   0x100001789:  ja     0x1000017a5               ; main + 37
   0x10000178b:  movabsq $0x18, %r10
   0x100001795:  movabsq $0x0, %r11
(lldb) c
Process 45203 resuming
Process 45203 stopped
* thread #2: tid = 0x370cf7, 0x00000001000016b4 inspect`inspect::main + 52 at inspect.rs:6, stop reason = breakpoint 1.1
    frame #0: 0x00000001000016b4 inspect`inspect::main + 52 at inspect.rs:6
   3    }
   4   
   5    fn main() {
-&gt; 6        let x = 4;
   7        println!("{}", factorial(x));
   8    }
(lldb) print factorial(5)
Error [IRForTarget]: Size of result type 'long (long)' couldn't be determined
error: warning: function 'factorial' has internal linkage but is not defined
note: used here
error: The expression could not be prepared to run in the target
(lldb) 
</code></pre></div>
<p dir="auto">cc <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/michaelwoerister/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/michaelwoerister">@michaelwoerister</a></p>
<p dir="auto">The way the runtime is currently structured every time "something happens" a callback is registered with a libuv event loop that wakes up that loop to deal with it. This could be "work available to steal" or "message sent to scheduler" for example. The problem with these is that we create massive numbers of the things when we really only need one per scheduler. If the scheduler needs to have a callback registered, register the singleton callback for that scheduler. Doing this would eliminate huge amounts of allocation and many many calls out to libuv functions.</p>