4 ms·
So, running under perf stat tells me the luajit version runs very much more instructions (5M vs. 3M with my patched C version), but they run in the same number
by glandium 8y ago
So, running under perf stat tells me the luajit version runs very much more instructions (5M vs. 3M with my patched C version), but they run in the same number of cycles (2.5M), with the luajit version using more instructions per cycle. The unpatched C version uses 3.5M instructions, and 3.5M cycles, which is half the number of instructions per cycle compared to the luajit version.
- viraptor 8y agoHow did you patch it? Just compile with "-fno-plt" or something more?
- glandium 8y agodiff --git a/hello.c b/hello.c index 725d5ec..b7b1745 100644 --- a/hello.c +++ b/hello.c @@ -1,3 +1,5 @@ +#define _GNU_SOURCE +#include <dlfcn.h> #include <stdio.h> #include "newplus/plus.h" @@ -7,8 +9,9 @@ void run(int count) long long end; int x = 0; + int (*_plusone)(int) = dlsym(RTLD_DEFAULT, "plusone"); while (x < count) - x = plusone(x); + x = _plusone(x); printf("%lld\n", current_timestamp() - start); } And you need to add -ldl to the link flags. Edit: but yeah, -fno-plt works too.