Skip to content

Instantly share code, notes, and snippets.

// omg
fn true_mod<T: Copy>(a: T, n: T) -> <<<T as ops::Rem>::Output as ops::Add<T>>::Output as ops::Rem<T>>::Output
where T: ops::Add + ops::Rem,
<T as ops::Rem>::Output: ops::Add<T>,
<<T as ops::Rem>::Output as ops::Add<T>>::Output: ops::Rem<T>
{
(((a % n) + n) % n)
}
int main(void) {
int x = 1;
float y = 1.0;
return true ? x : y;
}
int main(void) {
int x = 1;
int *y = &x;
return true ? x : y;
}

Benchmarking database engines is a great way to start discussions, market your product, embarrass yourself, and piss people off, often all at once!

Here is a non-exhaustive checklist of things you must report if you want to be taken seriously:

Hardware

  • CPU
  • Disk
  • RAM
  • Virtualization tech if used (try to avoid, it usually sucks)

Keybase proof

I hereby claim:

  • I am leifwalsh on github.
  • I am leifw (https://keybase.io/leifw) on keybase.
  • I have a public key whose fingerprint is ACA4 004D F414 21D2 2AA1 7662 B4B5 A4A0 3E4D 1FC0

To claim this, I am signing this object:

#include <atomic>
class spin_lock {
std::atomic<bool> _lock;
public:
spin_lock(const spin_lock&) = delete;
spin_lock& operator=(const spin_lock&) = delete;
spin_lock() : _lock(false) {}
@leifwalsh
leifwalsh / A_results.txt
Last active September 19, 2020 13:49
mcs lock: userspace c++11 implementation of http://lwn.net/Articles/590243/. seems to be awful---far worse than normal spinlock---with nthreads > ncpus
# clang version 3.4 (tags/RELEASE_34/final)
# Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz
spinlock 1: 3925ms
spinlock 2: 25665ms
spinlock 3: 27722ms
spinlock 4: 42727ms
std::mutex 1: 5526ms
std::mutex 2: 17672ms
std::mutex 3: 31038ms
std::mutex 4: 36890ms
// RSS
db.runCommand({touch: 'bar', data: true, index: true})
// db.stats() storageSize
(db.stats().storageSize + db.stats().indexSize) / 1024 / 1024 // mongodb
(db.stats().storageSize + db.stats().indexStorageSize) / 1024 / 1024 // tokumx
// full collection count
Date.timeFunc(function() { db.bar.count() }, 100)
// 10-key range count, with matcher
Date.timeFunc(function() { var x = Math.floor(Math.random() * (1000000 - 10)); db.bar.find({a: {$gte: x, $lt: x + 10}, x: 10000}).count() }, 10000)
// 100-key range count, with matcher
@leifwalsh
leifwalsh / A_instructions.md
Created January 11, 2014 23:02
got http://symas.com/mdb/microbench/ lightly hooked up to https://github.com/Tokutek/ft-index. Used leveldb vanilla code for scaffolding, may be missing some benchmark pieces (like Shuffle).

To build and run:

git clone https://github.com/Tokutek/ft-index
mkdir build-tokukv
pushd build-tokukv
cmake \
  -D CMAKE_BUILD_TYPE=Release \
  -D TOKU_DEBUG_PARANOID=OFF \
 -D USE_VALGRIND=OFF \
@properties.renderer
def get_a(props):
return "Hello, %s" % props.getProperty("a")
@properties.renderer
def get_cmd(props):
return ["echo", get_a]
factory = factory.BuildFactory([shell.ShellCommand(command=get_cmd)])