Benchmark between libriscv and LuaJIT

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 0x78e52a0513c0 to virtual 0x10000 -> 0x417f3

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

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

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

  • Using program-provided exit function at 0x119c8 libriscv: Found embedded translation for hash 9077D2DD, 29/5663 mappings

  • Entry is at 0x10c20 libriscv: mips instr 1600020000, time 1.224121, 1307.076475 mip/s libriscv: call overhead median 2ns lowest: 2ns highest: 3ns libriscv: call args=1 median 6ns lowest: 6ns highest: 11ns libriscv: call args=2 median 6ns lowest: 6ns highest: 9ns libriscv: call args=3 median 6ns lowest: 6ns highest: 11ns libriscv: call args=4 median 6ns lowest: 6ns highest: 8ns libriscv: call args=5 median 6ns lowest: 6ns highest: 6ns libriscv: call args=6 median 6ns lowest: 6ns highest: 9ns libriscv: call args=7 median 6ns lowest: 6ns highest: 9ns libriscv: call args=8 median 6ns lowest: 6ns highest: 6ns libriscv: preempt overhead median 10ns lowest: 10ns highest: 14ns libriscv: resume execution median 4ns lowest: 4ns highest: 7ns luajit: call overhead median 152ns lowest: 149ns highest: 161ns luajit: call args=1 median 161ns lowest: 159ns highest: 172ns luajit: call args=2 median 165ns lowest: 163ns highest: 173ns luajit: call args=3 median 168ns lowest: 166ns highest: 176ns luajit: call args=4 median 173ns lowest: 170ns highest: 185ns luajit: call args=5 median 175ns lowest: 172ns highest: 185ns luajit: call args=6 median 177ns lowest: 175ns highest: 187ns luajit: call args=7 median 181ns lowest: 179ns highest: 191ns luajit: call args=8 median 184ns lowest: 182ns highest: 192ns

      libriscv: syscall args=0	median 3ns  		lowest: 3ns     	highest: 4ns
      libriscv: syscall args=1	median 5ns  		lowest: 5ns     	highest: 9ns
      libriscv: syscall args=2	median 5ns  		lowest: 5ns     	highest: 7ns
      libriscv: syscall args=3	median 5ns  		lowest: 5ns     	highest: 8ns
      libriscv: syscall args=4	median 5ns  		lowest: 5ns     	highest: 7ns
      libriscv: syscall args=5	median 5ns  		lowest: 5ns     	highest: 7ns
      libriscv: syscall args=6	median 5ns  		lowest: 5ns     	highest: 9ns
      libriscv: syscall args=7	median 5ns  		lowest: 5ns     	highest: 8ns
      libriscv: syscall string	median 7ns  		lowest: 6ns     	highest: 10ns
        luajit: syscall args=0	median 168ns  		lowest: 165ns     	highest: 177ns
        luajit: syscall args=1	median 182ns  		lowest: 179ns     	highest: 196ns
        luajit: syscall args=2	median 195ns  		lowest: 192ns     	highest: 204ns
        luajit: syscall args=3	median 208ns  		lowest: 204ns     	highest: 218ns
        luajit: syscall args=4	median 223ns  		lowest: 219ns     	highest: 233ns
        luajit: syscall args=5	median 235ns  		lowest: 231ns     	highest: 248ns
        luajit: syscall args=6	median 249ns  		lowest: 245ns     	highest: 259ns
        luajit: syscall args=7	median 262ns  		lowest: 257ns     	highest: 270ns
        luajit: syscall string	median 179ns  		lowest: 176ns     	highest: 188ns
    

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

      libriscv: array append	median 4ns  		lowest: 4ns     	highest: 6ns
     libriscv: vector append	median 5ns  		lowest: 5ns     	highest: 7ns
        luajit: table append	median 19ns  		lowest: 15ns     	highest: 27ns

      libriscv: 8x arguments	median 20ns  		lowest: 20ns     	highest: 29ns
    libriscv: 8x stored args	median 16ns  		lowest: 16ns     	highest: 20ns
  libriscv: 8x prepared args	median 20ns  		lowest: 19ns     	highest: 25ns
        luajit: 8x arguments	median 369ns  		lowest: 361ns     	highest: 379ns

      libriscv: integer math	median 5ns  		lowest: 4ns     	highest: 8ns
           libriscv: fp math	median 7ns  		lowest: 7ns     	highest: 11ns
          libriscv: exp math	median 9ns  		lowest: 9ns     	highest: 13ns
           libriscv: fib(40)	median 3ns  		lowest: 3ns     	highest: 6ns
        libriscv: taylor(1K)	median 612ns  		lowest: 600ns     	highest: 635ns
        luajit: integer math	median 47ns  		lowest: 42ns     	highest: 55ns
             luajit: fp math	median 58ns  		lowest: 55ns     	highest: 66ns
            luajit: exp math	median 65ns  		lowest: 62ns     	highest: 80ns
             luajit: fib(40)	median 59ns  		lowest: 55ns     	highest: 67ns
          luajit: taylor(1K)	median 882ns  		lowest: 840ns     	highest: 924ns

   libriscv: complex syscall	median 30ns  		lowest: 30ns     	highest: 34ns
     luajit: complex syscall	median 840ns  		lowest: 830ns     	highest: 865ns

     libriscv: micro threads	median 91ns  		lowest: 88ns     	highest: 100ns
          luajit: coroutines	median 162ns  		lowest: 156ns     	highest: 188ns

 libriscv: micro thread args	median 106ns  		lowest: 104ns     	highest: 113ns
  libriscv: full thread args	median 118ns  		lowest: 115ns     	highest: 125ns
      luajit: coroutine args	median 210ns  		lowest: 203ns     	highest: 227ns
      luajit: coroutine args	median 258ns  		lowest: 249ns     	highest: 268ns

      libriscv: naive memcpy	median 1044ns  		lowest: 999ns     	highest: 1056ns
    libriscv: syscall memcpy	median 14ns  		lowest: 13ns     	highest: 17ns
              luajit: memcpy	median 93ns  		lowest: 84ns     	highest: 102ns
    libriscv: syscall memset	median 9ns  		lowest: 8ns     	highest: 19ns
      libriscv: naive memset	median 262ns  		lowest: 172ns     	highest: 278ns
              luajit: memset	median 66ns  		lowest: 63ns     	highest: 77ns

        libriscv: sieve(10M)	median 39ms  		lowest: 39ms     	highest: 39ms
          luajit: sieve(10M)	median 130ms  		lowest: 130ms     	highest: 130ms