Skip to content

Instantly share code, notes, and snippets.

@ahh
ahh / log
Created February 24, 2017 03:40
"fixed" RCU test
Benchmark Time(ns) CPU(ns) Iterations
-----------------------------------------------------
raw time: 56.25ns
BM_RCULocked 56.6 903 100000000
raw time: 20.5ns
BM_View 20.6 329 100000000
Benchmark Time(ns) CPU(ns) Iterations
-----------------------------------------------------
raw time: 57.01ns
@ahh
ahh / log
Created February 24, 2017 03:13
Stack alignment results
ahh@madcat % ./raw; echo $?
0
ahh@madcat % ./raw; echo $?
48
ahh@madcat % ./raw; echo $?
16
ahh@madcat % ./raw; echo $?
32
@ahh
ahh / raw.S
Created February 24, 2017 03:12
stack alignment detector
.globl _start
.section .text
_start:
movq $0x3c, %rax
movq %rsp, %rdi
andq $63, %rdi
syscall
@ahh
ahh / view.cc
Created February 24, 2017 03:05
Bad view benchmark with timing
int64_t before = rdtsc();
SpawnNThreadsRunning(15, [&shared]() {
for (int i = 0; i < reps; ++i) {
auto snapshot = shared.Get();
// ... do some meaningless work...
}
});
for (int i = 0; i < reps; ++i) {
auto snapshot = shared.Get();
// ... do some meaningless work...
@ahh
ahh / view.cc
Created February 24, 2017 03:05
Bad view benchmark with timing
int64_t before = rdtsc();
SpawnNThreadsRunning(15, [&shared]() {
for (int i = 0; i < reps; ++i) {
auto snapshot = shared.Get();
// ... do some meaningless work...
}
});
for (int i = 0; i < reps; ++i) {
auto snapshot = shared.Get();
// ... do some meaningless work...
@ahh
ahh / view.cc
Created February 24, 2017 03:04
Bad view benchmark
void BM_View(int reps) {
rcu::View<char> shared;
SpawnNThreadsRunning(15, [&shared]() {
for (int i = 0; i < reps; ++i) {
auto snapshot = shared.Get();
// ... do some meaningless work...
}
});
for (int i = 0; i < reps; ++i) {
auto snapshot = shared.Get();
@ahh
ahh / view.cc
Created February 24, 2017 02:56
Benchmark example
static rcu::View<char> shared;
void BM_View(int reps) {
for (int i = 0; i < reps; ++i) {
auto snapshot = shared.Get();
// ... do some meaningless work...
}
}
BENCHMARK(BM_View)->Threads(16);
@ahh
ahh / example.cc
Created February 5, 2017 05:55
exemple
for (int i = 0; i < n; ++i) {
f(x, y, z) += q;
}