Skip to content

Commit

Permalink
Add benchmarks results into README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov authored Mar 27, 2024
1 parent 87cba9a commit 7b1c0c2
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ The textual representation of the IR after system independent optimizations:
```
The visualized graph:

![IR example](examples/mandelbrot.svg)
![IR example](https://dstogov.github.io/mandelbrot.svg)

The graph was generated by the commands:

Expand Down Expand Up @@ -342,6 +342,48 @@ clang -O -Xclang -disable-llvm-passes -c -emit-llvm -o tmp.bc ./dynasm/minilua.c
opt tmp.bc --passes='function(mem2reg)' -S -o minilua.ll
```

## Performace

The fllowing table shows the benchmarks execution time in comparison to the same benchmarks compiled by ``gcc -O2`` (the more the better). The C benchmark were compiled by CLAG into LLVM code (without any LLVM optimizations, only SSA construction is necessary now) and then loaded, compiled and executed by IR framework.

| Benhcmark | Execution time (relative to GCC -02) |
| --------------- | ------------------------------------ |
| array | 0.86 |
| binary-trees | 0.97 |
| funnkuch-reduce | 1.03 |
| hash | 1.13 |
| hash2 | 0.88 |
| heapsort | 1.02 |
| lists | 0.95 |
| matrix | 1.10 |
| method-call | 0.92 |
| mandelbrot | 0.95 |
| nbody | 0.77 |
| sieve | 0.92 |
| spectral-norm | 0.94 |
| strcat | 0.96 |
| oggenc | 0.86 |
| minilua | 0.96 |
| AVERAGE | 0.95 |
| GEOMEAN | 0.95 |

Most of the bechmarks a very simple (few screems of code), oggenc and minilua are real applications. As you can see, IR produces code that in average 5% slower than ``GCC -O2``, in worst case the code was ~25% slower, and on some benchmarks it even faster. The folloing chart shows the same data graphically.

![IR benchmark chart](https://dstogov.github.io/ir_bench.svg)


The following table shows the comilation time relative to ``gcc -O2`` (the more the better)

| Benhcmark | Compilation time (relative to GCC -02) |
| --------------- | -------------------------------------- |
| oggenc | 26.42 |
| minilua | 18.00 |
| AVERAGE | 22.21 |

This comparison is not completely fair, because GCC compiles C source, but IR takes precompiled LLVM asm

Anyway, **IR framework provides code that is in average 5% slower, but does this ~20 times faster**.

## PHP JIT based on IR

A new experimental JIT for PHP based on this project is developed at [master](https://github.com/php/php-src/tree/master/ext/opcache/jit) php-src branch.
Expand Down

0 comments on commit 7b1c0c2

Please sign in to comment.