Interpreted libriscv vs. Luau (both actual sandboxes)

June 8, 2025 ยท View on GitHub

$ ./bench

  • All benchmark results are measured in 200x1200 samples benchmark overhead median 0ns lowest: 0ns highest: 0ns Self-test running ELF entry at 0x10C20 Calling into event loop...! event_loop: Checking for work event_loop: Going to sleep! add_work: Adding work Resuming event loop...! event_loop: Checking for work work: Doing some work! event_loop: Going to sleep! event_loop: Checking for work event_loop: Going to sleep! add_work: Adding work event_loop: Checking for work work: Doing some work! event_loop: Going to sleep! RISC-V self-test OK

  • Loading program of size 202739 from 0x75827123c100 to virtual 0x10000 -> 0x417f3

  • Program segment readable: 1 writable: 0 executable: 1

  • Loading program of size 2096 from 0x75827126d8f4 to virtual 0x427f4 -> 0x43024

  • Program segment readable: 1 writable: 1 executable: 0

  • Using program-provided exit function at 0x119c8

  • Entry is at 0x10c20 libriscv: mips instr 1600020000, time 1.549093, 1032.875527 mip/s libriscv: call overhead median 2ns lowest: 2ns highest: 3ns libriscv: call args=1 median 2ns lowest: 2ns highest: 3ns libriscv: call args=2 median 2ns lowest: 2ns highest: 4ns libriscv: call args=3 median 2ns lowest: 2ns highest: 8ns libriscv: call args=4 median 2ns lowest: 2ns highest: 2ns libriscv: call args=5 median 2ns lowest: 2ns highest: 5ns libriscv: call args=6 median 2ns lowest: 2ns highest: 3ns libriscv: call args=7 median 2ns lowest: 2ns highest: 6ns libriscv: call args=8 median 3ns lowest: 3ns highest: 3ns libriscv: preempt overhead median 10ns lowest: 10ns highest: 15ns libriscv: resume execution median 3ns lowest: 3ns highest: 5ns luau: call overhead median 87ns lowest: 86ns highest: 116ns luau: call args=1 median 96ns lowest: 95ns highest: 125ns luau: call args=2 median 100ns lowest: 98ns highest: 132ns luau: call args=3 median 102ns lowest: 99ns highest: 133ns luau: call args=4 median 103ns lowest: 101ns highest: 136ns luau: call args=5 median 104ns lowest: 102ns highest: 111ns luau: call args=6 median 106ns lowest: 105ns highest: 199ns luau: call args=7 median 111ns lowest: 109ns highest: 216ns luau: call args=8 median 110ns lowest: 109ns highest: 145ns

      libriscv: syscall args=0	median 3ns  		lowest: 3ns     	highest: 7ns
      libriscv: syscall args=1	median 3ns  		lowest: 3ns     	highest: 94ns
      libriscv: syscall args=2	median 3ns  		lowest: 3ns     	highest: 6ns
      libriscv: syscall args=3	median 3ns  		lowest: 3ns     	highest: 6ns
      libriscv: syscall args=4	median 3ns  		lowest: 3ns     	highest: 5ns
      libriscv: syscall args=5	median 3ns  		lowest: 3ns     	highest: 4ns
      libriscv: syscall args=6	median 4ns  		lowest: 4ns     	highest: 93ns
      libriscv: syscall args=7	median 4ns  		lowest: 3ns     	highest: 5ns
      libriscv: syscall string	median 6ns  		lowest: 6ns     	highest: 10ns
          luau: syscall args=0	median 105ns  		lowest: 103ns     	highest: 111ns
          luau: syscall args=1	median 113ns  		lowest: 111ns     	highest: 117ns
          luau: syscall args=2	median 125ns  		lowest: 123ns     	highest: 216ns
          luau: syscall args=3	median 130ns  		lowest: 128ns     	highest: 219ns
          luau: syscall args=4	median 139ns  		lowest: 136ns     	highest: 201ns
          luau: syscall args=5	median 149ns  		lowest: 147ns     	highest: 174ns
          luau: syscall args=6	median 157ns  		lowest: 155ns     	highest: 190ns
          luau: syscall args=7	median 167ns  		lowest: 164ns     	highest: 191ns
          luau: syscall string	median 114ns  		lowest: 112ns     	highest: 145ns
    

After this point, call overhead is subtracted from every benchmark result for both libriscv and Lua

      libriscv: array append	median 3ns  		lowest: 3ns     	highest: 8ns
     libriscv: vector append	median 7ns  		lowest: 7ns     	highest: 10ns
          luau: table append	median 26ns  		lowest: 25ns     	highest: 57ns

      libriscv: 8x arguments	median 48ns  		lowest: 40ns     	highest: 58ns
    libriscv: 8x stored args	median 35ns  		lowest: 31ns     	highest: 41ns
  libriscv: 8x prepared args	median 42ns  		lowest: 39ns     	highest: 52ns
          luau: 8x arguments	median 224ns  		lowest: 220ns     	highest: 315ns

      libriscv: integer math	median 3ns  		lowest: 3ns     	highest: 7ns
           libriscv: fp math	median 13ns  		lowest: 10ns     	highest: 17ns
          libriscv: exp math	median 13ns  		lowest: 12ns     	highest: 22ns
           libriscv: fib(40)	median 220ns  		lowest: 204ns     	highest: 328ns
        libriscv: taylor(1K)	median 6746ns  		lowest: 5811ns     	highest: 7409ns
          luau: integer math	median 38ns  		lowest: 34ns     	highest: 72ns
               luau: fp math	median 46ns  		lowest: 43ns     	highest: 77ns
              luau: exp math	median 50ns  		lowest: 47ns     	highest: 76ns
               luau: fib(40)	median 489ns  		lowest: 477ns     	highest: 535ns
            luau: taylor(1K)	median 10122ns  		lowest: 8297ns     	highest: 16641ns

   libriscv: complex syscall	median 35ns  		lowest: 34ns     	highest: 42ns
       luau: complex syscall	median 674ns  		lowest: 659ns     	highest: 708ns

     libriscv: micro threads	median 91ns  		lowest: 89ns     	highest: 105ns
            luau: coroutines	median 178ns  		lowest: 173ns     	highest: 205ns

 libriscv: micro thread args	median 137ns  		lowest: 133ns     	highest: 149ns
  libriscv: full thread args	median 146ns  		lowest: 141ns     	highest: 240ns
        luau: coroutine args	median 226ns  		lowest: 220ns     	highest: 338ns
        luau: coroutine args	median 223ns  		lowest: 217ns     	highest: 316ns

      libriscv: naive memcpy	median 888ns  		lowest: 819ns     	highest: 1010ns
    libriscv: syscall memcpy	median 18ns  		lowest: 18ns     	highest: 130ns
                luau: memcpy	median 2170ns  		lowest: 2140ns     	highest: 2293ns
    libriscv: syscall memset	median 11ns  		lowest: 11ns     	highest: 15ns
      libriscv: naive memset	median 176ns  		lowest: 170ns     	highest: 217ns
                luau: memset	median 1673ns  		lowest: 1660ns     	highest: 1758ns

        libriscv: sieve(10M)	median 138ms  		lowest: 138ms     	highest: 138ms
            luau: sieve(10M)	median 574ms  		lowest: 574ms     	highest: 574ms