Skip to content

Instantly share code, notes, and snippets.

@JakSprats
JakSprats / 1_setup
Created March 7, 2012 19:08
AlchemyREST vs Luvit+AlchemyDB
# Intel(R) Core(TM)2 Duo CPU T9600 @ 2.80GHz
# Ubuntu 9.10 64 bit
git clone https://github.com/luvit/luvit.git
(cd luvit
make
make install
)
git clone git://github.com/JakSprats/Alchemy-Database.git
@JakSprats
JakSprats / access-berkeleydb-1.cpp
Created December 15, 2011 12:40
LevelDB vs BerkeleyDB benchmark
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <db_cxx.h>
using namespace std;
@JakSprats
JakSprats / steps.sh
Created November 18, 2011 01:12
Benchmarking AlchemyDB (TCP, UDS, Embedded)
# download
git clone git://github.com/JakSprats/Alchemy-Database.git
# make the package
cd Alchemy-Database; make;
# change to directory w/ server, client, & benchmark-tool
cd redis/src
@JakSprats
JakSprats / disk_thrash.bash
Created June 18, 2011 07:39
Bash script to thrash disk
#!/bin/bash
T=$(tempfile)
time sudo find /usr -type f| sort -R | head -n 4000 | sed -e "s/\ /\\\ /g" > $T
rm -f rand.files
I=0
FILES=""
cat $T | while read file; do
if [ $I -lt 25 ]; then
@JakSprats
JakSprats / search engine ala AlchemyDB
Created January 27, 2011 00:14
test_word2item.bash
. ./bash_functions.sh
$CLI DROP TABLE item
$CLI CREATE TABLE item "(id INT, name TEXT)"
$CLI DROP TABLE word2item
$CLI CREATE TABLE word2item "(id INT, word_id INT, type INT, seller_id INT, pub_type INT, tag_id INT, item_id INT)"
$CLI CREATE INDEX ind_w2i_w ON word2item "(word_id)"
$CLI CREATE INDEX ind_w2i_i ON word2item "(item_id)"
CLI=./redisql-cli
$CLI CONFIG ADD LUA test/alchemy.lua
$CLI LUA "function cap_per_fk(max, tbl, fkname, fkval, pkname)
wc = fkname .. '=' .. fkval;
cnt_s = select('COUNT(*)', tbl, wc);
cnt = tonumber(string.sub(cnt_s, 2));
if (cnt > max) then
dnum = cnt - max;
wcob = wc .. ' ORDER BY ' .. pkname .. ' LIMIT ' .. dnum;
BENCH=./gen-benchmark
1.) use PK (no sorting)
taskset -c 1 $BENCH -q -c $C -n $REQ -s -A MULTI -Q SELECT \* FROM obycol WHERE "id BETWEEN 1 AND 10 ORDER BY id LIMIT 4 OFFSET 3"
38207.73 requests per second
2.) use unindexed column (sort) and sort to one column
taskset -c 1 $BENCH -q -c $C -n $REQ -s -A MULTI -Q SELECT \* FROM obycol WHERE "id BETWEEN 1 AND 10 ORDER BY m LIMIT 4 OFFSET 3"
28815.95 requests per second
3.) use unindexed column (sort) and sort to two columns
taskset -c 1 $BENCH -q -c $C -n $REQ -s -A MULTI -Q SELECT \* FROM obycol WHERE "id BETWEEN 1 AND 10 ORDER BY j,m LIMIT 4 OFFSET 3"
28535.61 requests per second
@JakSprats
JakSprats / client.py
Created December 21, 2010 23:58
test.py
import datetime
import errno
import socket
import threading
import time
import warnings
from itertools import chain, imap
from redis.exceptions import ConnectionError, ResponseError, InvalidResponse, WatchError
from redis.exceptions import RedisError, AuthenticationError
@JakSprats
JakSprats / 0 writeup
Created December 19, 2010 21:16
client calls
This test is not that conclusive, but its a start to test how much of a "tax" running AlchemyDB as a VirtualMachine must be paid.
All tests were run from one machine to another (both w/ phenom X4 @ 3.0 GHz CPUs)
The bare-metal was run on a 64bit Ubuntu 9.10
The Virtual machine was run on the same 64 bit Ubuntu 9.10 and the Virtual Machine was a Debian 5 (32 bit), the Hypervisor was VMware workstation 7.0.
A little bit stupid that the Virtual Machine was 32bit, but this is just a quick nothing-special first test to get a ballpark idea ... No special configuration was done in any of this, this is basically right out of the box.
@JakSprats
JakSprats / large update via cursors
Created December 14, 2010 20:33
script results
nrows: TOTAL: (WHERE fk=1)1000020
set count=4 WHERE fk = 1
elapsed time: 4375.12(ms)
nrows: (WHERE fk=1) count = 4: 10000196
nrows: (WHERE fk=1) count = 99: 0
BATCH UPDATE: set count=99 WHERE fk = 1
elapsed time: 5210.04(ms)