Interpreted libriscv vs. LuaJIT

June 7, 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 0x7cea3c63cd80 to virtual 0x10000 -> 0x417f3

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

  • Loading program of size 2096 from 0x7cea3c66e574 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.159662, 1379.729211 mip/s libriscv: call overhead median 2ns lowest: 2ns highest: 2ns libriscv: call args=1 median 2ns lowest: 2ns highest: 4ns libriscv: call args=2 median 2ns lowest: 2ns highest: 4ns libriscv: call args=3 median 2ns lowest: 2ns highest: 3ns libriscv: call args=4 median 2ns lowest: 2ns highest: 2ns libriscv: call args=5 median 2ns lowest: 2ns highest: 2ns libriscv: call args=6 median 2ns lowest: 2ns highest: 4ns libriscv: call args=7 median 2ns lowest: 2ns highest: 3ns libriscv: call args=8 median 3ns lowest: 3ns highest: 3ns libriscv: preempt overhead median 10ns lowest: 10ns highest: 12ns libriscv: resume execution median 3ns lowest: 3ns highest: 3ns luajit: call overhead median 150ns lowest: 149ns highest: 161ns luajit: call args=1 median 161ns lowest: 159ns highest: 168ns luajit: call args=2 median 164ns lowest: 162ns highest: 174ns luajit: call args=3 median 166ns lowest: 165ns highest: 175ns luajit: call args=4 median 170ns lowest: 165ns highest: 181ns luajit: call args=5 median 173ns lowest: 171ns highest: 180ns luajit: call args=6 median 178ns lowest: 176ns highest: 185ns luajit: call args=7 median 180ns lowest: 178ns highest: 191ns luajit: call args=8 median 184ns lowest: 181ns highest: 191ns

      libriscv: syscall args=0	median 3ns  		lowest: 3ns     	highest: 3ns
      libriscv: syscall args=1	median 3ns  		lowest: 3ns     	highest: 3ns
      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: 11ns
      libriscv: syscall args=6	median 3ns  		lowest: 3ns     	highest: 3ns
      libriscv: syscall args=7	median 3ns  		lowest: 3ns     	highest: 7ns
      libriscv: syscall string	median 6ns  		lowest: 6ns     	highest: 10ns
        luajit: syscall args=0	median 168ns  		lowest: 164ns     	highest: 187ns
        luajit: syscall args=1	median 183ns  		lowest: 180ns     	highest: 192ns
        luajit: syscall args=2	median 195ns  		lowest: 192ns     	highest: 205ns
        luajit: syscall args=3	median 207ns  		lowest: 204ns     	highest: 217ns
        luajit: syscall args=4	median 221ns  		lowest: 218ns     	highest: 234ns
        luajit: syscall args=5	median 234ns  		lowest: 229ns     	highest: 244ns
        luajit: syscall args=6	median 247ns  		lowest: 243ns     	highest: 254ns
        luajit: syscall args=7	median 260ns  		lowest: 256ns     	highest: 271ns
        luajit: syscall string	median 180ns  		lowest: 177ns     	highest: 188ns
    

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

      libriscv: array append	median 3ns  		lowest: 3ns     	highest: 5ns
     libriscv: vector append	median 7ns  		lowest: 7ns     	highest: 11ns
        luajit: table append	median 22ns  		lowest: 18ns     	highest: 31ns

      libriscv: 8x arguments	median 28ns  		lowest: 27ns     	highest: 48ns
    libriscv: 8x stored args	median 33ns  		lowest: 30ns     	highest: 37ns
  libriscv: 8x prepared args	median 37ns  		lowest: 34ns     	highest: 43ns
        luajit: 8x arguments	median 374ns  		lowest: 366ns     	highest: 406ns

      libriscv: integer math	median 3ns  		lowest: 3ns     	highest: 6ns
           libriscv: fp math	median 8ns  		lowest: 8ns     	highest: 12ns
          libriscv: exp math	median 13ns  		lowest: 13ns     	highest: 25ns
           libriscv: fib(40)	median 156ns  		lowest: 148ns     	highest: 194ns
        libriscv: taylor(1K)	median 5889ns  		lowest: 5051ns     	highest: 6106ns
        luajit: integer math	median 49ns  		lowest: 46ns     	highest: 60ns
             luajit: fp math	median 59ns  		lowest: 56ns     	highest: 69ns
            luajit: exp math	median 67ns  		lowest: 64ns     	highest: 73ns
             luajit: fib(40)	median 60ns  		lowest: 57ns     	highest: 68ns
          luajit: taylor(1K)	median 858ns  		lowest: 844ns     	highest: 926ns

   libriscv: complex syscall	median 40ns  		lowest: 36ns     	highest: 46ns
     luajit: complex syscall	median 838ns  		lowest: 812ns     	highest: 853ns

     libriscv: micro threads	median 86ns  		lowest: 84ns     	highest: 93ns
          luajit: coroutines	median 167ns  		lowest: 159ns     	highest: 185ns

 libriscv: micro thread args	median 132ns  		lowest: 128ns     	highest: 139ns
  libriscv: full thread args	median 141ns  		lowest: 135ns     	highest: 149ns
      luajit: coroutine args	median 214ns  		lowest: 206ns     	highest: 225ns
      luajit: coroutine args	median 256ns  		lowest: 248ns     	highest: 271ns

      libriscv: naive memcpy	median 1052ns  		lowest: 944ns     	highest: 1186ns
    libriscv: syscall memcpy	median 19ns  		lowest: 18ns     	highest: 25ns
              luajit: memcpy	median 96ns  		lowest: 91ns     	highest: 109ns
    libriscv: syscall memset	median 11ns  		lowest: 11ns     	highest: 21ns
      libriscv: naive memset	median 169ns  		lowest: 163ns     	highest: 208ns
              luajit: memset	median 69ns  		lowest: 66ns     	highest: 80ns

        libriscv: sieve(10M)	median 133ms  		lowest: 133ms     	highest: 133ms
          luajit: sieve(10M)	median 131ms  		lowest: 131ms     	highest: 131ms