diff --git a/buildheader/bash.suppressions b/buildheader/bash.suppressions deleted file mode 100644 index 18e80e652..000000000 --- a/buildheader/bash.suppressions +++ /dev/null @@ -1,6 +0,0 @@ -{ - bash - Memcheck:Leak - ... - obj:/bin/bash -} diff --git a/buildheader/benchmarks/.gitignore b/buildheader/benchmarks/.gitignore deleted file mode 100644 index cb775cf19..000000000 --- a/buildheader/benchmarks/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*~ -dummy.dev \ No newline at end of file diff --git a/buildheader/benchmarks/.hostcheck b/buildheader/benchmarks/.hostcheck deleted file mode 100644 index 04dbc836e..000000000 --- a/buildheader/benchmarks/.hostcheck +++ /dev/null @@ -1,6 +0,0 @@ -if [[ `hostname` != beaker* ]] -then - echo "Be careful. This script formats disk partitions." - echo "It should only be run on a properly configured crash box!!" - exit 0 -fi diff --git a/buildheader/benchmarks/.ismounted b/buildheader/benchmarks/.ismounted deleted file mode 100644 index 0b999ece8..000000000 --- a/buildheader/benchmarks/.ismounted +++ /dev/null @@ -1,5 +0,0 @@ -mountpoint -q $mntpnt -if [ $? -ne 0 ]; then - echo "no file system mounted: $?" - exit 1 -fi \ No newline at end of file diff --git a/buildheader/benchmarks/.mountcheck b/buildheader/benchmarks/.mountcheck deleted file mode 100644 index 93c698255..000000000 --- a/buildheader/benchmarks/.mountcheck +++ /dev/null @@ -1,4 +0,0 @@ -if mountpoint -q $mntpnt; then - echo "$mntpnt already mounted!!!" - exit 0 -fi \ No newline at end of file diff --git a/buildheader/benchmarks/.rootcheck b/buildheader/benchmarks/.rootcheck deleted file mode 100644 index 50d5c7549..000000000 --- a/buildheader/benchmarks/.rootcheck +++ /dev/null @@ -1,4 +0,0 @@ -if [[ $EUID -ne 0 ]]; then - echo "This script must be run as root" 1>&2 - exit 0 -fi diff --git a/buildheader/benchmarks/application/git/cleanup-m.sh b/buildheader/benchmarks/application/git/cleanup-m.sh deleted file mode 100755 index c889b3b81..000000000 --- a/buildheader/benchmarks/application/git/cleanup-m.sh +++ /dev/null @@ -1,2 +0,0 @@ -../../cleanup-fs.sh -../../setup-ftfs.sh diff --git a/buildheader/benchmarks/application/git/run-git-clone.sh b/buildheader/benchmarks/application/git/run-git-clone.sh deleted file mode 100755 index 76c68be56..000000000 --- a/buildheader/benchmarks/application/git/run-git-clone.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -. ../../fs-info.sh -. ../../.ismounted -support=$HOME/$repo/benchmarks/support-files - -if [ ! -e $support/$clone_repo ] ; then - cd $support; git clone git@camilla.oscar.cs.stonybrook.edu:$clone_repo.git; cd - -fi - -if [ -e $mntpnt/$clone_repo ]; then - echo "Stop! $mntpnt/$repo already exists." - echo "Please delete and run again." - exit 17 -fi - -sudo ../../clear-fs-caches.sh - -cd $mntpnt; time git clone $support/$clone_repo diff --git a/buildheader/benchmarks/application/git/run-git-diff.sh b/buildheader/benchmarks/application/git/run-git-diff.sh deleted file mode 100755 index d68c09642..000000000 --- a/buildheader/benchmarks/application/git/run-git-diff.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -. ../../fs-info.sh -. ../../.ismounted - -support=$HOME/$repo/benchmarks/support-files - -if [ ! -e $mntpnt/$clone_repo ]; then - if [ ! -e $support/$clone_repo ] ; then - cd $support; git clone git@camilla.oscar.cs.stonybrook.edu:$clone_repo.git; cd - - fi - cd $mntpnt; git clone $support/$clone_repo; cd - -fi - -sudo ../../clear-fs-caches.sh - - -# first commit where file system compiles vs current commit (8/31/14) - -cd $mntpnt/$clone_repo; time git diff --patch 6b93052128d62bf0e87620db78a27269eb00ccbf 637d301e7dea09f10d11b7570e86de3f06f2470c > patch - -#cd $mntpnt/$repo; time git diff --quiet 6b93052128d62bf0e87620db78a27269eb00ccbf 637d301e7dea09f10d11b7570e86de3f06f2470c diff --git a/buildheader/benchmarks/application/rsync/cleanup-m.sh b/buildheader/benchmarks/application/rsync/cleanup-m.sh deleted file mode 100755 index c889b3b81..000000000 --- a/buildheader/benchmarks/application/rsync/cleanup-m.sh +++ /dev/null @@ -1,2 +0,0 @@ -../../cleanup-fs.sh -../../setup-ftfs.sh diff --git a/buildheader/benchmarks/application/rsync/run-rsync.sh b/buildheader/benchmarks/application/rsync/run-rsync.sh deleted file mode 100755 index 0bf7551c9..000000000 --- a/buildheader/benchmarks/application/rsync/run-rsync.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -. ../../fs-info.sh -. ../../.ismounted - -support=$HOME/$repo/benchmarks/support-files -src=linux-3.11.10 -dst=rsynced -dst2=rsynced2 -copypos=temploc - -if [ ! -e $support/$src ]; then - cd $support; tar -xf $src.tar.xz; cd - -fi - -sudo ../../clear-fs-caches.sh -#echo 'Copy from home to benchmark partition' -#sudo perf record -g -- rsync --stats -r -t -S -h $support/$src $mntpnt/$dst -#strace -c -T rsync --stats -r -t -S -h $support/$src $mntpnt/$dst 2&> strace.txt -#rsync --stats -r -t -S -h $support/$src $mntpnt/$dst -rsync --stats -r -t -W -h --inplace $support/$src $mntpnt/$dst - -sudo ../../clear-fs-caches.sh - -if [ -e $mntpnt/$dst2 ]; then - cd $mntpnt; rm -r $dst2; cd - -fi -#echo 'Copy from benchmark to benchmark partition' -#sudo perf record -g -- rsync --stats -r -t -S -h $mntpnt/$dst $mntpnt/$dst2 -#rsync --stats -r -t -S -h $mntpnt/$dst $mntpnt/$dst2 -#strace rsync --stats -r -t -S -h $mntpnt/$dst $mntpnt/$dst2 2&> strace.txt -rsync --stats -r -t -W -h --inplace $mntpnt/$dst $mntpnt/$dst2 -#rsync --stats -r -t -W -h $mntpnt/$dst $mntpnt/$dst2 -#if [ -e $support/$copypos ]; then -# cd $support; rm -r $copypos; cd - -#fi -#sudo ../../clear-fs-caches.sh -#echo 'Copy from benchmark to home partition' -#sudo perf record -g -- rsync --stats -r -t -S -h $mntpnt/$dst $support/$copypos -#rsync --stats -r -t -S -h $mntpnt/$dst $support/$copypos -#rsync --stats -r -t -W -h --inplace $mntpnt/$dst $support/$copypos - -# -r recurse into directories -# -t preserve modification times -# -S handle sparse file effectively -# --statsx give some file transfer stats -# -h output numbers in human readable format diff --git a/buildheader/benchmarks/application/tar/cleanup-m.sh b/buildheader/benchmarks/application/tar/cleanup-m.sh deleted file mode 100755 index c889b3b81..000000000 --- a/buildheader/benchmarks/application/tar/cleanup-m.sh +++ /dev/null @@ -1,2 +0,0 @@ -../../cleanup-fs.sh -../../setup-ftfs.sh diff --git a/buildheader/benchmarks/application/tar/run-tar.sh b/buildheader/benchmarks/application/tar/run-tar.sh deleted file mode 100755 index ea3ad9c99..000000000 --- a/buildheader/benchmarks/application/tar/run-tar.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -. ../../fs-info.sh -. ../../.ismounted - -support=$HOME/$repo/benchmarks/support-files -src=linux-3.11.10.tar.xz -dst=linux-3.11.10.tar.xz - -if [ ! -e $mntpnt/$dst ]; then - cp $support/$src $mntpnt/$dst -fi - -sudo ../../clear-fs-caches.sh - -cd $mntpnt; time tar -xf $dst - -cd - - -sudo ../../clear-fs-caches.sh - -cd $mntpnt; time tar -zcvf ./linux.tar.gz ./linux-3.11.10/ > /dev/null diff --git a/buildheader/benchmarks/cleanup-fs.sh b/buildheader/benchmarks/cleanup-fs.sh deleted file mode 100755 index f4ab13238..000000000 --- a/buildheader/benchmarks/cleanup-fs.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -DIR="${BASH_SOURCE%/*}" -if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi - -. "$DIR/fs-info.sh" -. "$DIR/.rootcheck" - -fstype=`grep "[[:space:]]$mntpnt[[:space:]]" /proc/mounts | cut -d' ' -f3` - -echo "unmounting $fstype" - -if [[ $fstype == "ext4" || $fstype == "btrfs" || $fstype == "xfs" ]] -then - umount $mntpnt - exit 0 -elif [[ $fstype == "ftfs" ]] -then - umount $mntpnt - rmmod $module - losetup -d /dev/loop0 - exit 0 -elif [[ $fstype == "zfs" ]] -then - umount $mntpnt - zpool destroy -f datastore - #zpool destroy -f datastore > /dev/null - #zfs destroy -rf datastore > /dev/null - exit 0 -else - echo "unknown fs type mounted: $fstype." - exit 1 -fi diff --git a/buildheader/benchmarks/clear-fs-caches.sh b/buildheader/benchmarks/clear-fs-caches.sh deleted file mode 100755 index 5bebcba22..000000000 --- a/buildheader/benchmarks/clear-fs-caches.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -DIR="${BASH_SOURCE%/*}" -if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi - -. "$DIR/fs-info.sh" -. "$DIR/.rootcheck" - -sync -echo 3 > /proc/sys/vm/drop_caches # 1 frees pagecache - # 2 frees dentries and inodes - # 3 all -sync - -echo "caches freed via /proc/sys/vm/drop_caches" - -fstype=`grep "[[:space:]]$mntpnt[[:space:]]" /proc/mounts | cut -d' ' -f3` -echo $fstype - -if [[ $fstype == "ext4" || $fstype == "btrfs" || $fstype == "xfs" ]] -then - umount $mntpnt - mount -t $fstype $sb_dev $mntpnt -elif [[ $fstype == "zfs" ]] -then - echo "what do we do with zfs?" - exit 0 -elif [[ $fstype == "ftfs" ]] -then - echo "removing $module and mounting/unmounting ftfs file system" - umount $mntpnt - rmmod $module - insmod $module sb_dev=$sb_dev sb_fstype=ext4 - mount -t ftfs $dummy_dev $mntpnt -o max=$circle_size - echo "mounted: $fstype." - exit 0 -else - echo "unknown fs type mounted: $fstype." - exit 1 -fi diff --git a/buildheader/benchmarks/fs-info.sh b/buildheader/benchmarks/fs-info.sh deleted file mode 100644 index ee607b5c2..000000000 --- a/buildheader/benchmarks/fs-info.sh +++ /dev/null @@ -1,9 +0,0 @@ -sb_dev=/dev/sda4 -dummy_file=dummy.dev -dummy_dev=/dev/loop0 -mntpnt=/mnt/benchmark -southbound_module=/home/ftfs/ft-index/ftfs/ftfs.ko -module=/home/ftfs/ft-index/filesystem/ftfs.ko -repo=ft-index -clone_repo=ft-index-snapshot -circle_size=128 diff --git a/buildheader/benchmarks/macro/mailserver/README b/buildheader/benchmarks/macro/mailserver/README deleted file mode 100644 index b8ce39286..000000000 --- a/buildheader/benchmarks/macro/mailserver/README +++ /dev/null @@ -1,35 +0,0 @@ -The test is based on dovecot-2.2.13. Please install dovecot-2.2.13 and dovecot-2.2-pigeonhoe, which you can find the src tar in the support-files dir. - -You will have to "sudo apt-get install libssl-dev and libpam-dev". - -1.untar both and go to dovecot-2.2.13 and do -"./configure --with-pam --with-ssl -make -sudo make install" - -and go to dovecot-2.2-pigeonhole -"./configure -make -sudo make install." - - -2.add dovecot, dovenull and ftfstest users -ftfstest user's passwd has to be ftfstest or change imap_punish.py - -3 untar dovecont-conf.tar.gz under support-files and mv it to replace -/usr/local/etc/dovecot/ - -4 go to /usr/local/share/doc/dovecot and run ./mkcert.sh - -5 run sudo dovecot - -By now everything should set. scripts are ready to go. - - -=====imap test =========================== -if you are the first time running imap_punish, please do remember to use -s or the mailboxes are not init-ed. - -please read the script to understand the params if you do not want to use default value to test... - -=====delivery test ======================= -very strightforward single client delivery throughput test. please fast read the script to understand the params if you do not want to use default value to test. diff --git a/buildheader/benchmarks/macro/mailserver/imap-test/imap-punish.py b/buildheader/benchmarks/macro/mailserver/imap-test/imap-punish.py deleted file mode 100755 index 1882ccf33..000000000 --- a/buildheader/benchmarks/macro/mailserver/imap-test/imap-punish.py +++ /dev/null @@ -1,162 +0,0 @@ -#!/usr/bin/python - -#import getpass -import imaplib -import time -import sys -import getopt -import random -import os -import types - -SERVER = "localhost" -USER = "ftfstest" -PASS = "ftfstest" - -def usage() : - print sys.argv[0] + \ -''': [-t # num threads (1)] - [ -w # write operation fraction out of 100 (0)] - [ -m # mailboxes (shared among threads) (1)] - [ -n # operations (per thread) (1000)] - [ -h Print this message] -''' - -# Get command line options -try : - opts, args = getopt.getopt(sys.argv[1:], 'hn:m:t:w:x:s') -except : - usage() - sys.exit(2) - -opt_threads = 8 -opt_writes = 50 -opt_mailboxes = 10 -opt_ops = 10000 -opt_setup = 0 -boxsize = 2500 - -for o, a in opts : - if o == '-h' : - usage() - sys.exit(2) - if o == '-n' : - opt_ops = int(a) - if o == '-m' : - opt_mailboxes = int(a) - if o == '-t' : - opt_threads = int(a) - if o == '-w' : - opt_writes = int(a) - if o == '-s' : - opt_setup = 1 - if o == '-x' : - boxsize = int(a) - -print "IMAP Punish: %d threads, %d operations, %d mailboxes, %d %% writes" % (opt_threads, opt_ops, opt_mailboxes, opt_writes) - -if (opt_setup) : - # Initialize each mailbox to contain 3,000 messages - M = imaplib.IMAP4_SSL(SERVER) - M.login(USER, PASS) - for i in range (opt_mailboxes) : - name = "box%d" % i - M.delete(name) - M.create(name) - print "Making box %s" % name - for j in range (boxsize) : - M.append(name, None, None, "I love to go a-wandering, along the mountain tracks...") - M.logout() - sys.exit(0) - -#print "Done making boxes. Making %d threads" % opt_threads - -t1 = time.time() - -# Create (fork) threads -for i in range(opt_threads) : - if 0 == os.fork() : - # Child - random.seed() - min = (i * opt_mailboxes) / opt_threads - if opt_mailboxes > opt_threads : - max = min + (opt_mailboxes / opt_threads) - else : - max = min + 1 - - M = [None] * opt_mailboxes - for j in range (min, max) : - M[j] = imaplib.IMAP4_SSL(SERVER) - M[j].login(USER, PASS) - box = "box%d" % j - M[j].select(box) - - - - for j in range(opt_ops) : - # Select a mailbox - if min != max : - idx = random.randint(min, max-1) - else : - idx = min - - rand_op = 0 - # Select an operation - if opt_writes != 0 : - rand_op = random.randint(1, 100) - if (rand_op <= opt_writes) : - # Choose the specific type of write - # 1 = change flag - # 2 = delete - # 3 = append - rand_op = random.randint(1, 3) - else : - rand_op = 0 - # Select a random uid - num = random.randint(1, boxsize) - - #print "Thread %d, op %d, num %d, box %s" % (i, rand_op, num, box) - - if rand_op == 0 : - typ, data = M[idx].uid('fetch', num, '(RFC822 FLAGS)') - elif rand_op == 1 : - typ, data = M[idx].uid('fetch', num, '(RFC822 FLAGS)') - flagged = 0 - if type(data[0]) is types.NoneType : - continue - - for flag in imaplib.ParseFlags(data[0][0]): - if (flag == '\Flagged') : - flagged = 1 - if flagged : - M[idx].uid("STORE", num, '-FLAGS', '(\\FLAGGED)') - else : - M[idx].uid("STORE", num, '+FLAGS', '(\\FLAGGED)') - - elif rand_op == 2: - M[idx].uid("STORE", num, '+FLAGS', '(\\Deleted)') - M[idx].expunge() - - elif rand_op == 3: - M[idx].append(box, None, None, "I love to go a-wandering, along the mountain tracks...") - - for j in range (min, max) : - M[j].logout() - sys.exit(0) - -for i in range(opt_threads) : - os.wait() - -t2 = time.time() - -print "This experiment took %f seconds" % (t2 - t1) - -# Empty out the mailbox -if 0: - M = imaplib.IMAP4_SSL(SERVER) - M.login(USER, PASS) - for i in range (opt_mailboxes) : - name = "box%d" % i - M.delete(name) - M.logout() - diff --git a/buildheader/benchmarks/macro/mailserver/imap-test/run-test.sh b/buildheader/benchmarks/macro/mailserver/imap-test/run-test.sh deleted file mode 100755 index 8c71864d1..000000000 --- a/buildheader/benchmarks/macro/mailserver/imap-test/run-test.sh +++ /dev/null @@ -1,8 +0,0 @@ -cd ~/ft-index/benchmarks/ -sudo ./cleanup-fs.sh -sudo ./setup-ftfs.sh -cd - -sudo cp -r /home/ftfstest/ftfstest/ /mnt/benchmark/ -sudo chown -R ftfstest:ftfstest /mnt/benchmark/ftfstest/ -sudo dovecot -./imap-punish.py diff --git a/buildheader/benchmarks/micro/circlingtradeoff/Makefile b/buildheader/benchmarks/micro/circlingtradeoff/Makefile deleted file mode 100644 index 483081f46..000000000 --- a/buildheader/benchmarks/micro/circlingtradeoff/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -all: file-rename.c - gcc -O3 -o file-rename file-rename.c -lcrypto -lm -lrt - -clean: - rm -f file-rename - diff --git a/buildheader/benchmarks/micro/circlingtradeoff/circle-dirscan.sh b/buildheader/benchmarks/micro/circlingtradeoff/circle-dirscan.sh deleted file mode 100755 index 6ef32a8f4..000000000 --- a/buildheader/benchmarks/micro/circlingtradeoff/circle-dirscan.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/bash - -TIMEFORMAT="%R" - -declare -A resultfind -declare -A resultgrep -cnt=0 -for i in 2048 1024 512 256 128 64 32 16 8 4 2 1 0 -#for i in 2048 -do - FT_HOMEDIR=/home/ftfs/ft-index - . $FT_HOMEDIR/benchmarks/fs-info.sh - sudo $FT_HOMEDIR/benchmarks/cleanup-fs.sh - sudo $FT_HOMEDIR/benchmarks/setup-ftfs-parameterized.sh $i -# sudo $FT_HOMEDIR/benchmarks/setup-ext4.sh - -# dropbox=Dropbox - linux=linux-3.11.10 - -# if [ -d $mntpnt/linux-3.11.10 ]; then -# : -# else -# . $FT_HOMEDIR/benchmarks/micro/prepare-support-file.sh -# fi - - echo "Copying linux src" - cp -r $FT_HOMEDIR/benchmarks/support-files/linux-3.11.10 $mntpnt -# cp -r /home/ftfs/$dropbox $mntpnt - echo "checpoint" > /proc/toku_checkpoint - echo "Circle Size: $i" - -# for k in $(seq 0 49) -# do -# sudo $FT_HOMEDIR/benchmarks/clear-fs-caches.sh -# echo "begining find" -# resultfind[$cnt, $k]=$( { time find $mntpnt/$linux -type f >/dev/null; } 2>&1 ) -# echo "done" -# echo "Time(find): ${resultfind[$cnt, $k]}" -# done - -# num=50 -# total=$( IFS="+"; bc <<< "${resultfind[*]}" ) -# resultavgf[$cnt]=$(echo $total / $num | bc -l) - - for k in $(seq 0 49) - do - sudo $FT_HOMEDIR/benchmarks/clear-fs-caches.sh - echo "begining grep" - resultgrep[$cnt, $k]=$( { time grep -r "cpu_to_be64" $mntpnt/$linux >/dev/null; } 2>&1 ) - echo "done" - echo "Time(grep): ${resultgrep[$cnt, $k]}" - done - -# total=$( IFS="+"; bc <<< "${resultgrep[*]}" ) -# resultavgf[$cnt]=$(echo $total / $num | bc -l) - - cnt=$((cnt+1)) -done - -echo "grep: ${resultgrep[@]}" -#echo "find: ${resultfind[@]}" diff --git a/buildheader/benchmarks/micro/circlingtradeoff/circle-file-rename.sh b/buildheader/benchmarks/micro/circlingtradeoff/circle-file-rename.sh deleted file mode 100755 index 4e3727444..000000000 --- a/buildheader/benchmarks/micro/circlingtradeoff/circle-file-rename.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - - -for i in 12 13 14 15 16 17 18 19 20 21 22 -do - . /home/ftfs/ft-index/benchmarks/fs-info.sh - sudo /home/ftfs/ft-index/benchmarks/cleanup-fs.sh - sudo /home/ftfs/ft-index/benchmarks/setup-ftfs-parameterized.sh 100000 - ./file-rename "BetrFS_v2_100000" $i "result-betrfs-100000" -done - -for i in 12 13 14 15 16 17 18 19 20 21 22 -do - . /home/ftfs/ft-index/benchmarks/fs-info.sh - sudo /home/ftfs/ft-index/benchmarks/cleanup-fs.sh - sudo /home/ftfs/ft-index/benchmarks/setup-ftfs-parameterized.sh 0 - ./file-rename "BetrFS_v2_0" $i "result-fsync-betrfs-0" -done - - - diff --git a/buildheader/benchmarks/micro/circlingtradeoff/file-rename.c b/buildheader/benchmarks/micro/circlingtradeoff/file-rename.c deleted file mode 100644 index b87657e80..000000000 --- a/buildheader/benchmarks/micro/circlingtradeoff/file-rename.c +++ /dev/null @@ -1,135 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -struct stat st = {0}; - -void swap(char **str1, char **str2) { - char *tmp = *str1; - *str1 = *str2; - *str2 = tmp; -} - -int createDir(char* name) { - int r; - if (stat(name, &st) == -1) { - r = mkdir(name, 0777 ); - } - if (r != 0) { - printf("Can't create diri: %s", strerror(errno)); - exit(-1); - } - r = opendir(name, O_WRONLY | O_DIRECTORY); - if (r < 0) { - printf("error create dir r <0: %s\n", strerror(errno)); - exit(-1); - } - return r; -} - -int main(int argc, char* argv[]) { - - char *dir = "/mnt/benchmark/"; - char *srcfname = "/mnt/benchmark/a"; - char *dstfname = "/mnt/benchmark/b"; - // char *dir = "/home/ftfs/ft-index/benchmarks/micro/circlingtradeoff/dir"; - // char *srcfname = "/home/ftfs/ft-index/benchmarks/micro/circlingtradeoff/dir/a"; - // char *dstfname = "/home/ftfs/ft-index/benchmarks/micro/circlingtradeoff/dir/b"; - struct timespec start, end; - // struct timespec startrename, endrename; - // struct timespec startfsync, endfsync; - double elapsed; - // double elapsedrename; - // double elapsedfsync; - int filefd, dirfd; - int i, j; - int status, status1; - char *data; - int errno; - - char *filesystem = argv[1]; - double fsize = pow(2.0, atof(argv[2])); - char *filename = argv[3]; - - FILE *result = fopen(filename, "ab"); - - if (result == NULL) { - printf("Can't open result file"); - exit(0); - } - - data = (char *)malloc(fsize); - RAND_pseudo_bytes((unsigned char *)data, fsize); - - if((filefd = open(srcfname, O_CREAT | O_WRONLY, 0644)) < 0) { - fprintf(stderr, "open file failed\n"); - return -1; - } - - status = pwrite(filefd, data, fsize, 0); - if (status != fsize) { - printf("pwrite failed. Only write: %d", status); - exit(-1); - } - - status1 = fsync(filefd); - if (status1 != 0) - printf("Failed to sync file: %s\n", strerror(errno)); - - dirfd = open(dir, O_RDONLY); //createDir(dir); - if (dirfd < 0) { - printf("Can't open dir: %s", strerror(errno)); - exit(-1); - } - - for (j=0; j<100; j++) { - // printf("Src: %s Dst: %s\n", srcfname, dstfname); - - clock_gettime(CLOCK_MONOTONIC, &start); - // clock_gettime(CLOCK_MONOTONIC, &startrename); - status = rename(srcfname, dstfname); - // clock_gettime(CLOCK_MONOTONIC, &endrename); - - // clock_gettime(CLOCK_MONOTONIC, &startfsync); - status1 = fsync(dirfd); - // clock_gettime(CLOCK_MONOTONIC, &endfsync); - clock_gettime(CLOCK_MONOTONIC, &end); - - if (status != 0) { - printf("Failed to rename: %s\n", strerror(errno)); - exit(-1); - } - if (status1 != 0) { - printf("Failed to sync dir: %s\n", strerror(errno)); - exit(-1); - } - - //printf("Rename status: %d, Fsync status: %d\n", status, status1); - elapsed = (end.tv_sec - start.tv_sec) + (end.tv_nsec - start.tv_nsec) / 1000000000.0; - // elapsedrename = (endrename.tv_sec - startrename.tv_sec) + (endrename.tv_nsec - startrename.tv_nsec) / 1000000000.0; - // elapsedfsync = (endfsync.tv_sec - startfsync.tv_sec) + (endfsync.tv_nsec - startfsync.tv_nsec) / 1000000000.0; - fprintf(result, "%s, %lf, %lf\n", filesystem, fsize, elapsed); - printf("%s, %lf, %lf\n", filesystem, fsize, elapsed); - // fprintf(result, "%s, %d, %lf, %lf, %lf\n", filesystem, circle_size, fsize, elapsedrename, elapsedfsync); - // printf("%s, %d, %lf, %lf, %lf\n", filesystem, circle_size, fsize, elapsedrename, elapsedfsync); - - swap(&srcfname, &dstfname); - } - - free(data); - close(filefd); - close(dirfd); - - return 0; -} - diff --git a/buildheader/benchmarks/micro/large-file/.gitignore b/buildheader/benchmarks/micro/large-file/.gitignore deleted file mode 100644 index 017decc69..000000000 --- a/buildheader/benchmarks/micro/large-file/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -random_write -sequential_write diff --git a/buildheader/benchmarks/micro/large-file/Makefile b/buildheader/benchmarks/micro/large-file/Makefile deleted file mode 100644 index 306bad7f7..000000000 --- a/buildheader/benchmarks/micro/large-file/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -all: random_write.c sequential_write.c - gcc random_write.c -o random_write -lrt - gcc -g sequential_write.c -o sequential_write -lrt - -clean: - rm -f random_write sequential_write - diff --git a/buildheader/benchmarks/micro/large-file/clean-mount.sh b/buildheader/benchmarks/micro/large-file/clean-mount.sh deleted file mode 100755 index c889b3b81..000000000 --- a/buildheader/benchmarks/micro/large-file/clean-mount.sh +++ /dev/null @@ -1,2 +0,0 @@ -../../cleanup-fs.sh -../../setup-ftfs.sh diff --git a/buildheader/benchmarks/micro/large-file/params.sh b/buildheader/benchmarks/micro/large-file/params.sh deleted file mode 100644 index 50b2d419b..000000000 --- a/buildheader/benchmarks/micro/large-file/params.sh +++ /dev/null @@ -1,16 +0,0 @@ -############################## -#### benchmark parameters #### -############################## -f_size=$((10*1024*1024*1024)) -mnt="/mnt/benchmark" -input="large.file" - - -#################################################### -##### parameters for dd and sequential_write.c ##### -#################################################### - -# generate randomized buffers of write_size, and each write system -# call will write 1 whole buffer -io_size=40960 # read/write in io_size units -random_buffers=2000 # alternate among randomized buffers diff --git a/buildheader/benchmarks/micro/large-file/random_write.c b/buildheader/benchmarks/micro/large-file/random_write.c deleted file mode 100644 index 86936b9c1..000000000 --- a/buildheader/benchmarks/micro/large-file/random_write.c +++ /dev/null @@ -1,109 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -static long randomwrites = 10000; -static char * fname = NULL; -static long long fsize = 0; -static char * prog_name; - -static void process_options(int, char *[]); -int main(int argc, char* argv[]) { - struct timespec start, end; - double elapsed, mb; - int pos; - int fd; - int i; - long long *array; - - char buffer[4] = {'\20','\10','\5','W'}; - - prog_name = argv[0]; - process_options(argc, argv); - if( 0 == fsize || 0 == fname) { - fprintf(stderr, "error option: you have to set both fname: %s and fsize: %lld\n", fname, fsize); - return -1; - } - - if (fsize <= 4) { - fprintf(stderr, "fsize too small\n"); - return -1; - } - - array = malloc(sizeof(int) * randomwrites); - if (random == NULL) { - fprintf(stderr, "Allocate memory failed\n"); - return -1; - } - - srand(42); - - for (i = 0; i < randomwrites; i++) { - array[i] = (random()<<32|random()) % (fsize - 4); - } - - if((fd = open(fname, O_RDWR,0644)) < 0) { - fprintf(stderr, "open file failed\n"); - return -1; - } - - clock_gettime(CLOCK_MONOTONIC, &start); - - /* THIS IS THE ACTUAL TEST */ - for(i = 0; i < randomwrites; i ++) { - pwrite(fd, buffer, 4, array[i]); - } - fsync(fd); - - clock_gettime(CLOCK_MONOTONIC, &end); - - close(fd); - - elapsed = (end.tv_sec - start.tv_sec) + (end.tv_nsec - start.tv_nsec) / 1000000000.0; - mb = (4*randomwrites)/1.0E6; - printf("op, seq.or.rand, size.MB, time.s, throughput.MBps\n"); - printf("write, random, %lf, %lf, %lf\n", mb, elapsed, mb / elapsed); - return 0; -} -void print_usage (FILE * stream){ - fprintf(stream, "%s -s FILESIZE -f FNAME [-r RANDOMWRITES]\n", prog_name); - fprintf(stream, "\t -r --randomwrites how many randomwrites\n"); - fprintf(stream, "\t -f --filename the file name to be written\n"); - fprintf(stream, "\t -s --size the file size (max pos)\n"); - -} - -void process_options(int argc, char * argv[]){ - int opt; - struct option long_opts[] = { - {"size", 1, 0, 's'}, - {"filename", 1, 0, 'f'}, - {"randomwrites", 1, 0, 'r'}, - {0,0,0,0} - }; - while((opt = getopt_long(argc,argv, "s:f:r:", long_opts, NULL))!=EOF) - { switch(opt) - { - case 'r': - randomwrites = atol(optarg); - break; - case 'f': - fname = optarg; - break; - case 's': - fsize = atoll(optarg); - break; - default: - print_usage(stderr); - return; - } - - } - -} - diff --git a/buildheader/benchmarks/micro/large-file/run-large-file-random_write.sh b/buildheader/benchmarks/micro/large-file/run-large-file-random_write.sh deleted file mode 100755 index 31012aabd..000000000 --- a/buildheader/benchmarks/micro/large-file/run-large-file-random_write.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -. params.sh - -exe="./random_write" - -if [ ! -e $exe ] ; then - echo "Stop! You must run 'make' first!" - exit 1 -fi - -if [ ! -e $mnt/$input ] ; then - echo "Stop! run run-large-file-write.sh first!" - echo "This will generate the input file" - exit 1 -fi - -sudo ../../clear-fs-caches.sh - -echo "beginning random write test..." -$exe -f $mnt/$input -s $f_size -echo "done!" diff --git a/buildheader/benchmarks/micro/large-file/run-large-file-read.sh b/buildheader/benchmarks/micro/large-file/run-large-file-read.sh deleted file mode 100755 index 5637e21e7..000000000 --- a/buildheader/benchmarks/micro/large-file/run-large-file-read.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -. params.sh - -read_exe="dd" -write_exe="./sequential_write" - -if [ ! -e $write_exe ] ; then - echo "Stop! You must run 'make' first!" - exit 1 -fi - -if [ ! -e $mnt/$input ]; then - echo "no input file... generating" - $write_exe -o$mnt/$input -b$io_size -n$random_buffers -s$f_size - echo "done generating input file." -fi - -sudo ../../clear-fs-caches.sh - -echo "beginning test..." -$read_exe if=$mnt/$input of=/dev/null bs=$io_size count=$(($f_size / $io_size)) 2>&1 | grep "10737" -echo "done!" diff --git a/buildheader/benchmarks/micro/large-file/run-large-file-write.sh b/buildheader/benchmarks/micro/large-file/run-large-file-write.sh deleted file mode 100755 index 38c42d690..000000000 --- a/buildheader/benchmarks/micro/large-file/run-large-file-write.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -. params.sh - -exe="./sequential_write" - -if [ ! -e $exe ] ; then - echo "Stop! You must run 'make' first!" - exit 1 -fi - -if [ -e $mnt/$input ] ; then - echo "File Exists. This is an overwrite." - rm $mnt/$input -fi - -echo "a" > $mnt/zzz -sudo ../../clear-fs-caches.sh -#iostat -p -echo "beginning sequential write test..." -$exe -o$mnt/$input -b$io_size -n$random_buffers -s$f_size -echo "done!" -#iostat -p diff --git a/buildheader/benchmarks/micro/large-file/sequential_write.c b/buildheader/benchmarks/micro/large-file/sequential_write.c deleted file mode 100644 index 274508a57..000000000 --- a/buildheader/benchmarks/micro/large-file/sequential_write.c +++ /dev/null @@ -1,142 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define PAGE_SIZE 4096 -#define BLOCK_SIZE 4096 -#define RAND_BLOCKS 5 -#define DEFAULT_SEED 42 - -static char * fname = NULL; -static long long fsize = 1073741824; -static char * prog_name; -static unsigned int seed = DEFAULT_SEED; -static unsigned int block_size = BLOCK_SIZE; -static unsigned int rand_blocks = RAND_BLOCKS; - -static void process_options(int, char *[]); - -int main(int argc, char* argv[]) { - struct timespec start, end; - double elapsed, mb; - long long pos; - int fd; - int ret; - int i, j; - char **array; - - prog_name = argv[0]; - process_options(argc, argv); - if ( 0 == fsize || 0 == fname) { - fprintf(stderr, "error option: you have to set both" - " fname: %s and fsize: %lld\n", fname, fsize); - return -1; - } - printf("file_size: %lld\n", fsize); - printf("block_size: %d\n", block_size); - printf("rand_blocks: %d\n", rand_blocks); - - if (fsize <= 4) { - fprintf(stderr, "fsize too small\n"); - return -1; - } - - srand(seed); - - array = malloc(RAND_BLOCKS * sizeof(*array)); - if (!array) - return -ENOMEM; - - /* we want some page aligned buffers with incompressible data */ - for (i = 0; i < rand_blocks; i++) { - ret = posix_memalign((void**)&array[i], PAGE_SIZE, block_size); - if (ret) { - fprintf(stderr, "memalign failed: %d\n", ret); - return ret; - } - for (j = 0; j < block_size; j++) - array[i][j] = (char) rand(); - } - - fd = open(fname, O_RDWR | O_CREAT, 0644); - if (fd < 0) { - fprintf(stderr, "open file failed: %d\n", fd); - return fd; - } - - clock_gettime(CLOCK_MONOTONIC, &start); - - i = 0; - pos = 0; - for(pos = 0; pos < fsize; pos += block_size) { - ret = pwrite(fd, array[i], block_size, pos); - if (ret != block_size) - printf("short write (ret: %d)\n", ret); - i = (i+1) % rand_blocks; - } - - fsync(fd); - - clock_gettime(CLOCK_MONOTONIC, &end); - - close(fd); - - elapsed = (end.tv_sec - start.tv_sec) + - (end.tv_nsec - start.tv_nsec) / 1000000000.0; - - mb = fsize/1.0E6; - printf("op, seq.or.rand, size.MB, time.s, throughput.MBps\n"); - printf("write, seq, %lf, %lf, %lf\n", mb, elapsed, mb / elapsed); - - return 0; -} -void print_usage (FILE * stream){ - fprintf(stream, "%s -s FILESIZE -f FNAME [-r RANDOMWRITES]\n", prog_name); - fprintf(stream, "\t -r --random_seed seed for srand()\n"); - fprintf(stream, "\t -o --filename the output file name\n"); - fprintf(stream, "\t -s --size output file size (max pos)\n"); - -} - -void process_options(int argc, char * argv[]){ - int opt; - - struct option long_opts[] = { - {"output_file", 1, 0, 'o'}, - {"file_size", 1, 0, 's'}, - {"block_size", 1, 0, 'b'}, - {"num_blocks", 1, 0, 'n'}, - {"random_seed", 1, 0, 'r'}, - }; - - - while((opt = getopt_long(argc,argv, "r:o:s:b:n:", long_opts, NULL))!=EOF) { - switch (opt) { - case 'r': - seed = atoi(optarg); - break; - case 'o': - fname = optarg; - break; - case 's': - fsize = atoll(optarg); - break; - case 'b': - block_size = atoi(optarg); - break; - case 'n': - rand_blocks = atoi(optarg); - break; - default: - print_usage(stderr); - return; - } - } -} - diff --git a/buildheader/benchmarks/micro/prepare-support-file.sh b/buildheader/benchmarks/micro/prepare-support-file.sh deleted file mode 100755 index 222e14db9..000000000 --- a/buildheader/benchmarks/micro/prepare-support-file.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -set -x -FT_HOMEDIR=/home/ftfs/ft-index/ -. $FT_HOMEDIR/benchmarks/fs-info.sh || exit 1 -pushd $PWD || exit 1 -cd $FT_HOMEDIR/benchmarks/support-files || exit 1 -if [ -d linux-3.11.10 ] -then : -else - tar -xf linux-3.11.10.tar.xz || exit 1 -fi - -if [ -d $mntpnt/linux-3.11.10 ] -then : -else - cp -r linux-3.11.10 $mntpnt || exit 1 -fi -popd || exit 1 -exit 0 diff --git a/buildheader/benchmarks/micro/readafterrandomwrites/Makefile b/buildheader/benchmarks/micro/readafterrandomwrites/Makefile deleted file mode 100644 index a864f2194..000000000 --- a/buildheader/benchmarks/micro/readafterrandomwrites/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -all: random_write.c sequential_write.c - gcc -g random_write.c -o random_write -lrt - gcc -g sequential_write.c -o sequential_write -lrt - -clean: - rm -f random_write sequential_write - diff --git a/buildheader/benchmarks/micro/readafterrandomwrites/clean-mount.sh b/buildheader/benchmarks/micro/readafterrandomwrites/clean-mount.sh deleted file mode 100755 index 895a8539c..000000000 --- a/buildheader/benchmarks/micro/readafterrandomwrites/clean-mount.sh +++ /dev/null @@ -1,2 +0,0 @@ -../../cleanup-fs.sh -../../setup-$1.sh diff --git a/buildheader/benchmarks/micro/readafterrandomwrites/params.sh b/buildheader/benchmarks/micro/readafterrandomwrites/params.sh deleted file mode 100644 index 50b2d419b..000000000 --- a/buildheader/benchmarks/micro/readafterrandomwrites/params.sh +++ /dev/null @@ -1,16 +0,0 @@ -############################## -#### benchmark parameters #### -############################## -f_size=$((10*1024*1024*1024)) -mnt="/mnt/benchmark" -input="large.file" - - -#################################################### -##### parameters for dd and sequential_write.c ##### -#################################################### - -# generate randomized buffers of write_size, and each write system -# call will write 1 whole buffer -io_size=40960 # read/write in io_size units -random_buffers=2000 # alternate among randomized buffers diff --git a/buildheader/benchmarks/micro/readafterrandomwrites/random_write.c b/buildheader/benchmarks/micro/readafterrandomwrites/random_write.c deleted file mode 100644 index 2c0490756..000000000 --- a/buildheader/benchmarks/micro/readafterrandomwrites/random_write.c +++ /dev/null @@ -1,145 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define PAGE_SIZE 4096 -//#define BLOCK_SIZE 100 -#define BLOCK_SIZE 4095 -#define DEFAULT_SEED 42 - -static long randomwrites = 10000; -static char * fname = NULL; -static long long fsize = 0; -static unsigned int block_size = BLOCK_SIZE; -static unsigned int seed = DEFAULT_SEED; -static unsigned int numbuffers = 50; -static char * prog_name; - -static void process_options(int, char *[]); -int main(int argc, char* argv[]) { - struct timespec start, end; - double elapsed, mb; - int pos; - int fd; - int i, ret, k, pwriteret; - long long *array; - long long max = 0; - char **buffer; - - printf(" write_size = %d\n", block_size); - prog_name = argv[0]; - process_options(argc, argv); - if( 0 == fsize || 0 == fname) { - fprintf(stderr, "error option: you have to set both fname: %s and fsize: %lld\n", fname, fsize); - return -1; - } - - if (fsize <= 4) { - fprintf(stderr, "fsize too small\n"); - return -1; - } - - array = malloc(sizeof(long long) * randomwrites); - if (random == NULL) { - fprintf(stderr, "Allocate memory failed\n"); - return -1; - } - - srand(seed); - - for (i = 0; i < randomwrites; i++) { - array[i] = random(); - array[i] = (array[i] << 32) | rand(); - array[i] = array[i] % (fsize - 4096); - array[i] -= array[i]%4096; - } - - buffer = malloc(numbuffers * sizeof(*buffer)); - if(!buffer) - return -ENOMEM; - - for (k=0; k -b -o -#sudo blktrace -d /dev/sda4 -b 2048 -o ${1}-read & -echo "beginning test..." -$read_exe if=$mnt/$input of=/dev/null bs=$io_size count=$(($f_size / $io_size)) 2>&1 | grep "^10737" -echo "done!" -#sudo pkill -15 blktrace diff --git a/buildheader/benchmarks/micro/readafterrandomwrites/run-large-file-write.sh b/buildheader/benchmarks/micro/readafterrandomwrites/run-large-file-write.sh deleted file mode 100755 index b95eec6a6..000000000 --- a/buildheader/benchmarks/micro/readafterrandomwrites/run-large-file-write.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -. params.sh - -exe="./sequential_write" - -if [ ! -e $exe ] ; then - echo "Stop! You must run 'make' first!" - exit 1 -fi - -if [ ! -e $mnt/$input ] ; then - echo "Warning. The first run will use the right-edge optimization." - echo "********Please discard the first run********" -fi - -if [ -e $mnt/$input ] ; then - rm $mnt/$input -fi - -sudo ../../clear-fs-caches.sh - -echo "beginning sequential write test..." -#sudo blktrace -d /dev/sda4 -b 2048 & -$exe -o$mnt/$input -b$io_size -n$random_buffers -s$f_size -#sudo pkill -15 blktrace -echo "done!" - diff --git a/buildheader/benchmarks/micro/readafterrandomwrites/run-test.sh b/buildheader/benchmarks/micro/readafterrandomwrites/run-test.sh deleted file mode 100755 index 4b405abf1..000000000 --- a/buildheader/benchmarks/micro/readafterrandomwrites/run-test.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -FILESYS=$1 - -sudo ./clean-mount.sh $1 > /dev/null -result=`./run-large-file-write.sh | grep "^write"` -echo "$FILESYS, $result" -result=`./run-large-file-read.sh \"first\" | grep "^10737" | awk '{print $6", "$8}'` -echo "$FILESYS, read, seq, 10737.418240, $result" -result=`./run-large-file-random_write.sh | grep "^write"` -echo "$FILESYS, $result" -result=`./run-large-file-read.sh \"second\" | grep "^10737" | awk '{print $6", "$8}'` -echo "$FILESYS, read, seq, 10737.418240, $result" -printf "\n" diff --git a/buildheader/benchmarks/micro/readafterrandomwrites/sequential_write.c b/buildheader/benchmarks/micro/readafterrandomwrites/sequential_write.c deleted file mode 100644 index 274508a57..000000000 --- a/buildheader/benchmarks/micro/readafterrandomwrites/sequential_write.c +++ /dev/null @@ -1,142 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define PAGE_SIZE 4096 -#define BLOCK_SIZE 4096 -#define RAND_BLOCKS 5 -#define DEFAULT_SEED 42 - -static char * fname = NULL; -static long long fsize = 1073741824; -static char * prog_name; -static unsigned int seed = DEFAULT_SEED; -static unsigned int block_size = BLOCK_SIZE; -static unsigned int rand_blocks = RAND_BLOCKS; - -static void process_options(int, char *[]); - -int main(int argc, char* argv[]) { - struct timespec start, end; - double elapsed, mb; - long long pos; - int fd; - int ret; - int i, j; - char **array; - - prog_name = argv[0]; - process_options(argc, argv); - if ( 0 == fsize || 0 == fname) { - fprintf(stderr, "error option: you have to set both" - " fname: %s and fsize: %lld\n", fname, fsize); - return -1; - } - printf("file_size: %lld\n", fsize); - printf("block_size: %d\n", block_size); - printf("rand_blocks: %d\n", rand_blocks); - - if (fsize <= 4) { - fprintf(stderr, "fsize too small\n"); - return -1; - } - - srand(seed); - - array = malloc(RAND_BLOCKS * sizeof(*array)); - if (!array) - return -ENOMEM; - - /* we want some page aligned buffers with incompressible data */ - for (i = 0; i < rand_blocks; i++) { - ret = posix_memalign((void**)&array[i], PAGE_SIZE, block_size); - if (ret) { - fprintf(stderr, "memalign failed: %d\n", ret); - return ret; - } - for (j = 0; j < block_size; j++) - array[i][j] = (char) rand(); - } - - fd = open(fname, O_RDWR | O_CREAT, 0644); - if (fd < 0) { - fprintf(stderr, "open file failed: %d\n", fd); - return fd; - } - - clock_gettime(CLOCK_MONOTONIC, &start); - - i = 0; - pos = 0; - for(pos = 0; pos < fsize; pos += block_size) { - ret = pwrite(fd, array[i], block_size, pos); - if (ret != block_size) - printf("short write (ret: %d)\n", ret); - i = (i+1) % rand_blocks; - } - - fsync(fd); - - clock_gettime(CLOCK_MONOTONIC, &end); - - close(fd); - - elapsed = (end.tv_sec - start.tv_sec) + - (end.tv_nsec - start.tv_nsec) / 1000000000.0; - - mb = fsize/1.0E6; - printf("op, seq.or.rand, size.MB, time.s, throughput.MBps\n"); - printf("write, seq, %lf, %lf, %lf\n", mb, elapsed, mb / elapsed); - - return 0; -} -void print_usage (FILE * stream){ - fprintf(stream, "%s -s FILESIZE -f FNAME [-r RANDOMWRITES]\n", prog_name); - fprintf(stream, "\t -r --random_seed seed for srand()\n"); - fprintf(stream, "\t -o --filename the output file name\n"); - fprintf(stream, "\t -s --size output file size (max pos)\n"); - -} - -void process_options(int argc, char * argv[]){ - int opt; - - struct option long_opts[] = { - {"output_file", 1, 0, 'o'}, - {"file_size", 1, 0, 's'}, - {"block_size", 1, 0, 'b'}, - {"num_blocks", 1, 0, 'n'}, - {"random_seed", 1, 0, 'r'}, - }; - - - while((opt = getopt_long(argc,argv, "r:o:s:b:n:", long_opts, NULL))!=EOF) { - switch (opt) { - case 'r': - seed = atoi(optarg); - break; - case 'o': - fname = optarg; - break; - case 's': - fsize = atoll(optarg); - break; - case 'b': - block_size = atoi(optarg); - break; - case 'n': - rand_blocks = atoi(optarg); - break; - default: - print_usage(stderr); - return; - } - } -} - diff --git a/buildheader/benchmarks/micro/recursive-dir-delete/README b/buildheader/benchmarks/micro/recursive-dir-delete/README deleted file mode 100644 index b701aee64..000000000 --- a/buildheader/benchmarks/micro/recursive-dir-delete/README +++ /dev/null @@ -1,4 +0,0 @@ -ftfs should be properly set before benchmarking recursive dir deletion. (by runing setup-ftfs.sh) - -just run -sudo ./recur-del.sh diff --git a/buildheader/benchmarks/micro/recursive-dir-delete/recur-del.sh b/buildheader/benchmarks/micro/recursive-dir-delete/recur-del.sh deleted file mode 100755 index cbe5c0112..000000000 --- a/buildheader/benchmarks/micro/recursive-dir-delete/recur-del.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -set -x -FT_HOMEDIR=/home/ftfs/ft-index -. $FT_HOMEDIR/benchmarks/fs-info.sh -#. $FT_HOMEDIR/benchmarks/.rootcheck -#. $FT_HOMEDIR/benchmarks/micro/prepare-support-file.sh -(cd $FT_HOMEDIR/benchmarks/; sudo ./clear-fs-caches.sh) -time rm -fr $mntpnt/linux-3.11.10>/dev/null 2>&1 diff --git a/buildheader/benchmarks/micro/recursive-grep/README b/buildheader/benchmarks/micro/recursive-grep/README deleted file mode 100644 index 6bd5cf1ce..000000000 --- a/buildheader/benchmarks/micro/recursive-grep/README +++ /dev/null @@ -1,7 +0,0 @@ -ftfs should be properly set before benchmarking recursive dir deletion. (by running setup-ftfs.sh) - -run at least once -sudo ./prepare-support-files.sh - -then run -sudo ./recur-grep.sh diff --git a/buildheader/benchmarks/micro/recursive-grep/clean-mount.sh b/buildheader/benchmarks/micro/recursive-grep/clean-mount.sh deleted file mode 100755 index c889b3b81..000000000 --- a/buildheader/benchmarks/micro/recursive-grep/clean-mount.sh +++ /dev/null @@ -1,2 +0,0 @@ -../../cleanup-fs.sh -../../setup-ftfs.sh diff --git a/buildheader/benchmarks/micro/recursive-grep/recur-grep.sh b/buildheader/benchmarks/micro/recursive-grep/recur-grep.sh deleted file mode 100755 index 9f7e54879..000000000 --- a/buildheader/benchmarks/micro/recursive-grep/recur-grep.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -set -x -FT_HOMEDIR=/home/ftfs/ft-index -. $FT_HOMEDIR/benchmarks/fs-info.sh -#. $FT_HOMEDIR/benchmarks/.rootcheck -if [ -d $mntpnt/linux-3.11.10 ]; then -: -else -. $FT_HOMEDIR/benchmarks/micro/prepare-support-file.sh -fi -(cd $FT_HOMEDIR/benchmarks/; sudo ./clear-fs-caches.sh) -if [ "$1" = "" ] -then -keyword=cpu_to_be64 -else -keyword=$1 -fi -time grep -r $keyword $mntpnt/linux-3.11.10>/dev/null 2>&1 diff --git a/buildheader/benchmarks/micro/recursive-scan-find/README b/buildheader/benchmarks/micro/recursive-scan-find/README deleted file mode 100644 index 77d7b4bd0..000000000 --- a/buildheader/benchmarks/micro/recursive-scan-find/README +++ /dev/null @@ -1,7 +0,0 @@ -ftfs should be properly set before benchmarking recursive dir deletion. (by running setup-ftfs.sh) - -run at least once -sudo ./prepare-support-files.sh - -then run -sudo ./recur-find.sh diff --git a/buildheader/benchmarks/micro/recursive-scan-find/recur-find.sh b/buildheader/benchmarks/micro/recursive-scan-find/recur-find.sh deleted file mode 100755 index 193151fe3..000000000 --- a/buildheader/benchmarks/micro/recursive-scan-find/recur-find.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -set -x -FT_HOMEDIR=/home/ftfs/ft-index -. $FT_HOMEDIR/benchmarks/fs-info.sh -#. $FT_HOMEDIR/benchmarks/.rootcheck -if [ -d $mntpnt/linux-3.11.10 ]; then -: -else -. $FT_HOMEDIR/benchmarks/micro/prepare-support-file.sh -fi -(cd $FT_HOMEDIR/benchmarks/; sudo ./clear-fs-caches.sh) -if [ "$1" = "" ] -then -filename='wait.c' -else -filename=$1 -fi -time find $mntpnt/linux-3.11.10 -name $filename>/dev/null 2>&1 diff --git a/buildheader/benchmarks/micro/rename/Makefile b/buildheader/benchmarks/micro/rename/Makefile deleted file mode 100644 index 4941d906b..000000000 --- a/buildheader/benchmarks/micro/rename/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -ARCH ?= x86_64 - -ifeq "$(ARCH)" "i386" -ARCH_OPT := -m32 -else ifeq "$(ARCH)" "x86_64" -ARCH_OPT := -m64 -else -ARCH_OPT = $(error "not supported architecture") -endif - -ALL = rename_test - -all: ${ALL} - -.c: $@.c - gcc $(ARCH_OPT) -Wall -o $@ $@.c - -bench-rename: - touch /mnt/benchmarks/file1 - touch /mnt/benchmarks/file2 - /bin/bash -c 'time ./rename_test /mnt/benchmarks/file1 /mnt/benchmarks/file2 500000' - -clean: - rm -f *~ - for i in $(ALL); do \ - rm -f $$i; \ - done; - diff --git a/buildheader/benchmarks/micro/rename/clean-mount.sh b/buildheader/benchmarks/micro/rename/clean-mount.sh deleted file mode 100755 index c889b3b81..000000000 --- a/buildheader/benchmarks/micro/rename/clean-mount.sh +++ /dev/null @@ -1,2 +0,0 @@ -../../cleanup-fs.sh -../../setup-ftfs.sh diff --git a/buildheader/benchmarks/micro/rename/rename.sh b/buildheader/benchmarks/micro/rename/rename.sh deleted file mode 100755 index 54f869121..000000000 --- a/buildheader/benchmarks/micro/rename/rename.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -set -x -FT_HOMEDIR=/home/ftfs/ft-index -. $FT_HOMEDIR/benchmarks/fs-info.sh -if [ -d $mntpnt/linux-3.11.10 ]; then -: -else -. $FT_HOMEDIR/benchmarks/micro/prepare-support-file.sh -fi -(cd $FT_HOMEDIR/benchmarks/; sudo ./clear-fs-caches.sh) -if [ "$1" = "" ] -then -copydir=copydir -else -copydir=$1 -fi -#mkdir $mntpnt/$copydir>/dev/null 2>&1 -#if [ $? -ne 0 ]; then -# echo "failed to create the $copydir, exiting..." -#else -ls $mntpnt - time mv $mntpnt/linux-3.11.10 $mntpnt/$copydir>/dev/null 2>&1 -#fi diff --git a/buildheader/benchmarks/micro/rename/rename_test.c b/buildheader/benchmarks/micro/rename/rename_test.c deleted file mode 100644 index a89522fe8..000000000 --- a/buildheader/benchmarks/micro/rename/rename_test.c +++ /dev/null @@ -1,52 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -int main(int argc, char **argv) -{ - char *file1; - char *file2; - int count = 0; - int ret = 0; - - if (argc == 1) { - file1 = "/mnt/benchmarks/file1"; - file2 = "/mnt/benchmarks/file2"; - count = 500000; - } else if(argc < 4){ - printf("use: rename-test file1 file2 count\n"); - return 0; - } else { - file1 = argv[1]; - file2 = argv[2]; - count = atoi(argv[3]); - } - - printf("file1: %s, file2: %s, count: %d\n", file1, file2, count); - - while(count >= 0){ - - if(count % 2){ - ret = rename(file1, file2); - if (ret) { - printf("rename error: %d\n", errno); - return ret; - } - } else { - ret = rename(file2, file1); - if (ret) { - printf("rename error: %d\n", errno); - return ret; - } - } - - count--; - } - - return 0; -} diff --git a/buildheader/benchmarks/micro/space-overhead/disk-usage.sh b/buildheader/benchmarks/micro/space-overhead/disk-usage.sh deleted file mode 100755 index cbbfe0364..000000000 --- a/buildheader/benchmarks/micro/space-overhead/disk-usage.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash - -exe="../lmbench-3/bin/x86_64-linux-gnu/lmdd" - -if [ ! -e $exe ] ; then - echo "Stop! You must run 'make' in ../lmbench-3 first!" - exit 1 -fi - -if [ -z "$1" ] ; then - echo "Usage: $0 " - exit 1 -fi -gcc generate-file.c -o generate-file -# benchmark parameters -io_size=4096 -mnt="/mnt/benchmark" -input="test.file" - -#f_size=$((1024*1024)) -#f_size=$((1024*1024*1024)) -f_size=($((1024*10)) $((1024*1024)) $((1024*1024*10)) $((1024*1024*100)) $((1024*1024*1024))) - -green='\033[0;32m' -NC='\033[0m' # No Color - -for file_size in ${f_size[@]}; do -#set -x -sudo ../../cleanup-fs.sh -sudo rm -rf $mnt -sudo ../../setup-$1.sh >> /dev/null - -echo "Generating file" -./generate-file $file_size $mnt/$input #uses urandom -#ls -l $mnt >> /dev/null #to initiate flush -#sleep 3 -#stdbuf -o0 head -c $file_size /dev/urandom | stdbuf -i0 -o0 tee $mnt/$input > /dev/null -#$exe if=internal of=$mnt/$input bs=$io_size count=$(($file_size / $io_size)) opat=1 fsync=1 -sync -df --sync $mnt -echo "du" -sudo du -ah $mnt -usage=$(df $mnt --sync | sed 's/ */ /g' | cut -d$'\n' -f2 | cut -d ' ' -f3) -sudo df --sync $mnt -#usage=$(df $mnt --sync | sed 's/ */ /g' | cut -d$'\n' -f2 | cut -d ' ' -f3) -echo -e "${green}filesize(K), usage(K), overhead(K)${NC}" -echo -e "${green}$(($file_size / 1024)), ${usage}, $((-$file_size / 1024 + $usage))${NC}" -done diff --git a/buildheader/benchmarks/micro/space-overhead/generate-file.c b/buildheader/benchmarks/micro/space-overhead/generate-file.c deleted file mode 100644 index 80bc2549c..000000000 --- a/buildheader/benchmarks/micro/space-overhead/generate-file.c +++ /dev/null @@ -1,34 +0,0 @@ -#include -#include -#include -#include -#include -int main(int argc, char *argv[]) -{ - - char buffer[1024*1024]; - long count = atol(argv[1])/(1024*1024), i; - int bytesleft = atol(argv[1])%(1024*1024); - int fp, rand; - - rand= open(argv[2], O_WRONLY | O_SYNC | O_CREAT, 0777); - if(rand < 0 ){ - perror("Error in opening file"); - exit(1); - } - fp = open("/dev/urandom", O_RDONLY, 0777); - // printf("count:%ld", count); - for(i = 0; i < count; i++) - { - read(fp, buffer, 1024*1024); - write(rand, buffer, 1024*1024); - } - if(bytesleft > 0) - { - read(fp, buffer, bytesleft); - write(rand, buffer, bytesleft); - } - fsync(rand); - close(rand); - close(fp); -} diff --git a/buildheader/benchmarks/micro/space-overhead/many-files.sh b/buildheader/benchmarks/micro/space-overhead/many-files.sh deleted file mode 100755 index 2778d1ac4..000000000 --- a/buildheader/benchmarks/micro/space-overhead/many-files.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash - -exe="../lmbench-3/bin/x86_64-linux-gnu/lmdd" - -if [ ! -e $exe ] ; then - echo "Stop! You must run 'make' in ../lmbench-3 first!" - exit 1 -fi - -if [ -z "$1" ] ; then - echo "Usage: $0 " - exit 1 -fi -gcc generate-file.c -o generate-file -# benchmark parameters -io_size=4096 -mnt="/mnt/benchmark" -input="test.file" -f_size=($((1024*10)) $((1024*1024)) $((1024*1024*10)) $((1204*1024*100)) $((1024*1024*1024))) -t_size=0; -green='\033[0;32m' -NC='\033[0m' # No Color - -sudo ../../cleanup-fs.sh -sudo rm -rf $mnt -sudo ../../setup-$1.sh >> /dev/null - -echo "Generating files" -for file_size in ${f_size[@]}; do -#set -x -t_size=$((t_size + file_size)) -./generate-file $file_size $mnt/$input$file_size #uses urandom -done -#ls -l $mnt >> /dev/null #to initiate flush -#sleep 3 -#stdbuf -o0 head -c $file_size /dev/urandom | stdbuf -i0 -o0 tee $mnt/$input > /dev/null -#$exe if=internal of=$mnt/$input bs=$io_size count=$(($file_size / $io_size)) opat=1 fsync=1 -usage=$(df $mnt | sed 's/ */ /g' | cut -d$'\n' -f2 | cut -d ' ' -f3) -echo -e "${green}filesize(K), usage(K), overhead(K)${NC}" -echo -e "${green}$(($t_size / 1024)), ${usage}, $((-$t_size / 1024 + $usage))${NC}" - diff --git a/buildheader/benchmarks/micro/space-overhead/run-rsync.sh b/buildheader/benchmarks/micro/space-overhead/run-rsync.sh deleted file mode 100755 index bb5f0be12..000000000 --- a/buildheader/benchmarks/micro/space-overhead/run-rsync.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -. ../../fs-info.sh -. ../../.ismounted - -if [ -z "$1" ] ; then - echo "Usage: $0 " - exit 1 -fi - -support=$HOME/$repo/benchmarks/support-files -src=linux-3.11.10 -dst=rsynced -dst2=rsynced2 -copypos=temploc - -if [ ! -e $support/$src ]; then - cd $support; tar -xf $src.tar.xz; cd - -fi - -sudo ../../cleanup-fs.sh -sudo rm -rf $mntpnt -sudo ../../setup-$1.sh >> /dev/null - -#echo 'Copy from home to benchmark partition' -#sudo perf record -g -- rsync --stats -r -t -S -h $support/$src $mntpnt/$dst -#strace -c -T rsync --stats -r -t -S -h $support/$src $mntpnt/$dst 2&> strace.txt -#rsync --stats -r -t -S -h $support/$src $mntpnt/$dst -l_size=$(rsync --stats -r -t -W -h --inplace $support/$src $mntpnt/$dst | tail -n 1 | sed 's/ */ /g' | cut -d ' ' -f4 | cut -d 'M' -f1) -l_size=$(echo "$l_size*1024" | bc) - -usage=$(df $mntpnt | sed 's/ */ /g' | cut -d$'\n' -f2 | cut -d ' ' -f3) -echo -e "${green}filesize(K), usage(K), overhead(K)${NC}" -overhead=$(echo "$usage - $l_size" | bc) -echo -e "${green}$l_size, ${usage}, $overhead${NC}" diff --git a/buildheader/benchmarks/micro/space-overhead/sequential_write b/buildheader/benchmarks/micro/space-overhead/sequential_write deleted file mode 120000 index 27afc65b5..000000000 --- a/buildheader/benchmarks/micro/space-overhead/sequential_write +++ /dev/null @@ -1 +0,0 @@ -../large-file/sequential_write \ No newline at end of file diff --git a/buildheader/benchmarks/micro/space-overhead/test-whole.sh b/buildheader/benchmarks/micro/space-overhead/test-whole.sh deleted file mode 100755 index 8917f155f..000000000 --- a/buildheader/benchmarks/micro/space-overhead/test-whole.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash - -#gcc -g ../large-file/sequential_write.c -o ../large-file/sequential_write -lrt - - -exe="./sequential_write" - -if [ -z "$1" ] ; then - echo "Usage: $0 " - exit 1 -fi -if [ ! -e $exe ] ; then - #echo "Stop! You must run 'make' in ../lmbench-3 first!" - echo "Stop! You must run 'make' first!" - exit 1 -fi -#sudo ../../cleanup-fs.sh -#sudo rm -rf $mnt -sudo ../../setup-$1.sh - - -f_size=$((1024*1024*1024)) -mnt="/mnt/benchmark" -write_size=40960 -random_buffers=5 -i=0 -while [ $i -lt 64 ]; do - sudo $exe -o$mnt/$i -b$write_size -n$random_buffers -s$f_size - let i=i+1 - done - -sudo ../../cleanup-fs.sh -sudo mount -t ext4 /dev/sda6 /mnt -sudo df /mnt/ -sudo ../../setup-ftfs.sh - -let i=0 -while [ $i -lt 32 ]; do - sudo rm $mnt/$i - let i=i+1 - done - -sudo ../../cleanup-fs.sh -sudo mount -t ext4 /dev/sda6 /mnt -sudo df /mnt/ diff --git a/buildheader/benchmarks/micro/tokubench/.gitignore b/buildheader/benchmarks/micro/tokubench/.gitignore deleted file mode 100644 index 8e91b4c4d..000000000 --- a/buildheader/benchmarks/micro/tokubench/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -benchmark-compress -benchmark-fs -benchmark-fs-threaded \ No newline at end of file diff --git a/buildheader/benchmarks/micro/tokubench/Makefile b/buildheader/benchmarks/micro/tokubench/Makefile deleted file mode 100644 index 9345d4335..000000000 --- a/buildheader/benchmarks/micro/tokubench/Makefile +++ /dev/null @@ -1,40 +0,0 @@ -CC = gcc -LD = gcc - -CFLAGS += -Wall -Wextra -Wshadow #-Werror -CFLAGS += -Wmissing-prototypes -Wmissing-declarations -CFLAGS += -std=c99 - -ifeq ($(DEBUG), 1) - CFLAGS += -g3 -O0 -DDEBUG -else - CFLAGS += -g3 -O3 -ifeq ($(FLTO), 1) - CFLAGS += -flto - LDFLAGS += -flto -endif -endif - -INCDIR=. - -CPPFLAGS += -I$(INCDIR) -D_GNU_SOURCE -LDLIBS += -pthread - -OBJECTS := $(patsubst %.c, %, $(wildcard *.c)) -# threadpool is not going to be target -TARGETS := $(patsubst threadpool, , $(OBJECTS)) - -.PHONY: all clean - -all: $(TARGETS) - -# override the default so we can depend on threadpool.o -benchmark-fs-threaded: benchmark-fs-threaded.c threadpool.c - $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@ - - -tidy: - rm -rf *.mount - -clean: tidy - rm -rf $(TARGETS) benchmark-bucket diff --git a/buildheader/benchmarks/micro/tokubench/README b/buildheader/benchmarks/micro/tokubench/README deleted file mode 100644 index 1591d9e44..000000000 --- a/buildheader/benchmarks/micro/tokubench/README +++ /dev/null @@ -1 +0,0 @@ -These are modified micro-benchmarks from the hotstorage paper. \ No newline at end of file diff --git a/buildheader/benchmarks/micro/tokubench/benchmark-compress.c b/buildheader/benchmarks/micro/tokubench/benchmark-compress.c deleted file mode 100644 index ea9ba1b77..000000000 --- a/buildheader/benchmarks/micro/tokubench/benchmark-compress.c +++ /dev/null @@ -1,248 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "tokufs.h" - -#define TOKUFS_MOUNT "compress-bench.mount" - -static int verbose; -static int help; -static int use_posix; - -static char * input_file; -static char * output_file = "compress-bench.out"; - -#define MIN(a, b) ((a) < (b) ? (a) : (b)) - -#define echo(...) \ - do { \ - printf(__VA_ARGS__); \ - fflush(stdout); \ - } while(0) - -static struct option long_options[] = -{ - {"verbose", no_argument, &verbose, 1}, - {"help", no_argument, &help, 1}, - {"use-ufs", no_argument, &use_posix, 1}, - {"input-file", required_argument, NULL, 'f'}, - {"output-file", required_argument, NULL, 'o'}, -}; -static char * opt_string = "vhuf:o:"; - -static void usage(void) -{ - printf( - "usage:\n" - " -v, --verbose\n" - " enable verbose output.\n" - " -h, --help\n" - " print this help and quit.\n" - " -u, --use-ufs\n" - " perform benchmark on the underlying file system\n" - " -f, --input-file\n" - " input file name.\n" - " -o, --input-file\n" - " output file name.\n" - ); -} - -static int parse_args(int argc, char * argv[]) -{ - int i, c; - - while ((c = getopt_long(argc, argv, - opt_string , long_options, &i)) != -1) { - switch (c) { - case 0: - break; - case 'f': - if (strlen(optarg) == 0) { - fprintf(stderr, "invalid file name\n"); - return 1; - } - input_file = strdup(optarg); - break; - case 'h': - help = 1; - break; - case 'o': - if (strlen(optarg) == 0) { - fprintf(stderr, "invalid file name\n"); - return 1; - } - output_file = strdup(optarg); - break; - case 'u': - use_posix = 1; - break; - case 'v': - verbose = 1; - break; - case '?': - default: - return 1; - } - } - - return 0; -} - -/** - * Get the current time in microseconds - */ -static long current_time_usec(void) -{ - struct timeval t; - gettimeofday(&t, NULL); - return t.tv_usec + t.tv_sec * 1000000; -} - -/** - * Make it so that switching between tokufs and ufs - * is transparent to the benchmarking code. - * - * We then define each benchmark function in terms of - * benchmark file struct - */ -struct benchmark_file -{ - int (*open)(const char * path, int flags, ...); - int (*close)(int fd); - ssize_t (*pwrite)(int fd, const void * buf, - size_t count, off_t offset); - ssize_t (*pread)(int fd, void * buf, - size_t count, off_t offset); - int (*fsync)(int fd); -}; - -static int posix_sync_and_close(int fd) -{ - int ret; - ret = fsync(fd); - assert(ret == 0); - ret = close(fd); - assert(ret == 0); - return ret; -} - -static struct benchmark_file posix_file = -{ - .open = open, - .close = posix_sync_and_close, - .pwrite = pwrite, - .pread = pread -}; - -struct input_file_info { - char * buf; - size_t size; -}; - -static void read_input_file_into_memory( - struct input_file_info * info) -{ - int ret, fd; - struct stat st; - - fd = open(input_file, O_RDONLY); - if (fd < 0 && errno == ENOENT) { - printf("can't find input file %s\n", input_file); - exit(1); - } - assert(fd >= 0); - ret = fstat(fd, &st); - assert(ret == 0); - info->size = st.st_size; - assert(info->size > 0); - info->buf = malloc(info->size); - if (info->buf == NULL) { - printf("couldn't allocate %ld bytes to bring " - " the file into memory\n", info->size); - exit(1); - } - ret = pread(fd, info->buf, info->size, 0); - assert(ret == (int) info->size); - ret = close(fd); - assert(ret == 0); -} - -static long run_benchmark(struct benchmark_file * file) -{ - const int pagesize = getpagesize(); - int ret, fd; - long start, write_time; - struct input_file_info file_info; - size_t bytes_written = 0; - - printf("reading file into memory...\n"); - read_input_file_into_memory(&file_info); - - printf("writing output file...\n"); - start = current_time_usec(); - int flags = O_CREAT | O_TRUNC | O_WRONLY; - fd = file->open(output_file, flags, 0644); - assert(fd >= 0); - - while (bytes_written < file_info.size) { - const int iosize = 8 * pagesize; - const int bytes_left = file_info.size - bytes_written; - int write_size = MIN(bytes_left, iosize); - ssize_t n = file->pwrite(fd, file_info.buf + bytes_written, - write_size, bytes_written); - if (n != write_size) { - printf("wrote %ld bytes, wanted %d, errno %d\n", n, write_size, errno); - } - assert(n == write_size); - bytes_written += n; - } - - ret = file->close(fd); - assert(ret == 0); - write_time = current_time_usec() - start; - printf("done.\n"); - printf("time %ld usec, %lf MBs/sec\n", - write_time, file_info.size / (write_time * 1.0)); - - free(file_info.buf); - return write_time; -} - -int main(int argc, char * argv[]) -{ - int ret; - struct benchmark_file * file; - - ret = parse_args(argc, argv); - if (ret != 0 || help) { - usage(); - exit(ret); - } - - ret = toku_fs_set_cachesize(64L * 1024 * 1024); - assert(ret == 0); - - echo("compression benchmark\n"); - echo(" * input file: %s\n", input_file); - echo(" * output file: %s\n", output_file); - echo(" * file op interface: %s\n", use_posix ? "posix" : "tokufs"); - echo(" * pagesize: %lu\n", - use_posix ? (size_t) getpagesize() : toku_fs_get_blocksize()); - echo(" * verbose? %s\n", verbose ? "yes" : "no"); - - file = &posix_file; - - run_benchmark(file); - - return 0; -} diff --git a/buildheader/benchmarks/micro/tokubench/benchmark-fs-threaded.c b/buildheader/benchmarks/micro/tokubench/benchmark-fs-threaded.c deleted file mode 100644 index 63eefc852..000000000 --- a/buildheader/benchmarks/micro/tokubench/benchmark-fs-threaded.c +++ /dev/null @@ -1,913 +0,0 @@ -/** - * TokuFS - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -//#include -//#include -//#include - -#include "threadpool.h" - -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#define MAX(a, b) ((a) > (b) ? (a) : (b)) - -#define progress_printf(...) do { printf(__VA_ARGS__); fflush(stdout); } while(0) - -int toku_debug; - -static int verbose; -static int report_progress; -static int help; - -static char * benchmark_root_dir = "benchmark-bucket"; -static size_t iosize = 512; -static size_t cachesize = 512L * 1024 * 1024; - -static int num_files = 1; -static int num_threads = 1; -static int num_operations = 1; -static int directory_max_children = 100; -static int file_read_flags = O_RDONLY; -static int file_write_flags = O_CREAT | O_WRONLY; - -// do serial pwrites by default -static int do_pwrite = 1; -static int do_serial = 1; -static int do_scan = 0; - -static struct option long_options[] = -{ - {"verbose", no_argument, &verbose, 1}, - {"progress", no_argument, &report_progress, 1}, - {"help", no_argument, &help, 1}, - {"dir", required_argument, NULL, 'f'}, - {"cachesize", required_argument, NULL, 'c'}, - {"files", required_argument, NULL, 'n'}, - {"children", required_argument, NULL, 'd'}, - {"threads", required_argument, NULL, 'm'}, - {"iosize", required_argument, NULL, 'b'}, - {"operations", required_argument, NULL, 'x'}, - {"scan", no_argument, &do_scan, 1}, - {"serial", no_argument, &do_serial, 1}, - {"random", no_argument, &do_serial, 0}, - {"pwrite", no_argument, &do_pwrite, 1}, - {"pread", no_argument, &do_pwrite, 0}, -}; -static char * opt_string = "vhc:f:s:n:d:m:b:x:"; - -static void usage(void) -{ - printf( - "usage:\n" - " -v, --verbose\n" - " enable verbose output.\n" - " -p, --progress\n" - " enable progress reporting, showing throughput at 20 intervals.\n" - " -h, --help\n" - " print this help and quit.\n" - " -f, --dir\n" - " directory where the benchmark should take place.\n" - " -c, --cachesize\n" - " set the cache size (MB) for tokufs runs. default 512\n" - " -n, --files\n" - " number of files to operate on. default 1.\n" - " -d, --children\n" - " maximum number of children in a single directory. default 100.\n" - " -m, --threads\n" - " number of concurrent threads. default 1.\n" - " -b, --iosize\n" - " size of each thread's read or write thread_operation. default 512.\n" - " -x, --operations\n" - " number of operations per thread. default 1.\n" - " -s, --scan\n" - " just perform a metadata scan on an existing benchmark-bucket\n" - " --serial\n" - " perform sequential IO on each file. default.\n" - " --random\n" - " perform random IO on each file\n" - " --pwrite\n" - " perform pwrites on each file\n" - " --pread\n" - " perform preads on each file\n" - ); -} - -static int parse_args(int argc, char * argv[]) -{ - int i, c; - long n; - - while ((c = getopt_long(argc, argv, - opt_string, long_options, &i)) != -1) { - switch (c) { - case 'v': - verbose = 1; - break; - case 'p': - report_progress = 1; - break; - case 'h': - help = 1; - break; - case 'f': - if (strlen(optarg) == 0) { - printf("invalid root directory\n"); - return 1; - } - benchmark_root_dir = optarg; - break; - case 'c': - n = atol(optarg); - if (n <= 32) { - printf("cachesize shouldn't be less than 32mb\n"); - return 1; - } - cachesize = n * 1024 * 1024L; - break; - case 'n': - n = atol(optarg); - if (n <= 0) { - printf("need to operate on at least one file\n"); - return 1; - } - num_files = n; - break; - case 'd': - n = atol(optarg); - if (n <= 0) { - printf("need at least one file per directory\n"); - return 1; - } - directory_max_children = n; - break; - case 'm': - n = atol(optarg); - if (n <= 0) { - printf("need to use at least one thread\n"); - return 1; - } - num_threads = n; - break; - case 'b': - n = atol(optarg); - if (n <= 0) { - printf("io size needs to be > 0\n"); - return 1; - } - iosize = n; - break; - case 'x': - n = atol(optarg); - if (n < 0) { - printf("number of operations needs to be >= 0.\n" - "0 means only open and close files\n"); - return 1; - } - num_operations = n; - break; - case 0: - break; - case '?': - printf("?\n"); - default: - return 1; - } - } - - return 0; -} - -/** - * file operation interface used by benchmark threads. should - * make it easy to switch between the posix and tokufs interface. - */ -struct benchmark_file_ops -{ - int (*open)(const char * path, int flags, ...); - int (*close)(int fd); - ssize_t (*pwrite)(int fd, const void * buf, size_t count, off_t offset); - ssize_t (*pread)(int fd, void * buf, size_t count, off_t offset); - int (*unlink)(const char * path); - int (*mkdir)(const char * path, mode_t mode); - int (*rmdir)(const char * path); -}; - -static struct benchmark_file_ops posix_file = -{ - .open = open, - .close = close, - .pwrite = pwrite, - .pread = pread, - .unlink = unlink, - .mkdir = mkdir, - .rmdir = rmdir -}; - -/** - * Generate a random long - */ -static long toku_random_long(void) -{ - long r1, r2; - - r1 = rand(); - r2 = rand(); - - return r1 | (r2 << 32); -} - -static char * generate_random_name(const char * parent) -{ - char * filename = malloc(strlen(parent) + 50); - uint64_t k = toku_random_long(); - sprintf(filename, "%s/benchfile.%lu", parent, k); - return filename; -} - -static char * generate_subdir_name(const char * parent, int i) -{ - char * subdir = malloc(strlen(parent) + 50); - sprintf(subdir, "%s/benchdir.%d", parent, i); - return subdir; -} - -struct leaf_directories { - char ** array; - int num_entries; - int capacity; -}; - -static void shuffle_leaf_directories(struct leaf_directories * leaves) -{ - for (int i = leaves->num_entries - 1; i > 0; i--) { - // the knuth shuffle. swap i with some random index in [0, i] - long r = toku_random_long() % (i + 1); - char * tmp = leaves->array[i]; - leaves->array[i] = leaves->array[r]; - leaves->array[r] = tmp; - } -} - -static void add_leaf_directory(struct leaf_directories * leaves, - const char * leaf) -{ - // if we're full, double the capacity and realloc - // this is just easy to do. hopefully it doesn't result - // in resident set explosion when there are many leaves. - if (leaves->num_entries == leaves->capacity) { - leaves->capacity *= 2; - size_t new_size = sizeof(char *) * leaves->capacity; - leaves->array = realloc(leaves->array, new_size); - assert(leaves->array != NULL); - } - assert(leaves->num_entries < leaves->capacity); - leaves->array[leaves->num_entries++] = strdup(leaf); -} - -static void free_leaf_directories(struct leaf_directories * leaves) -{ - for (int i = 0; i < leaves->num_entries; i++) { - free(leaves->array[i]); - } - free(leaves->array); -} - -static void create_directory_tree_structure(struct benchmark_file_ops * file_ops, - const char * parent, int n, struct leaf_directories * leaves) -{ - // if this parent directory needs to be created with less than - // the max number of children for a directory, then it is going - // to be a leaf in the structure. add it to the array of leaves - // and be done. - if (n <= directory_max_children) { - add_leaf_directory(leaves, parent); - return; - } - - // create directory_max_children in this directory and - // divide the files amongst them. - const int files_per_child = n / directory_max_children; - const int remaining_files = n % directory_max_children; - for (int i = 0; i < directory_max_children && n > 0; i++) { - int files_this_child; - char * subdir = generate_subdir_name(parent, i); - if (n < directory_max_children) { - // if there are less files to create than the max - // for one child, give it all to the child - files_this_child = n; - } else if (files_per_child < directory_max_children) { - // there are enough files to fill at least one child, - // but not all of them, so max out this child. - files_this_child = directory_max_children; - } else { - // there are enough files to fill all of the children. - // give them each a fair share and dish out the remainder - // on a first come first serve basis. - files_this_child = files_per_child; - files_this_child += i < remaining_files ? 1 : 0; - } - - assert(n >= files_this_child); - int ret = file_ops->mkdir(subdir, 0777); - assert(ret == 0); - // recursively create a directory tree rooted at - // the current subdir with the given number of children - create_directory_tree_structure(file_ops, subdir, - files_this_child, leaves); - free(subdir); - n -= files_this_child; - } - // maintain the invariant that all files were given out. - // the loop breaks if n == 0 or if all children have - // been created. - assert(n == 0); -} - -/** - * Get the current time in microseconds - */ -static long toku_current_time_usec(void) -{ - struct timeval t; - gettimeofday(&t, NULL); - return t.tv_usec + t.tv_sec * 1000000; -} - - -struct benchmark_directory_scan_info { - uint64_t num_files; - size_t total_size; -}; - -// call me once to initialize. call me again to track progress. -static void maybe_report_directory_scan_progress(int files_so_far, int * stop) -{ - // only check every 2000 files. that is as long as 10 second - // on a slow file system. - const int check_interval = 2000; - const long time_interval = 60 * 1000 * 1000L; - const long timeout = 60 * 60 * 1000 * 1000L; - static long start, last_progress_report; - if (last_progress_report == 0) { - last_progress_report = toku_current_time_usec(); - start = last_progress_report; - return; - } - if (files_so_far > 0 && files_so_far % check_interval == 0) { - long now = toku_current_time_usec(); - if (now - last_progress_report > time_interval) { - progress_printf("* progress: scanned %d files in %ld usec, %lf files/second\n", - files_so_far, now - start, - files_so_far / ((now - start) / 1000000.0)); - last_progress_report = now; - } - // if it's been more than the timeout, let the caller - // know it should stop - it's been running long enough. - if (now - start > timeout) { - *stop = 1; - } else { - *stop = 0; - } - } -} - -static void benchmark_directory_scan_helper(char * parent, - struct benchmark_directory_scan_info * info) -{ - int ret; - DIR * dir; - struct dirent * entry; - struct stat st; - - // opendir can come back with ENFILES if our recursion - // goes too deep, but it shouldn't. - dir = opendir(parent); - assert(dir != NULL); - ret = chdir(parent); - assert(ret == 0); - - // call it once to initialize the timers. - maybe_report_directory_scan_progress(0, NULL); - int stop = 0; - while ((entry = readdir(dir)) != NULL && !stop) { - // skip self and parent - if (strcmp(entry->d_name, ".") == 0 || - strcmp(entry->d_name, "..") == 0) { - continue; - } - - int child_fd = open(entry->d_name, O_RDONLY); - assert(child_fd >= 0); - ret = fstat(child_fd, &st); - assert(ret == 0); - close(child_fd); - if (S_ISDIR(st.st_mode)) { - benchmark_directory_scan_helper(entry->d_name, info); - } else { - info->total_size += st.st_size; - } - info->num_files++; - // this will report our progress on a reasonable interval, - // and tell us whether or not we should stop because - // we've taken too long. - maybe_report_directory_scan_progress(info->num_files, &stop); - } - - ret = chdir(".."); - assert(ret == 0); - ret = closedir(dir); - assert(ret == 0); -} - -static void benchmark_directory_scan(struct benchmark_directory_scan_info *info) -{ - // here we smash the file_ops abstraction, because it doesn't - // provide a consistent way of reading directories. that's - // because tokufs has its own directory api. - memset(info, 0, sizeof(*info)); - benchmark_directory_scan_helper(benchmark_root_dir, info); -} - -enum thread_operation { - RANDOM_PREAD, - SERIAL_PREAD, - RANDOM_PWRITE, - SERIAL_PWRITE, -}; - -static int thread_operation_is_writing(enum thread_operation op) -{ - return op == SERIAL_PWRITE || op == RANDOM_PWRITE; -} - -static int should_report_file_io_progress(int operation_num) -{ - const int interval = 20; - if (!report_progress || operation_num < interval) { - // don't if progress reporting is off or thread_operation is too low - return 0; - } else if (operation_num == num_operations) { - // do it for the last thread_operation, for accurate terminal throughput - return 1; - } else { - // otherwise do it on some evenly spaced interval. - return operation_num % (num_operations / interval) == 0; - } -} - - -static int toku_gettid(void) -{ - // too much hassle getting syscall to prototype correctly - return syscall(SYS_gettid); -} - -// HACK should be replaced by a struct benchmark_info that -// is contained in benchmark_thread_info -static long benchmark_start_time; -static void maybe_report_file_io_progress(enum thread_operation op, - int operation_num) -{ - if (should_report_file_io_progress(operation_num)) { - // adding 1 is a shameless hack to avoid start == now - long elapsed_time = toku_current_time_usec()+1 - benchmark_start_time; - size_t num_bytes = operation_num * iosize; - progress_printf("* progress: thread [%d] %s %lu bytes so far, %lf\n", - toku_gettid(), - thread_operation_is_writing(op) ? "wrote" : "read", - num_bytes, num_bytes * 1.0f / elapsed_time); - } -} - -static void maybe_report_file_create_progress(int i) -{ - const int interval = 10000; - static int files_created; - static long start, last_progress_report; - if (last_progress_report == 0) { - last_progress_report = toku_current_time_usec(); - start = last_progress_report; - return; - } - // when some thread has reached a multiple of interval - // files created, record it and report overall progress. - if (i > 0 && i % interval == 0) { - long elapsed_time = toku_current_time_usec() - start; - (void) __sync_fetch_and_add(&files_created, interval); - progress_printf("* progress: %d files, %lf files/sec\n", - files_created, - files_created / (elapsed_time / 1000000.0)); - } -} - -struct benchmark_thread_info { - enum thread_operation op; - int num_files; - char ** directories; - int num_directories; - const struct benchmark_file_ops * file_ops; -}; - -static struct benchmark_thread_info * benchmark_thread_info_create( - enum thread_operation op, int nfiles, - char ** directories, int num_directories, - const struct benchmark_file_ops * file_ops) -{ - struct benchmark_thread_info * info; - info = malloc(sizeof(struct benchmark_thread_info)); - info->op = op; - info->file_ops = file_ops; - info->directories = directories; - info->num_directories = num_directories; - info->num_files = nfiles; - return info; -} - -static char * get_write_buf(void) -{ - static char * random_buf; - static const size_t random_buf_size = 16L * 1024 * 1024; - assert(iosize < random_buf_size); - // initialize the random buffer if it is not already - if (random_buf == NULL) { - assert(random_buf_size % sizeof(uint64_t) == 0); - random_buf = malloc(random_buf_size); - assert(random_buf != NULL); - for (unsigned i = 0; i < random_buf_size / sizeof(uint64_t); i++) { - uint64_t * b = (uint64_t *) random_buf; - b[i] = toku_random_long(); - } - } - // then give out a random index into the buffer - // from 0 to the size of the random buffer, minus the iosize. - uint64_t r = toku_random_long() % (random_buf_size - iosize); - return &random_buf[r]; -} - -static void benchmark_thread(void * arg) -{ - int fd, ret; - struct benchmark_thread_info * info = arg; - - for (int i = 0; i < info->num_files; i++) { - // create the necessary number of files evently over - // the number of directories by choosing the i'th directory - // in a cicular loop over the directories array - const char * parent = info->directories[i % info->num_directories]; - char * filename = generate_random_name(parent); - - fd = info->file_ops->open(filename, - thread_operation_is_writing(info->op) ? - file_write_flags : file_read_flags, 0644); - if (fd < 0) { - int e = errno; - printf("couldn't create file %s, ret %d, errno %d\n", - parent, fd, e); - exit(fd); - } - assert(fd >= 0); - free(filename); - - // do the file IO, if necessary - for (int j = 0; j < num_operations; j++) { - int k = j; - ssize_t n, expected = iosize; - char * buf = get_write_buf(); - switch (info->op) { - case RANDOM_PREAD: - k = toku_random_long() % num_operations + j; - case SERIAL_PREAD: - n = info->file_ops->pread(fd, buf, iosize, k * iosize); - break; - case RANDOM_PWRITE: - k = toku_random_long() % num_operations + j; - case SERIAL_PWRITE: - n = info->file_ops->pwrite(fd, buf, iosize, k * iosize); - break; - default: - assert(0); - } - assert(n == expected); - - maybe_report_file_io_progress(info->op, j); - } - ret = info->file_ops->close(fd); - assert(ret == 0); - - maybe_report_file_create_progress(i); - } - - free(info); -} - -static void do_meta_scan(void) -{ - long start, end; - printf("Scanning the entire directory tree, counting children, total size\n"); - - start = toku_current_time_usec(); - struct benchmark_directory_scan_info scan_info; - benchmark_directory_scan(&scan_info); - end = toku_current_time_usec(); - - assert(scan_info.num_files > 0); - printf("scanned %ld files in %ld usec, %lf files/second\n", - scan_info.num_files, end - start, - scan_info.num_files / ((end - start) / 1000000.0)); - printf("total size of all files not including metadata %lu\n", - scan_info.total_size); -} - -static void run_benchmarks(struct benchmark_file_ops * file_ops) -{ - int ret; - struct threadpool tp; - enum thread_operation op; - long start; - - // XXX still ugly, but better - if (do_scan) { - do_meta_scan(); - return; - } - - ret = toku_threadpool_init(&tp, num_threads); - - assert(ret == 0); - if (do_pwrite) { - op = do_serial ? SERIAL_PWRITE : RANDOM_PWRITE; - } else { - op = do_serial ? RANDOM_PREAD : RANDOM_PREAD; - } - - const char * parent = benchmark_root_dir; - - // first create the directory structure and record all - // the leaf directories the benchmark will put its - // files into. - struct leaf_directories leaves = { - .array = malloc(sizeof(char *) * 8), - .capacity = 8, - .num_entries = 0 - }; - - // create the top level directory, then create the structure - // underneath it - ret = file_ops->mkdir(parent, 0777); - if (ret != 0) { - int e = errno; - printf("couldn't make directory %s, ret %d, errno %d\n", - parent, ret, e); - exit(ret); - } - assert(ret == 0); - create_directory_tree_structure(file_ops, parent, - num_files, &leaves); - - printf("created directory structure with %d leaves\n", - leaves.num_entries); - - // shuffle the leaf directories so when we iterate over - // them, it is random. - shuffle_leaf_directories(&leaves); - - // to help maintain invariants - int total_files = 0; - int total_directories = 0; - - // call this once to initialize interal timers and counters - maybe_report_file_create_progress(0); - start = toku_current_time_usec(); - - struct benchmark_thread_info * info; - char ** directories = NULL; - for (int i = 0; i < num_threads; i++) { - // each thread will create its share of files in some subset - // of the the leaf directories. determine which directories - // this thread will operate over. - // - // the outcome of this condition is the same at every - // iteration of the loop. the code probably wouldn't work otherwise - int num_directories; - if (num_threads > leaves.num_entries) { - // there are more threads than directories, so we will give - // each thread one directory. the directory given is the - // i'th directory in a cicular loop over the leaves - num_directories = 1; - directories = &leaves.array[i % leaves.num_entries]; - // record this only if we haven't used the directory yet - total_directories += i < leaves.num_entries ? 1 : 0; - } else { - // there are at least as many directories as threads, so we - // can give each thread its divided share. - // the remainder is given out first come first serve - num_directories = leaves.num_entries / num_threads; - num_directories += i < leaves.num_entries % num_threads ? 1 : 0; - directories = leaves.array + total_directories; - total_directories += num_directories; - } - // determine how many files this thread will operate on - // the remainder is given out first come first serve - int nfiles = num_files / num_threads; - assert(nfiles > 0); // already an invariant that num_threads <= num_files - nfiles += i < num_files % num_threads ? 1 : 0; - // create and dispatch a thread to do the work. to recap, this thread - // creates nfiles evenly over num_directories whose paths are in the - // array starting at directories. the op dictates what kind of - // IO goes down and the file ops dictates which interface is used - assert(num_directories <= num_files); - info = benchmark_thread_info_create(op, - nfiles, directories, num_directories, file_ops); - toku_threadpool_dispatch(&tp, benchmark_thread, info); - total_files += nfiles; - } - - // make sure that we used the correct number of leaf directories - assert(total_files == num_files); - assert(total_directories == leaves.num_entries); - - printf("waiting for work to finish...\n"); - ret = toku_threadpool_wait(&tp); - assert(ret == 0); - - //sync(); - - long elapsed_time = toku_current_time_usec() - start; - printf("finished: time %ld usec\n", elapsed_time); - // if there's more than one file, we probably care about - // file creations per second - if (num_files > 1) { - double seconds = elapsed_time / 1000000.0; - printf("%d files, %lf files/sec\n", - num_files, - num_files / seconds); - } - // if there are data operations happening, we probably - // care about byte throughput - if (num_operations > 0) { - long bytes = num_files * num_operations * iosize; - printf("throughput: %lf MB/sec\n", bytes / (elapsed_time * 1.0)); - } - - ret = toku_threadpool_destroy(&tp); - free_leaf_directories(&leaves); - assert(ret == 0); -} - -static void handle_sigusr1(int sig) -{ - assert(sig == SIGUSR1); - - printf("progress reporting unimplemented\n"); -} - -static void setup_signal_handlers(void) -{ - int ret; - struct sigaction sigact; - sigset_t signals; - - memset(&sigact, 0, sizeof(sigact)); - sigemptyset(&signals); - sigaddset(&signals, SIGUSR1); - - sigact.sa_handler = handle_sigusr1; - sigact.sa_mask = signals; - - ret = sigaction(SIGUSR1, &sigact, NULL); - assert(ret == 0); -} - -/** - * Aggregate a bunch of strings into one, separated by spaces. - */ -static char * toku_strcombine(char ** strings, int count) -{ - int i, length; - char * buf; - - length = 0; - for (i = 0; i < count; i++) { - length += (strlen(strings[i]) + 1); - } - length++; - - buf = malloc(sizeof(char) * (length + 1)); - memset(buf, 0, length + 1); - for (i = 0; i < count; i++) { - strcat(buf, strings[i]); - strcat(buf, " "); - } - - return buf; -} - - -/** - * Get a string representing the current date. - * The returned string needs to be freed by the caller. - */ -static char * toku_strdate(void) -{ - time_t now; - char * date; - char * newline; - - now = time(NULL); - date = ctime(&now); - date = strdup(date); - - /* at least one ctime implementation is putting on its - * own newline char, for some reason. */ - newline = strchr(date, '\n'); - if (newline != NULL) { - *newline = '\0'; - } - - return date; -} - - -int main(int argc, char * argv[]) -{ - int ret; - char * invocation_str, * date_str; - char hostname[256]; - struct benchmark_file_ops * file_ops; - - ret = parse_args(argc, argv); - if (ret != 0 || help) { - usage(); - exit(ret); - } - if (num_threads > num_files) { - printf("cannot have more threads (%d) than files (%d)\n", - num_threads, num_files); - exit(1); - } else if (num_files == 1) { - printf("reporting 20 intervals of throughput progress " - "for a one file benchmark\n"); - report_progress = 1; - } - - toku_debug = verbose != 0; - setup_signal_handlers(); - invocation_str = toku_strcombine(argv, argc); - ret = gethostname(hostname, 256); - assert(ret == 0); - - ret = toku_fs_set_cachesize(cachesize); - if (ret != 0) { - printf("Couldn't set the cache size to %lu\n", cachesize); - exit(1); - } - - int pgsize = getpagesize(); - date_str = toku_strdate(); - printf("filesystem benchmark\n"); - printf("invoked via: %s\n", invocation_str); - printf(" * dir: %s\n", benchmark_root_dir); - printf(" * started: %s\n", date_str); - printf(" * pid: %d\n", getpid()); - printf(" * hostname: %s\n", hostname); - printf(" * num files: %d\n", num_files); - printf(" * max children: %d\n", directory_max_children); - printf(" * num threads: %d\n", num_threads); - printf(" * num operations: %d\n", num_operations); - printf(" * IO type: %s\n", do_pwrite ? "pwrite" : "pread"); - printf(" * IO pattern: %s\n", do_serial ? "serial" : "random"); - printf(" * size of each IO op: %lu\n", iosize); - printf(" * size of each file: %lu\n", num_operations * iosize); - printf(" * filesystem pagesize: %d\n", pgsize); - printf(" * cachesize: %lu MB\n", cachesize / (1024*1024)); - printf(" * verbose? %s\n", verbose ? "yes" : "no"); - printf(" * report progress? %s\n", report_progress ? "yes" : "no"); - - free(date_str); - free(invocation_str); - - file_ops = &posix_file; - - run_benchmarks(file_ops); - - return 0; -} diff --git a/buildheader/benchmarks/micro/tokubench/benchmark-fs.c b/buildheader/benchmarks/micro/tokubench/benchmark-fs.c deleted file mode 100644 index a7f47ee56..000000000 --- a/buildheader/benchmarks/micro/tokubench/benchmark-fs.c +++ /dev/null @@ -1,867 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "tokufs.h" - -#define TOKUFS_MOUNT "dumpfile.mount" - -static int verbose; - -static int help; -static int use_ufs; -static int do_drop_caches; - -static int do_serial_read; -static int do_serial_write; -static int do_random_read; -static int do_random_write; - -static size_t num_records = 256 * 1024; -static size_t record_size = 512; -static size_t compressibility = 1; -static size_t cachesize_mb = 128; - -#define RANDOM_TABLE_SIZE (32*1024*1024) -static char * random_table; - -static char * output_file = "dumpfile"; - -#define RECORD_MAGIC_BYTE 123 -#define FILE_SIZE (num_records * record_size) - -static size_t * bytes_done_so_far; -static long * operation_start_time; - -#define echo(...) \ - do { \ - printf(__VA_ARGS__); \ - fflush(stdout); \ - } while(0) - -#define verbose_echo(...) \ - do { \ - if (verbose) { \ - echo("-- "); \ - echo(__VA_ARGS__); \ - } \ - } while (0) - -static struct option long_options[] = -{ - {"verbose", no_argument, &verbose, 1}, - {"help", no_argument, &help, 1}, - {"drop-caches", no_argument, &do_drop_caches, 1}, - {"file-name", required_argument, NULL, 'f'}, - {"num-records", required_argument, NULL, 'n'}, - {"record-size", required_argument, NULL, 'x'}, - {"compressibility", required_argument, NULL, 'c'}, - {"output-file", required_argument, NULL, 'o'}, - {"cache-size-mb", required_argument, NULL, 'm'}, - {"serial-read", no_argument, &do_serial_read, 1}, - {"serial-write", no_argument, &do_serial_write, 1}, - {"random-read", no_argument, &do_random_read, 1}, - {"random-write", no_argument, &do_random_write, 1} -}; -static char * opt_string = "vhudf:n:x:o:t:m:"; - -static void usage(void) -{ - printf( - "usage:\n" - " -v, --verbose\n" - " enable verbose output.\n" - " -h, --help\n" - " print this help and quit.\n" - " -u, --use-ufs\n" - " perform benchmark on the underlying file system\n" - " -d, --drop-caches\n" - " try to drop caches between runs. usually requires root.\n" - " -f, --file-name\n" - " target file name.\n" - " -n, --num-records\n" - " number of records to read/write.\n" - " -x, --record-size\n" - " size of each record.\n" - " -c, --compressibility\n" - " populate records with data that a compression algorithm\n" - " would likely reduce by a given factor\n" - " -m, --cache-size-mb\n" - " set the cache size in mb for non ufs runs\n" - " --serial-read\n" - " perform the serial read benchmark. target file required\n" - " if no write benchmark is specified\n" - " --serial-write\n" - " perform the serial write benchmark\n" - " --random-read\n" - " pefform the random read benchmark. target file required\n" - " if no write benchmark is specified\n" - " --random-write\n" - " perform the random write benchmark\n" - "Note: If none of serial/random read/write are specified,\n" - " all are assumed.\n" - ); -} - -static int parse_args(int argc, char * argv[]) -{ - int i, c; - long n; - - while ((c = getopt_long(argc, argv, - opt_string , long_options, &i)) != -1) { - switch (c) { - case 0: - break; - case 'f': - if (strlen(optarg) == 0) { - fprintf(stderr, "invalid file name\n"); - return 1; - } - output_file = strdup(optarg); - break; - case 'h': - help = 1; - break; - case 'n': - n = atol(optarg); - if (n <= 0) { - fprintf(stderr, "number of records must be > 0\n"); - return 1; - } - num_records = n; - break; - case 'c': - n = atol(optarg); - if (n < 1) { - fprintf(stderr, "compressibility must be >= 1\n"); - fprintf(stderr, "ie: a compressibility of 4 means the" - "data is roughly 1/4 the size when compressed\n"); - return 1; - } - compressibility = n; - break; - case 'm': - cachesize_mb = atol(optarg); - break; - case 'v': - verbose = 1; - break; - case 'd': - do_drop_caches = 1; - break; - case 'x': - n = atol(optarg); - if (n <= 0) { - fprintf(stderr, "record size must be > 0\n"); - return 1; - } - record_size = n; - break; - case '?': - default: - return 1; - } - } - - return 0; -} - -/** - * Get the current time in microseconds - */ -static long current_time_us(void) -{ - struct timeval t; - gettimeofday(&t, NULL); - return t.tv_usec + t.tv_sec * 1000000; -} - -/** - * Get a string representing the current date. - * The returned string needs to be freed by the caller. - */ -static char * date_string(void) -{ - time_t now; - char * date; - char * newline; - - now = time(NULL); - date = ctime(&now); - date = strdup(date); - - /* at least one ctime implementation is putting on its - * own newline char, for some reason. */ - newline = strchr(date, '\n'); - if (newline != NULL) { - *newline = '\0'; - } - - return date; -} - -/** - * Generate a random int - */ -static int random_int(void) -{ - int r; - - r = rand(); - - return r; -} - -/** - * Generate a random long - */ -static long random_long(void) -{ - long r1, r2; - - r1 = rand(); - r2 = rand(); - - return r1 | (r2 << 32); -} - -/** - * Generate a random permutation of uint64s - */ -static uint64_t * random_perm(uint64_t n) -{ - uint64_t i, j, tmp; - uint64_t * perm; - - perm = malloc(sizeof(uint64_t) * n); - for (i = 0; i < n; i++) { - perm[i] = i; - } - for (i = n - 1; i > 0; i--) { - j = random_long() % (i + 1); - tmp = perm[i]; - perm[i] = perm[j]; - perm[j] = tmp; - } - - return perm; -} - -/** - * Aggregate a bunch of strings into one, separated by spaces. - */ -static char * str_aggregate(int count, char ** strings) -{ - int i, length; - char * buf; - - length = 0; - for (i = 0; i < count; i++) { - length += (strlen(strings[i]) + 1); - } - length++; - - buf = malloc(sizeof(char) * (length + 1)); - memset(buf, 0, length + 1); - for (i = 0; i < count; i++) { - strcat(buf, strings[i]); - strcat(buf, " "); - } - - return buf; -} - -/** - * Asks the virtual memory system to drop recently - * accessed memory in the page file, I believe. - */ -static int drop_caches(void) -{ - int ret; - - ret = system("echo 3 > /proc/sys/vm/drop_caches"); - - return ret; -} - -/** - * TokuDB compresses redundant bytes, so we need a way - * to extract some reasonable random bytes quickly - * during each benchmark iteration. Here, we generate - * a big old table of random stuff to later grab from for - * this purpose. - */ -static void init_random_table(void) -{ - size_t i; - int * rand_ints; - - assert(RANDOM_TABLE_SIZE % sizeof(int) == 0); - - random_table = malloc(RANDOM_TABLE_SIZE); - rand_ints = (int *) random_table; - - /* Generate randomness 4 bytes at a time. */ - for (i = 0; i < RANDOM_TABLE_SIZE / sizeof(int); i++) { - if (i % compressibility == 0) { - rand_ints[i] = 0; - } else { - rand_ints[i] = random_int(); - } - } -} - -/** - * Populate some subset of the record with stuff - * from a random spot in the random table. Then, - * fill the rest with the magic byte. The idea is that - * this particular record will have its magic bytes - * compressed to almost nothing, and the random bytes - * will be uncompressed, giving us a record which - * is roughly compressible by a tweakable factor. - */ -static char * get_write_buf() -{ - int r = random_int() % (RANDOM_TABLE_SIZE - record_size); - return &random_table[r]; -#if 0 - size_t offset, threshold; - - threshold = record_size / compressibility; - offset = random_long() % (RANDOM_TABLE_SIZE - threshold); - - memcpy(record, random_table + offset, threshold); -#ifdef DUMPRECORD - printf("record ["); - for (unsigned i = 0; i < threshold; i++) { - printf("%x ", *((unsigned char *) record + i)); - } - getchar(); -#endif - memset(record + threshold, - RECORD_MAGIC_BYTE, record_size - threshold); -#endif -} - -/* TODO: Determine a good way to verify a record, - * in light of the fact that it may be partly random. */ -static int verify_record(void * record) -{ - (void) record; -#if 0 - size_t i; - unsigned char expected; - unsigned char * cbuf = record; - - for (i = 0; i < record_size; i++) { - expected = i % 100; - if (cbuf[i] != expected) { - fprintf(stderr, "%s: byte %lu got %d wanted %d\n", - __FUNCTION__, i, cbuf[i], expected); - } - //assert(cbuf[i] == i % 100); - } -#endif - return 0; -} - -/** - * Make it so that switching between tokufs and ufs - * is transparent to the benchmarking code. - * - * We then define each benchmark function in terms of - * benchmark file struct - */ -struct benchmark_file -{ - char * path; - int (*open)(const char * path, int flags, ...); - int (*close)(int fd); - ssize_t (*pwrite)(int fd, const void * buf, - size_t count, off_t offset); - ssize_t (*pread)(int fd, void * buf, - size_t count, off_t offset); -}; - -struct benchmark_times -{ - long open_time; - long io_time; - long close_time; -}; - -static long benchmark_serial_write(struct benchmark_file * file, - struct benchmark_times * times) -{ - int fd; - long op_start, start, now; - ssize_t n; - size_t i, bytes_written; - char * record; - - if (do_drop_caches) { - assert(drop_caches() == 0); - } - - verbose_echo("%s: opening %s\n", __FUNCTION__, file->path); - start = current_time_us(); - - fd = file->open(file->path, O_WRONLY | O_CREAT, 0644); - assert(fd >= 0); - - now = current_time_us(); - times->open_time = now - start; - verbose_echo("%s: done\n", __FUNCTION__); - - op_start = current_time_us(); - - operation_start_time = &op_start; - bytes_done_so_far = &bytes_written; - - for (i = 0, bytes_written = 0; i < num_records; i++) { - record = get_write_buf(); - n = file->pwrite(fd, record, - record_size, i * record_size); - assert(n == (ssize_t) record_size); - if (i > 0 && i % (num_records/20) == 0) { - now = current_time_us() - op_start; - verbose_echo("wrote %ld bytes so far, throughput %.3lf\n", - bytes_written, (bytes_written * 1.0 / now)); - } - bytes_written += n; - } - - assert(bytes_written == FILE_SIZE); - now = current_time_us(); - times->io_time = now - op_start; - - /* Clear the global bytes_done and operation time pointers */ - bytes_done_so_far = NULL; - operation_start_time = NULL; - - verbose_echo("%s: closing %s\n", __FUNCTION__, file->path); - op_start = current_time_us(); - - file->close(fd); - now = current_time_us(); - times->close_time = now - op_start; - verbose_echo("%s: done\n", __FUNCTION__); - - return now - start; -} - -static long benchmark_serial_read(struct benchmark_file * file, - struct benchmark_times * times) -{ - int fd; - long op_start, start, now; - ssize_t n; - size_t i, bytes_read; - unsigned char * record = malloc(record_size); - - if (do_drop_caches) { - assert(drop_caches() == 0); - } - - verbose_echo("%s: opening %s\n", __FUNCTION__, file->path); - start = current_time_us(); - - fd = file->open(file->path, O_RDONLY); - assert(fd >= 0); - - now = current_time_us(); - times->open_time = now - start; - verbose_echo("%s: done\n", __FUNCTION__); - - op_start = current_time_us(); - - operation_start_time = &op_start; - bytes_done_so_far = &bytes_read; - - for (i = 0, bytes_read = 0; i < num_records; i++) { - n = file->pread(fd, record, - record_size, i * record_size); - if (n != (ssize_t) record_size) { - printf("i = %lu, bytes_read %lu, n = %ld, record_size %ld\n", - i, bytes_read, n, record_size); - } - assert(n == (ssize_t) record_size); - assert(verify_record(record) == 0); - if (i > 0 && i % (num_records/20) == 0) { - now = current_time_us() - op_start; - verbose_echo("read %ld bytes so far, throughput %.3lf\n", - bytes_read, (bytes_read * 1.0 / now)); - } - bytes_read += n; - } - - free(record); - - assert(bytes_read == FILE_SIZE); - now = current_time_us(); - times->io_time = now - op_start; - - /* Clear the global bytes_done and operation time pointers */ - bytes_done_so_far = NULL; - operation_start_time = NULL; - - verbose_echo("%s: closing %s\n", __FUNCTION__, file->path); - op_start = current_time_us(); - - file->close(fd); - now = current_time_us(); - times->close_time = now - op_start; - verbose_echo("%s: done\n", __FUNCTION__); - - return now - start; -} - -static long benchmark_random_write(struct benchmark_file * file, - struct benchmark_times * times) -{ - int fd; - long op_start, start, now; - ssize_t n; - size_t i, bytes_written, * offsets; - char * record; - - offsets = random_perm(num_records); - - if (do_drop_caches) { - assert(drop_caches() == 0); - } - - verbose_echo("%s: opening %s\n", __FUNCTION__, file->path); - start = current_time_us(); - - fd = file->open(file->path, O_WRONLY | O_CREAT, 0644); - assert(fd >= 0); - - now = current_time_us(); - times->open_time = now - start; - verbose_echo("%s: done\n", __FUNCTION__); - - op_start = current_time_us(); - - operation_start_time = &op_start; - bytes_done_so_far = &bytes_written; - - for (i = 0, bytes_written = 0; i < num_records; i++) { - record = get_write_buf(); - n = file->pwrite(fd, record, - record_size, offsets[i] * record_size); - assert(n == (ssize_t) record_size); - if (i > 0 && i % (num_records/20) == 0) { - now = current_time_us() - op_start; - verbose_echo("wrote %ld bytes so far, throughput %.3lf\n", - bytes_written, (bytes_written * 1.0 / now)); - } - bytes_written += n; - } - - assert(bytes_written == FILE_SIZE); - now = current_time_us(); - times->io_time = now - op_start; - - /* Clear the global bytes_done and operation time pointers */ - bytes_done_so_far = NULL; - operation_start_time = NULL; - - free(offsets); - - verbose_echo("%s: closing %s\n", __FUNCTION__, file->path); - op_start = current_time_us(); - - file->close(fd); - now = current_time_us(); - times->close_time = now - op_start; - verbose_echo("%s: done\n", __FUNCTION__); - - return now - start; -} - -static long benchmark_random_read(struct benchmark_file * file, - struct benchmark_times * times) -{ - int fd; - long op_start, start, now; - ssize_t n; - size_t i, bytes_read, * offsets; - unsigned char * record = malloc(record_size); - - offsets = random_perm(num_records); - - if (do_drop_caches) { - assert(drop_caches() == 0); - } - - verbose_echo("%s: opening %s\n", __FUNCTION__, file->path); - start = current_time_us(); - - fd = file->open(file->path, O_RDONLY); - assert(fd >= 0); - now = current_time_us(); - times->open_time = now - start; - verbose_echo("%s: done\n", __FUNCTION__); - - op_start = current_time_us(); - - operation_start_time = &op_start; - bytes_done_so_far = &bytes_read; - - for (i = 0, bytes_read = 0; i < num_records; i++) { - n = file->pread(fd, record, - record_size, offsets[i] * record_size); - assert(n == (ssize_t) record_size); - assert(verify_record(record) == 0); - if (i > 0 && i % (num_records/20) == 0) { - now = current_time_us() - op_start; - verbose_echo("read %ld bytes so far, throughput %.3lf\n", - bytes_read, (bytes_read * 1.0 / now)); - } - bytes_read += n; - } - - free(record); - - assert(bytes_read == FILE_SIZE); - now = current_time_us(); - times->io_time = now - op_start; - - /* Clear the global bytes_done and operation time pointers */ - bytes_done_so_far = NULL; - operation_start_time = NULL; - - free(offsets); - - verbose_echo("%s: closing %s\n", __FUNCTION__, file->path); - op_start = current_time_us(); - - file->close(fd); - now = current_time_us(); - times->close_time = now - op_start; - verbose_echo("%s: done\n", __FUNCTION__); - - return now - start; -} - -static struct benchmark_file ufs_file = -{ - .open = open, - .close = close, - .pwrite = pwrite, - .pread = pread -}; - -static void run_benchmarks(struct benchmark_file * file) -{ - char * date; - long sw_total_time, sr_total_time, rw_total_time, rr_total_time; - struct benchmark_times sw_times, sr_times, rw_times, rr_times; - - init_random_table(); - - sw_total_time = sr_total_time = rw_total_time = rr_total_time = 0; - memset(&sw_times, 0, sizeof(struct benchmark_times)); - memset(&sr_times, 0, sizeof(struct benchmark_times)); - memset(&rw_times, 0, sizeof(struct benchmark_times)); - memset(&rr_times, 0, sizeof(struct benchmark_times)); - - date = date_string(); - echo("Benchmarks starting: %s\n", date); - free(date); - - if (do_serial_write) { - sw_total_time = benchmark_serial_write(file, &sw_times); - } - - if (do_random_write) { - rw_total_time = benchmark_random_write(file, &rw_times); - } - - if (do_serial_read) { - sr_total_time = benchmark_serial_read(file, &sr_times); - } - - if (do_random_read) { - rr_total_time = benchmark_random_read(file, &rr_times); - } - - date = date_string(); - echo("Benchmarks completed: %s\n", date); - free(date); - - if (do_serial_write) { - echo("Serial write times:\n"); - echo(" * open: %ld\n", sw_times.open_time); - echo(" * io: %ld\n", sw_times.io_time); - echo(" * close: %ld\n", sw_times.close_time); - echo(" * total: %ld\n", sw_total_time); - echo(" * io throughput: %lf MB/s\n", - FILE_SIZE / (sw_times.io_time * 1.0)); - echo(" * effective: %lf MB/s\n", - FILE_SIZE / (sw_total_time * 1.0)); - } - - if (do_random_write) { - echo("Random write times:\n"); - echo(" * open: %ld\n", rw_times.open_time); - echo(" * io: %ld\n", rw_times.io_time); - echo(" * close: %ld\n", rw_times.close_time); - echo(" * total: %ld\n", rw_total_time); - echo(" * io throughput: %lf MB/s\n", - FILE_SIZE / (rw_times.io_time * 1.0)); - echo(" * effective: %lf MB/s\n", - FILE_SIZE / (rw_total_time * 1.0)); - } - - if (do_serial_read) { - echo("Serial read times:\n"); - echo(" * open: %ld\n", sr_times.open_time); - echo(" * io: %ld\n", sr_times.io_time); - echo(" * close: %ld\n", sr_times.close_time); - echo(" * total: %ld\n", sr_total_time); - echo(" * io throughput: %lf MB/s\n", - FILE_SIZE / (sr_times.io_time * 1.0)); - echo(" * effective: %lf MB/s\n", - FILE_SIZE / (sr_total_time * 1.0)); - } - - if (do_random_read) { - echo("Random read times:\n"); - echo(" * open: %ld\n", rr_times.open_time); - echo(" * io: %ld\n", rr_times.io_time); - echo(" * close: %ld\n", rr_times.close_time); - echo(" * total: %ld\n", rr_total_time); - echo(" * io throughput: %lf MB/s\n", - FILE_SIZE / (rr_times.io_time * 1.0)); - echo(" * effective: %lf MB/s\n", - FILE_SIZE / (rr_total_time * 1.0)); - } -} - -static void handle_sigusr1(int sig) -{ - size_t bytes_done; - long op_start; - long now = current_time_us(); - - assert(sig == SIGUSR1); - - if (bytes_done_so_far != NULL && operation_start_time != NULL) { - bytes_done = *bytes_done_so_far; - op_start = *operation_start_time; - printf("bytes done %lu, throughput %.3lf\n", - bytes_done, (bytes_done / (now - op_start * 1.0))); - - } else { - printf("Nothing happening.\n"); - } -} - -static void setup_signal_handlers(void) -{ - int ret; - struct sigaction sigact; - sigset_t signals; - - memset(&sigact, 0, sizeof(sigact)); - sigemptyset(&signals); - sigaddset(&signals, SIGUSR1); - - sigact.sa_handler = handle_sigusr1; - sigact.sa_mask = signals; - - ret = sigaction(SIGUSR1, &sigact, NULL); - assert(ret == 0); -} - -int main(int argc, char * argv[]) -{ - int ret; - int preference; - char * invocation_str, host_name[256]; - struct benchmark_file * file; - - ret = parse_args(argc, argv); - if (ret != 0 || help) { - usage(); - exit(ret); - } - - setup_signal_handlers(); - - srand(current_time_us()); - invocation_str = str_aggregate(argc, argv); - ret = gethostname(host_name, 256); - assert(ret == 0); - - /* If no preference is given, do serial write and read. */ - preference = do_serial_read || do_serial_write - || do_random_read || do_random_write; - - if (!preference) { - do_serial_read = 1; - do_serial_write = 1; - } - - ret = toku_fs_set_cachesize(cachesize_mb * 1024 * 1024); - - if (ret != 0) { - printf("Couldn't set the cache size to %lu\n", - cachesize_mb * 1024 * 1024); - exit(-1); - } - - echo("File system benchmark\n"); - echo("invoked via: %s\n", invocation_str); - echo(" * pid: %d\n", getpid()); - echo(" * Hostname: %s\n", host_name); - echo(" * Number of records: %lu\n", - num_records < 20 ? (num_records = 20) : num_records); - echo(" * Record size: %lu\n", record_size); - echo(" * File size: %lu\n", FILE_SIZE); - echo(" * Compressibility: %lu\n", compressibility); - echo(" * Target file name: %s\n", output_file); - echo(" * Target file system: %s\n", use_ufs ? "ufs" : "TokuFS"); - echo(" * Page size: %lu\n", - use_ufs ? (size_t) getpagesize() : toku_fs_get_blocksize()); - if (!use_ufs) { - echo(" * Cache size: %lu MB\n", cachesize_mb); - echo(" * Underlying store: TokuFS\n"); - } - echo(" * Verbose? %s\n", verbose ? "yes" : "no"); - echo(" * Benchmarking serial write? %s\n", - do_serial_write ? "yes" : "no"); - echo(" * Benchmarking random write? %s\n", - do_random_write ? "yes" : "no"); - echo(" * Benchmarking serial read? %s\n", - do_serial_read ? "yes" : "no"); - echo(" * Benchmarking random read? %s\n", - do_random_read ? "yes" : "no"); - - free(invocation_str); - - file = &ufs_file; - file->path = output_file; - - run_benchmarks(file); - - long start = current_time_us(); - //unmount here - long end = current_time_us(); - echo("Unmount time: %ld\n", end - start); - - free(random_table); - - return 0; -} diff --git a/buildheader/benchmarks/micro/tokubench/run-benchmark-fs-threaded.sh b/buildheader/benchmarks/micro/tokubench/run-benchmark-fs-threaded.sh deleted file mode 100755 index 5a237bcc3..000000000 --- a/buildheader/benchmarks/micro/tokubench/run-benchmark-fs-threaded.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash - -if [ ! -e benchmark-fs-threaded ] ; then - echo "run \'make benchmark-fs-threaded\' first." - exit 1 -fi - - -# benchmark parameters -#thread_counts="1" -#thread_counts="2" -thread_counts="4" -iosize="200" -operations="1" -#max_fanout="1000000" -max_fanout="128" -#num_files="500000" -num_files="3000000" -#num_files="1000000" - -mnt="/mnt/benchmark" - -outfile="fs-threaded" - -echo "Running benchmarks on $mnt" -for num_threads in $thread_counts ; do - sudo ../../clear-fs-caches.sh - dir="microfile-bucket.$(date +%s)" - cmd="./benchmark-fs-threaded --files $num_files -d $max_fanout --iosize $iosize --operations $operations --pwrite --serial --threads $num_threads --dir $mnt/$dir" - echo $cmd - ( - $cmd - ) | tee -a $outfile-$num_threads.results - if [ $? != 0 ] ; then - echo "got error $?" - fi -done - - diff --git a/buildheader/benchmarks/micro/tokubench/run-overnight.sh b/buildheader/benchmarks/micro/tokubench/run-overnight.sh deleted file mode 100755 index 8f8bcdefb..000000000 --- a/buildheader/benchmarks/micro/tokubench/run-overnight.sh +++ /dev/null @@ -1,29 +0,0 @@ -cd /home/ftfs/ft-index/benchmarks/ -sudo ./cleanup-fs.sh -sudo ./setup-ftfs.sh -cd - -./run-benchmark-fs-threaded.sh - -cd /home/ftfs/ft-index/benchmarks/ -sudo ./cleanup-fs.sh -sudo ./setup-xfs.sh -cd - -./run-benchmark-fs-threaded.sh - -cd /home/ftfs/ft-index/benchmarks/ -sudo ./cleanup-fs.sh -sudo ./setup-ext4.sh -cd - -./run-benchmark-fs-threaded.sh - -cd /home/ftfs/ft-index/benchmarks/ -sudo ./cleanup-fs.sh -sudo ./setup-btrfs.sh -cd - -./run-benchmark-fs-threaded.sh - -cd /home/ftfs/ft-index/benchmarks/ -sudo ./cleanup-fs.sh -sudo ./setup-zfs.sh -cd - -./run-benchmark-fs-threaded.sh diff --git a/buildheader/benchmarks/micro/tokubench/run-test.sh b/buildheader/benchmarks/micro/tokubench/run-test.sh deleted file mode 100755 index 42fdfaa10..000000000 --- a/buildheader/benchmarks/micro/tokubench/run-test.sh +++ /dev/null @@ -1,9 +0,0 @@ -cd ~/ft-index/benchmarks/ -sudo ./cleanup-fs.sh -sudo ./setup-ftfs.sh -cd - - -#sudo blktrace -d /dev/sda6 -b 2048 & -./run-benchmark-fs-threaded.sh -#sudo pkill -15 blktrace - diff --git a/buildheader/benchmarks/micro/tokubench/run.microfile-bench.bash b/buildheader/benchmarks/micro/tokubench/run.microfile-bench.bash deleted file mode 100644 index a399e73f1..000000000 --- a/buildheader/benchmarks/micro/tokubench/run.microfile-bench.bash +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -if [ ! -e benchmark-fs-threaded ] ; then - echo "make benchmark-fs-threaded first. cowardly not doing it here." - return 1 -fi - -# benchmark parameters -thread_counts="1 4 8" -iosize="200" -operations="1" -dir_depth="128" -num_files="5000000" - -mounts="/mnt/ext4 /mnt/xfs /mnt/btrfs /zfs" - -for mnt in $mounts ; do - echo "Running benchmarks on $mnt" - for num_threads in $thread_counts ; do - dir="microfile-bucket.$(date +%s)" - fs=$(echo $mnt | tr / _) - cmd="./benchmark-fs-threaded --files $num_files -d $dir_depth --iosize $iosize --operations $operations -u --threads $num_threads --dir $mnt/$dir" - echo $cmd - ( - $cmd - ) | tee -a $fs-$num_threads.results - if [ $? != 0 ] ; then - echo "got error $?" - return $? - fi - done -done - diff --git a/buildheader/benchmarks/micro/tokubench/threadpool.c b/buildheader/benchmarks/micro/tokubench/threadpool.c deleted file mode 100644 index 3a1cca755..000000000 --- a/buildheader/benchmarks/micro/tokubench/threadpool.c +++ /dev/null @@ -1,212 +0,0 @@ -/** - * TokuFS - */ - -#include -#include -#include -#include -#include - -#include "threadpool.h" - -#define WORK_QUEUE_CONGESTION_FACTOR 3 - -struct work { - threadpool_fn fn; - void * arg; - struct work * next; -}; - -static int work_queue_is_congested(struct threadpool * tp) -{ - int max_work = tp->num_threads * WORK_QUEUE_CONGESTION_FACTOR; - return tp->unfinished_work_items >= max_work; -} - -/** - * Post work to the queue, assume the lock is held. - */ -static int work_queue_post(struct threadpool * tp, - threadpool_fn fn, void * arg) -{ - struct work * w; - - w = malloc(sizeof(struct work)); - w->fn = fn; - w->arg = arg; - w->next = NULL; - // we're posting this to the tail of the queue - if (tp->work_queue_head == NULL) { - // in an empty queue, the new element - // is both the head and the tail - assert(tp->work_queue_tail == NULL); - tp->work_queue_head = tp->work_queue_tail = w; - } else { - // in a nonempty queue, the new element goes - // after the current tail, and the tail - // becomes the new element. - assert(tp->work_queue_tail != NULL); - tp->work_queue_tail->next = w; - tp->work_queue_tail = w; - } - // count this unfinished work item, wake up a - // single thread waiting for work - tp->unfinished_work_items++; - pthread_cond_signal(&tp->work_available); - - return 0; -} - -/** - * Get some work from the queue, assume the lock is held. - */ -static struct work * work_queue_get(struct threadpool * tp) -{ - struct work * w; - - if (tp->work_queue_head == NULL) { - w = NULL; - assert(tp->work_queue_tail == NULL); - } else { - w = tp->work_queue_head; - tp->work_queue_head = tp->work_queue_head->next; - // if removing the top element empties the queue, - // then the tail should have been pointing to our - // element, and both head and tail become null. - if (tp->work_queue_head == NULL) { - assert(tp->work_queue_tail == w); - tp->work_queue_tail = NULL; - } - } - - return w; -} - -/** - * "Launch point" function that each work thread is directed to. - * threads atomically grab work from the queue and do it. - */ -static void * launch_point(void * arg) -{ - struct work * w; - struct threadpool * tp = arg; - - pthread_mutex_lock(&tp->lock); - - while (tp->keep_working) { - w = work_queue_get(tp); - if (w == NULL) { - pthread_cond_wait(&tp->work_available, &tp->lock); - continue; - } - pthread_mutex_unlock(&tp->lock); - - w->fn(w->arg); - free(w); - - pthread_mutex_lock(&tp->lock); - assert(tp->unfinished_work_items > 0); - tp->unfinished_work_items--; - pthread_cond_signal(&tp->work_finished); - if (tp->unfinished_work_items == 0) { - pthread_cond_broadcast(&tp->pool_idle); - } - } - - pthread_mutex_unlock(&tp->lock); - return NULL; -} - -/** - * initializes a fixed-sized thread pool. - */ -int toku_threadpool_init(struct threadpool * tp, int num_threads) -{ - int i, ret; - - memset(tp, 0, sizeof(struct threadpool)); - tp->num_threads = num_threads; - tp->pool = malloc(sizeof(pthread_t) * num_threads); - tp->keep_working = 1; - pthread_mutex_init(&tp->lock, NULL); - pthread_cond_init(&tp->work_available, NULL); - pthread_cond_init(&tp->work_finished, NULL); - pthread_cond_init(&tp->pool_idle, NULL); - - for (i = 0; i < tp->num_threads; i++) { - ret = pthread_create(&tp->pool[i], NULL, launch_point, tp); - assert(ret == 0); - } - - return 0; -} - -/** - * dispatch sends a thread off to do some work. - */ -int toku_threadpool_dispatch(struct threadpool * tp, - threadpool_fn fn, void * arg) -{ - pthread_mutex_lock(&tp->lock); - if (work_queue_is_congested(tp)) { - pthread_cond_wait(&tp->work_finished, &tp->lock); - } - assert(!work_queue_is_congested(tp)); - work_queue_post(tp, fn, arg); - pthread_mutex_unlock(&tp->lock); - - return 0; -} - -/** - * Blocks until all threads in the pool are idle. - */ -int toku_threadpool_wait(struct threadpool * tp) -{ - pthread_mutex_lock(&tp->lock); - if (tp->unfinished_work_items > 0) { - pthread_cond_wait(&tp->pool_idle, &tp->lock); - } - assert(tp->unfinished_work_items == 0); - assert(tp->work_queue_head == NULL); - assert(tp->work_queue_tail == NULL); - pthread_mutex_unlock(&tp->lock); - - return 0; -} - -/** - * join all threads in the threadpool and - * free all the memory associated with the threadpool. - */ -int toku_threadpool_destroy(struct threadpool * tp) -{ - int i; - - pthread_mutex_lock(&tp->lock); - // drop the keep working flag, and broadcast to all threads - // that work is available. that way, they see the flag - // as down, and return. - tp->keep_working = 0; - pthread_cond_broadcast(&tp->work_available); - pthread_mutex_unlock(&tp->lock); - - // join with each worker thread to clean up - for (i = 0; i < tp->num_threads; i++) { - pthread_join(tp->pool[i], NULL); - } - - pthread_mutex_destroy(&tp->lock); - pthread_cond_destroy(&tp->work_available); - pthread_cond_destroy(&tp->work_finished); - pthread_cond_destroy(&tp->pool_idle); - - // let's consider it a bug to do a destroy while - // there exists unfinished work - assert(tp->unfinished_work_items == 0); - assert(tp->work_queue_head == NULL); - assert(tp->work_queue_tail == NULL); - free(tp->pool); - return 0; -} diff --git a/buildheader/benchmarks/micro/tokubench/threadpool.h b/buildheader/benchmarks/micro/tokubench/threadpool.h deleted file mode 100644 index 75a9bfdad..000000000 --- a/buildheader/benchmarks/micro/tokubench/threadpool.h +++ /dev/null @@ -1,35 +0,0 @@ -/** - * TokuFS - */ - -#ifndef TOKU_THREADPOOL_H -#define TOKU_THREADPOOL_H - -typedef void (*threadpool_fn)(void * arg); - -struct work; -struct threadpool { - int num_threads; - pthread_t * pool; - - struct work * work_queue_head; - struct work * work_queue_tail; - int unfinished_work_items; - int keep_working; - - pthread_mutex_t lock; - pthread_cond_t work_available; - pthread_cond_t work_finished; - pthread_cond_t pool_idle; -}; - -int toku_threadpool_init(struct threadpool * tp, int num_threads); - -int toku_threadpool_dispatch(struct threadpool * tp, - threadpool_fn fn, void * arg); - -int toku_threadpool_wait(struct threadpool * tp); - -int toku_threadpool_destroy(struct threadpool * tp); - -#endif /* TOKU_THREADPOOL_H */ diff --git a/buildheader/benchmarks/micro/tokubench/tokufs.h b/buildheader/benchmarks/micro/tokubench/tokufs.h deleted file mode 100644 index ed23b688a..000000000 --- a/buildheader/benchmarks/micro/tokubench/tokufs.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef _TOKUFS_H -#define _TOKUFS_H - -static inline int toku_fs_set_cachesize(size_t cachesize) -{ - return cachesize - cachesize; -} - -static inline size_t toku_fs_get_blocksize(void) -{ - return 0; -} - -static inline int toku_fs_mount(void) -{ - return 0; -} - -static inline int toku_fs_unmount(void) -{ - return 0; -} - -#endif //_TOKUFS_H diff --git a/buildheader/benchmarks/mkfs.ftfs b/buildheader/benchmarks/mkfs.ftfs deleted file mode 100755 index 4d2116339..000000000 --- a/buildheader/benchmarks/mkfs.ftfs +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -DIR="${BASH_SOURCE%/*}" -if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi - -. "$DIR/.hostcheck" -. "$DIR/.rootcheck" - -#mkfs.ext4 $1 -mkfs -t ext4 -E lazy_itable_init=0,lazy_journal_init=0 $1 -mount $1 /mnt -cd /mnt; mkdir db; mkdir dev; touch dev/null; mkdir tmp; chmod 1777 tmp; cd -; - -sleep 1 - -umount /mnt diff --git a/buildheader/benchmarks/mount-ftfs.sh b/buildheader/benchmarks/mount-ftfs.sh deleted file mode 100755 index 779af0226..000000000 --- a/buildheader/benchmarks/mount-ftfs.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -DIR="${BASH_SOURCE%/*}" -if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi - -. "$DIR/fs-info.sh" -. "$DIR/.hostcheck" -. "$DIR/.rootcheck" -. "$DIR/.mountcheck" - -set -x - -touch $DIR/$dummy_file -losetup $dummy_dev $DIR/$dummy_file - -# mount the file system -mkdir -p $mntpnt -modprobe zlib -insmod $module sb_dev=$sb_dev sb_fstype=ext4 -mount -t ftfs $dummy_dev $mntpnt -chown -R ftfs:ftfs $mntpnt diff --git a/buildheader/benchmarks/setup-btrfs.sh b/buildheader/benchmarks/setup-btrfs.sh deleted file mode 100755 index 035241c46..000000000 --- a/buildheader/benchmarks/setup-btrfs.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -DIR="${BASH_SOURCE%/*}" -if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi - -. "$DIR/fs-info.sh" -. "$DIR/.hostcheck" -. "$DIR/.rootcheck" -. "$DIR/.mountcheck" - -set -x - -# prep file system -mkfs.btrfs -f $sb_dev - -# mount the file system -mkdir -p $mntpnt -mount -t btrfs $sb_dev $mntpnt -chown -R ftfs:ftfs $mntpnt diff --git a/buildheader/benchmarks/setup-ext4.sh b/buildheader/benchmarks/setup-ext4.sh deleted file mode 100755 index 623cab698..000000000 --- a/buildheader/benchmarks/setup-ext4.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -DIR="${BASH_SOURCE%/*}" -if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi - -. "$DIR/fs-info.sh" -. "$DIR/.hostcheck" -. "$DIR/.rootcheck" -. "$DIR/.mountcheck" - -set -x - -# prep file system -# mkfs -t ext4 $sb_dev -mkfs -t ext4 -E lazy_itable_init=0,lazy_journal_init=0 $sb_dev && -# mount the file system -mkdir -p $mntpnt && -mount -t ext4 $sb_dev $mntpnt && -chown -R ftfs:ftfs $mntpnt -exit $? diff --git a/buildheader/benchmarks/setup-ftfs-parameterized.sh b/buildheader/benchmarks/setup-ftfs-parameterized.sh deleted file mode 100755 index 23e8b9523..000000000 --- a/buildheader/benchmarks/setup-ftfs-parameterized.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -DIR="${BASH_SOURCE%/*}" -if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi - -. "$DIR/fs-info.sh" -. "$DIR/.hostcheck" -. "$DIR/.rootcheck" -. "$DIR/.mountcheck" - -#set -x - -echo "Setup Circle Size: $1" -#echo "Setup Circle Size: $circle_size" - -# prep file system -$DIR/mkfs.ftfs $sb_dev -touch $DIR/$dummy_file -losetup $dummy_dev $DIR/$dummy_file - -# mount the file system -mkdir -p $mntpnt -modprobe zlib -insmod $module sb_dev=$sb_dev sb_fstype=ext4 -mount -t ftfs $dummy_dev $mntpnt -o max=$1 -#$circle_size -chown -R ftfs:ftfs $mntpnt diff --git a/buildheader/benchmarks/setup-ftfs.sh b/buildheader/benchmarks/setup-ftfs.sh deleted file mode 100755 index 3df4eef98..000000000 --- a/buildheader/benchmarks/setup-ftfs.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -DIR="${BASH_SOURCE%/*}" -if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi - -. "$DIR/fs-info.sh" -. "$DIR/.hostcheck" -. "$DIR/.rootcheck" -. "$DIR/.mountcheck" - -#set -x - -#echo "Setup Circle Size: $1" -echo "Setup Circle Size: $circle_size" - -# prep file system -$DIR/mkfs.ftfs $sb_dev -touch $DIR/$dummy_file -losetup $dummy_dev $DIR/$dummy_file - -# mount the file system -mkdir -p $mntpnt -modprobe zlib -insmod $module sb_dev=$sb_dev sb_fstype=ext4 -mount -t ftfs $dummy_dev $mntpnt -o max=$circle_size -chown -R ftfs:ftfs $mntpnt diff --git a/buildheader/benchmarks/setup-southbound.sh b/buildheader/benchmarks/setup-southbound.sh deleted file mode 100755 index 0c3eda450..000000000 --- a/buildheader/benchmarks/setup-southbound.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -DIR="${BASH_SOURCE%/*}" -if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi - -. "$DIR/fs-info.sh" -. "$DIR/.hostcheck" -. "$DIR/.rootcheck" -. "$DIR/.mountcheck" - -set -x - -if [ ! -z "$1" ] -then -# prep file system - $DIR/mkfs.ftfs $sb_dev -fi - - -modprobe zlib -insmod $southbound_module sb_dev=$sb_dev sb_fstype=ext4 diff --git a/buildheader/benchmarks/setup-xfs.sh b/buildheader/benchmarks/setup-xfs.sh deleted file mode 100755 index ac313f3c8..000000000 --- a/buildheader/benchmarks/setup-xfs.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -DIR="${BASH_SOURCE%/*}" -if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi - -. "$DIR/fs-info.sh" -. "$DIR/.hostcheck" -. "$DIR/.rootcheck" -. "$DIR/.mountcheck" - -set -x - -# prep file system -mkfs.xfs -f $sb_dev - -# mount the file system -mkdir -p $mntpnt -mount -t xfs $sb_dev $mntpnt -chown -R ftfs:ftfs $mntpnt diff --git a/buildheader/benchmarks/setup-zfs.sh b/buildheader/benchmarks/setup-zfs.sh deleted file mode 100755 index ff968e0c6..000000000 --- a/buildheader/benchmarks/setup-zfs.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -DIR="${BASH_SOURCE%/*}" -if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi - -. "$DIR/fs-info.sh" -. "$DIR/.hostcheck" -. "$DIR/.rootcheck" -. "$DIR/.mountcheck" - -set -x - -# prep file system -mkdir -p $mntpnt -sudo zpool create -f datastore $sb_dev - -# mount the file system -sudo zfs create -o mountpoint=$mntpnt datastore/files -chown -R ftfs:ftfs $mntpnt diff --git a/buildheader/benchmarks/support-files/.gitignore b/buildheader/benchmarks/support-files/.gitignore deleted file mode 100644 index abf41bc31..000000000 --- a/buildheader/benchmarks/support-files/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -linux-3.11.10 -ft-index-snapshot \ No newline at end of file diff --git a/buildheader/benchmarks/support-files/dovecot-2.2-pigeonhole-0.4.3.tar.gz b/buildheader/benchmarks/support-files/dovecot-2.2-pigeonhole-0.4.3.tar.gz deleted file mode 100644 index c075eb416..000000000 Binary files a/buildheader/benchmarks/support-files/dovecot-2.2-pigeonhole-0.4.3.tar.gz and /dev/null differ diff --git a/buildheader/benchmarks/support-files/dovecot-2.2.13.tar.gz b/buildheader/benchmarks/support-files/dovecot-2.2.13.tar.gz deleted file mode 100644 index 5cdaed4bb..000000000 Binary files a/buildheader/benchmarks/support-files/dovecot-2.2.13.tar.gz and /dev/null differ diff --git a/buildheader/benchmarks/support-files/dovecot-conf.tar.gz b/buildheader/benchmarks/support-files/dovecot-conf.tar.gz deleted file mode 100644 index 42aa90c33..000000000 Binary files a/buildheader/benchmarks/support-files/dovecot-conf.tar.gz and /dev/null differ diff --git a/buildheader/benchmarks/support-files/linux-3.11.10.tar.xz b/buildheader/benchmarks/support-files/linux-3.11.10.tar.xz deleted file mode 100644 index 78b87d3bf..000000000 Binary files a/buildheader/benchmarks/support-files/linux-3.11.10.tar.xz and /dev/null differ diff --git a/buildheader/buildbot/masterftfs/buildbot.tac b/buildheader/buildbot/masterftfs/buildbot.tac deleted file mode 100644 index 9c8b67a7f..000000000 --- a/buildheader/buildbot/masterftfs/buildbot.tac +++ /dev/null @@ -1,31 +0,0 @@ -import os - -from twisted.application import service -from buildbot.master import BuildMaster - -basedir = '/home/ftfs/masterftfs' -rotateLength = '10000000' -maxRotatedFiles = '10' -configfile = 'master.cfg' - -# Default umask for server -umask = None - -# if this is a relocatable tac file, get the directory containing the TAC -if basedir == '.': - import os.path - basedir = os.path.abspath(os.path.dirname(__file__)) - -# note: this line is matched against to check that this is a buildmaster -# directory; do not edit it. -application = service.Application('buildmaster') -from twisted.python.logfile import LogFile -from twisted.python.log import ILogObserver, FileLogObserver -logfile = LogFile.fromFullPath(os.path.join(basedir, "twistd.log"), rotateLength=rotateLength, - maxRotatedFiles=maxRotatedFiles) -application.setComponent(ILogObserver, FileLogObserver(logfile).emit) - -m = BuildMaster(basedir, configfile, umask) -m.setServiceParent(application) -m.log_rotation.rotateLength = rotateLength -m.log_rotation.maxRotatedFiles = maxRotatedFiles diff --git a/buildheader/buildbot/masterftfs/check.py b/buildheader/buildbot/masterftfs/check.py deleted file mode 100644 index b97c3078d..000000000 --- a/buildheader/buildbot/masterftfs/check.py +++ /dev/null @@ -1,16 +0,0 @@ -#! /bin/python -import sys - -try: - if(len(sys.argv) <= 1): - print("check.py should be run with the name of the output file to check.") - exit() - - check_file = sys.argv[1] - checkf = open(check_file, "r") - for line in checkf: - stop_str = "end trace" - if stop_str in line: - print line -except: - print "there is a exception, please check the code" diff --git a/buildheader/buildbot/masterftfs/master.cfg b/buildheader/buildbot/masterftfs/master.cfg deleted file mode 100644 index 31599262d..000000000 --- a/buildheader/buildbot/masterftfs/master.cfg +++ /dev/null @@ -1,129 +0,0 @@ -# -*- python -*- -# ex: set syntax=python: - -# This is a sample buildmaster config file. It must be installed as -# 'master.cfg' in your buildmaster's base directory. - -# This is the dictionary that the buildmaster pays attention to. We also use -# a shorter alias to save typing. -c = BuildmasterConfig = {} - -####### BUILDSLAVES - -# The 'slaves' list defines the set of recognized buildslaves. Each element is -# a BuildSlave object, specifying a unique slave name and password. The same -# slave name and password must be configured on the slave. -from buildbot.buildslave import BuildSlave -c['slaves'] = [BuildSlave("slave-ftfs", "password123")] - -# 'slavePortnum' defines the TCP port to listen on for connections from slaves. -# This must match the value configured into the buildslaves (with their -# --master option) -c['slavePortnum'] = 9989 - -####### CHANGESOURCES - -# the 'change_source' setting tells the buildmaster how it should find out -# about source code changes. Here we point to the buildbot clone of pyflakes. - -from buildbot.changes.gitpoller import GitPoller -c['change_source'] = [] -c['change_source'].append(GitPoller( - 'git@camilla.oscar.cs.stonybrook.edu:ft-index.git', - workdir='masterbuild', branch='master', - pollinterval=300)) - -####### SCHEDULERS - -# Configure the Schedulers, which decide how to react to incoming changes. In this -# case, just kick off a 'runtests' build - -from buildbot.schedulers.basic import SingleBranchScheduler -from buildbot.schedulers.forcesched import ForceScheduler -from buildbot.changes import filter -c['schedulers'] = [] -c['schedulers'].append(SingleBranchScheduler( - name="master", - change_filter=filter.ChangeFilter(branch='master'), - treeStableTimer=None, - builderNames=["runtests"])) -c['schedulers'].append(ForceScheduler( - name="force", - builderNames=["runtests"])) - -####### BUILDERS - -# The 'builders' list defines the Builders, which tell Buildbot how to perform a build: -# what steps, and which slaves can execute them. Note that any particular build will -# only take place on one slave. - -from buildbot.process.factory import BuildFactory -from buildbot.steps.source.git import Git -from buildbot.steps.shell import ShellCommand - -factory = BuildFactory() -# run the tests (note that this will require that 'trial' is installed) -factory.addStep(ShellCommand(command=["/home/ftfs/masterftfs/test.sh"])) - -from buildbot.config import BuilderConfig - -c['builders'] = [] -c['builders'].append( - BuilderConfig(name="runtests", - slavenames=["slave-ftfs"], - factory=factory)) - -####### STATUS TARGETS - -# 'status' is a list of Status Targets. The results of each build will be -# pushed to these targets. buildbot/status/*.py has a variety to choose from, -# including web pages, email senders, and IRC bots. - -c['status'] = [] - -from buildbot.status import html -from buildbot.status.web import authz, auth - -authz_cfg=authz.Authz( - # change any of these to True to enable; see the manual for more - # options - auth=auth.BasicAuth([("ftfs","password123")]), - gracefulShutdown = False, - forceBuild = 'auth', # use this to test your slave once it is set up - forceAllBuilds = 'auth', - pingBuilder = 'auth', - stopBuild = 'auth', - stopAllBuilds = 'auth', - cancelPendingBuild = 'auth', -) -c['status'].append(html.WebStatus(http_port=8010, authz=authz_cfg)) - -from buildbot.status import mail - -c['status'].append(mail.MailNotifier(fromaddr='oscar.sbu@gmail.com', - mode=['failing', 'warnings'], - extraRecipients=['ftfs@lists.cs.stonybrook.edu'])) -####### PROJECT IDENTITY - -# the 'title' string will appear at the top of this buildbot -# installation's html.WebStatus home page (linked to the -# 'titleURL') and is embedded in the title of the waterfall HTML page. - -c['title'] = "FTFS" -c['titleURL'] = "https://sites.google.com/a/stonybrook.edu/ftfs/home" - -# the 'buildbotURL' string should point to the location where the buildbot's -# internal web server (usually the html.WebStatus page) is visible. This -# typically uses the port number set in the Waterfall 'status' entry, but -# with an externally-visible host name which the buildbot cannot figure out -# without some help. - -c['buildbotURL'] = "http://localhost:8010/" - -####### DB URL - -c['db'] = { - # This specifies what database buildbot uses to store its state. You can leave - # this at its default for all but the largest installations. - 'db_url' : "sqlite:///state.sqlite", -} diff --git a/buildheader/buildbot/masterftfs/poweroff.sh b/buildheader/buildbot/masterftfs/poweroff.sh deleted file mode 100755 index 08d269815..000000000 --- a/buildheader/buildbot/masterftfs/poweroff.sh +++ /dev/null @@ -1 +0,0 @@ -VBoxManage controlvm FTFSTest poweroff diff --git a/buildheader/buildbot/masterftfs/send_email.py b/buildheader/buildbot/masterftfs/send_email.py deleted file mode 100755 index fdb8b28c8..000000000 --- a/buildheader/buildbot/masterftfs/send_email.py +++ /dev/null @@ -1,34 +0,0 @@ -#! /usr/bin/python - -import smtplib -from email.mime.text import MIMEText - - -gmail_user = "ftfs.sb@gmail.com" -gmail_pwd = "ftfs2014ABC" -FROM = 'ftfs.sb@gmail.com' -TO = 'yjiao@cs.stonybrook.edu' - -textfile="ftfs-2014-05-23-18-20-54.out" -fp = open(textfile, 'rb') -msg = MIMEText(fp.read()) -fp.close() - -msg['Subject']= 'ftfs error log: %s' % textfile -msg['From']= FROM -msg['To']= TO - -try: - #server = smtplib.SMTP(SERVER) - server = smtplib.SMTP("smtp.gmail.com", 587) #or port 465 doesn't seem to work! - server.ehlo() - server.starttls() - server.login(gmail_user, gmail_pwd) - server.sendmail(FROM, [TO], msg.as_string()) - #server.quit() - server.close() - print 'successfully sent the mail' -except: - print "failed to send mail" - - diff --git a/buildheader/buildbot/masterftfs/test.sh b/buildheader/buildbot/masterftfs/test.sh deleted file mode 100755 index 0131294fa..000000000 --- a/buildheader/buildbot/masterftfs/test.sh +++ /dev/null @@ -1,35 +0,0 @@ -#! /bin/bash -# Shutdown the VM and then turn it on again - -STATE=$(VBoxManage showvminfo "FTFSTest" --machinereadable | grep 'VMState=' | cut -d '"' -f2) - -if [ "$STATE" != "poweroff" ] -then - VBoxManage controlvm FTFSTest poweroff - sleep 10 -else - echo "The virtual machine is powered off already... " -fi - -# to set up COM1 -VBoxManage modifyvm FTFSTest --uart1 0x3F8 4 - -NOW=`date +"%Y-%m-%d-%H-%M-%S"` - -# link it to physical port ttyS0 -VBoxManage modifyvm FTFSTest --uartmode1 file ftfs-${NOW}.out - -# start the VM -VBoxManage startvm FTFSTest || exit #? -sleep 2m - - -GUEST_IP="130.245.153.150" -# Host name is slave -# See /etc/hosts - -EXE=/home/ftfs/ft-index/ftfs/userspace-testing/run-tests.py -ARG=/home/ftfs/ft-index/ftfs/userspace-testing/simple.tests - -ssh slave "/home/ftfs/yzj_test.sh < /dev/null > /home/ftfs/logfile 2>&1 &" - diff --git a/buildheader/buildbot/masterftfs/testcommand b/buildheader/buildbot/masterftfs/testcommand deleted file mode 100644 index cf9360b17..000000000 --- a/buildheader/buildbot/masterftfs/testcommand +++ /dev/null @@ -1 +0,0 @@ -exec ./test.sh diff --git a/locktree/tests/CMakeLists.txt b/locktree/tests/CMakeLists.txt deleted file mode 100644 index 47ec4d884..000000000 --- a/locktree/tests/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -if(BUILD_TESTING) - function(add_locktree_test bin) - add_toku_test(locktree ${bin} ${ARGN}) - endfunction(add_locktree_test) - - file(GLOB srcs *.cc) - foreach(src ${srcs}) - get_filename_component(base ${src} NAME_WE) - - add_executable(${base} ${base}) - add_space_separated_property(TARGET ${base} COMPILE_FLAGS -fvisibility=hidden) - target_link_libraries(${base} locktree ft ${LIBTOKUPORTABILITY}) - add_locktree_test(${base}) - endforeach(src) -endif(BUILD_TESTING) diff --git a/locktree/tests/concurrent_tree_create_destroy.cc b/locktree/tests/concurrent_tree_create_destroy.cc deleted file mode 100644 index f6bb3987d..000000000 --- a/locktree/tests/concurrent_tree_create_destroy.cc +++ /dev/null @@ -1,121 +0,0 @@ -/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: -#ident "$Id$" -/* -COPYING CONDITIONS NOTICE: - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation, and provided that the - following conditions are met: - - * Redistributions of source code must retain this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below). - - * Redistributions in binary form must reproduce this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below) in the documentation and/or other materials - provided with the distribution. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -COPYRIGHT NOTICE: - - TokuDB, Tokutek Fractal Tree Indexing Library. - Copyright (C) 2007-2013 Tokutek, Inc. - -DISCLAIMER: - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - -UNIVERSITY PATENT NOTICE: - - The technology is licensed by the Massachusetts Institute of - Technology, Rutgers State University of New Jersey, and the Research - Foundation of State University of New York at Stony Brook under - United States of America Serial No. 11/760379 and to the patents - and/or patent applications resulting from it. - -PATENT MARKING NOTICE: - - This software is covered by US Patent No. 8,185,551. - This software is covered by US Patent No. 8,489,638. - -PATENT RIGHTS GRANT: - - "THIS IMPLEMENTATION" means the copyrightable works distributed by - Tokutek as part of the Fractal Tree project. - - "PATENT CLAIMS" means the claims of patents that are owned or - licensable by Tokutek, both currently or in the future; and that in - the absence of this license would be infringed by THIS - IMPLEMENTATION or by using or running THIS IMPLEMENTATION. - - "PATENT CHALLENGE" shall mean a challenge to the validity, - patentability, enforceability and/or non-infringement of any of the - PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS. - - Tokutek hereby grants to you, for the term and geographical scope of - the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free, - irrevocable (except as stated in this section) patent license to - make, have made, use, offer to sell, sell, import, transfer, and - otherwise run, modify, and propagate the contents of THIS - IMPLEMENTATION, where such license applies only to the PATENT - CLAIMS. This grant does not include claims that would be infringed - only as a consequence of further modifications of THIS - IMPLEMENTATION. If you or your agent or licensee institute or order - or agree to the institution of patent litigation against any entity - (including a cross-claim or counterclaim in a lawsuit) alleging that - THIS IMPLEMENTATION constitutes direct or contributory patent - infringement, or inducement of patent infringement, then any rights - granted to you under this License shall terminate as of the date - such litigation is filed. If you or your agent or exclusive - licensee institute or order or agree to the institution of a PATENT - CHALLENGE, then Tokutek may terminate any rights granted to you - under this License. -*/ - -#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved." -#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." - -#include "concurrent_tree_unit_test.h" - -namespace toku { - -static comparator cmp; - -// test that creating a concurrent tree puts it in a valid, empty state. -// the root node should be properly marked and have the correct comparator. -void concurrent_tree_unit_test::test_create_destroy(void) { - concurrent_tree tree; - tree.create(&cmp); - - invariant(tree.m_root.is_root()); - invariant(tree.m_root.is_empty()); - invariant(tree.m_root.m_cmp == &cmp); - invariant_null(tree.m_root.m_left_child.ptr); - invariant_null(tree.m_root.m_right_child.ptr); - - invariant(tree.is_empty()); - - tree.destroy(); -} - -} /* namespace toku */ - -int main(void) { - toku::concurrent_tree_unit_test test; - test.test_create_destroy(); - return 0; -} diff --git a/locktree/tests/concurrent_tree_lkr_acquire_release.cc b/locktree/tests/concurrent_tree_lkr_acquire_release.cc deleted file mode 100644 index ecf683ed8..000000000 --- a/locktree/tests/concurrent_tree_lkr_acquire_release.cc +++ /dev/null @@ -1,171 +0,0 @@ -/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: -#ident "$Id$" -/* -COPYING CONDITIONS NOTICE: - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation, and provided that the - following conditions are met: - - * Redistributions of source code must retain this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below). - - * Redistributions in binary form must reproduce this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below) in the documentation and/or other materials - provided with the distribution. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -COPYRIGHT NOTICE: - - TokuDB, Tokutek Fractal Tree Indexing Library. - Copyright (C) 2007-2013 Tokutek, Inc. - -DISCLAIMER: - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - -UNIVERSITY PATENT NOTICE: - - The technology is licensed by the Massachusetts Institute of - Technology, Rutgers State University of New Jersey, and the Research - Foundation of State University of New York at Stony Brook under - United States of America Serial No. 11/760379 and to the patents - and/or patent applications resulting from it. - -PATENT MARKING NOTICE: - - This software is covered by US Patent No. 8,185,551. - This software is covered by US Patent No. 8,489,638. - -PATENT RIGHTS GRANT: - - "THIS IMPLEMENTATION" means the copyrightable works distributed by - Tokutek as part of the Fractal Tree project. - - "PATENT CLAIMS" means the claims of patents that are owned or - licensable by Tokutek, both currently or in the future; and that in - the absence of this license would be infringed by THIS - IMPLEMENTATION or by using or running THIS IMPLEMENTATION. - - "PATENT CHALLENGE" shall mean a challenge to the validity, - patentability, enforceability and/or non-infringement of any of the - PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS. - - Tokutek hereby grants to you, for the term and geographical scope of - the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free, - irrevocable (except as stated in this section) patent license to - make, have made, use, offer to sell, sell, import, transfer, and - otherwise run, modify, and propagate the contents of THIS - IMPLEMENTATION, where such license applies only to the PATENT - CLAIMS. This grant does not include claims that would be infringed - only as a consequence of further modifications of THIS - IMPLEMENTATION. If you or your agent or licensee institute or order - or agree to the institution of patent litigation against any entity - (including a cross-claim or counterclaim in a lawsuit) alleging that - THIS IMPLEMENTATION constitutes direct or contributory patent - infringement, or inducement of patent infringement, then any rights - granted to you under this License shall terminate as of the date - such litigation is filed. If you or your agent or exclusive - licensee institute or order or agree to the institution of a PATENT - CHALLENGE, then Tokutek may terminate any rights granted to you - under this License. -*/ - -#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved." -#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." - -#include "concurrent_tree_unit_test.h" - -namespace toku { - -void concurrent_tree_unit_test::test_lkr_acquire_release(void) { - comparator cmp; - cmp.create(compare_dbts, nullptr); - - // we'll test a tree that has values 0..20 - const uint64_t min = 0; - const uint64_t max = 20; - - // acquire/release should work regardless of how the - // data was inserted into the tree, so we test it - // on a tree whose elements were populated starting - // at each value 0..20 (so we get different rotation - // behavior for each starting value in the tree). - for (uint64_t start = min; start <= max; start++) { - concurrent_tree tree; - tree.create(&cmp); - populate_tree(&tree, start, min, max); - invariant(!tree.is_empty()); - - for (uint64_t i = 0; i <= max; i++) { - concurrent_tree::locked_keyrange lkr; - lkr.prepare(&tree); - invariant(lkr.m_tree == &tree); - invariant(lkr.m_subtree->is_root()); - - keyrange range; - range.create(get_dbt(i), get_dbt(i)); - lkr.acquire(range); - // the tree is not empty so the subtree root should not be empty - invariant(!lkr.m_subtree->is_empty()); - - // if the subtree root does not overlap then one of its children - // must exist and have an overlapping range. - if (!lkr.m_subtree->m_range.overlaps(&cmp, range)) { - treenode *left = lkr.m_subtree->m_left_child.ptr; - treenode *right = lkr.m_subtree->m_right_child.ptr; - if (left != nullptr) { - // left exists, so if it does not overlap then the right must - if (!left->m_range.overlaps(&cmp, range)) { - invariant_notnull(right); - invariant(right->m_range.overlaps(&cmp, range)); - } - } else { - // no left child, so the right must exist and be overlapping - invariant_notnull(right); - invariant(right->m_range.overlaps(&cmp, range)); - } - } - - lkr.release(); - } - - // remove everything one by one and then destroy - keyrange range; - concurrent_tree::locked_keyrange lkr; - lkr.prepare(&tree); - invariant(lkr.m_subtree->is_root()); - range.create(get_dbt(min), get_dbt(max)); - lkr.acquire(range); - invariant(lkr.m_subtree->is_root()); - for (uint64_t i = 0; i <= max; i++) { - range.create(get_dbt(i), get_dbt(i)); - lkr.remove(range); - } - lkr.release(); - tree.destroy(); - } -} - -} /* namespace toku */ - -int main(void) { - toku::concurrent_tree_unit_test test; - test.test_lkr_acquire_release(); - return 0; -} diff --git a/locktree/tests/concurrent_tree_lkr_insert_remove.cc b/locktree/tests/concurrent_tree_lkr_insert_remove.cc deleted file mode 100644 index ae71cda45..000000000 --- a/locktree/tests/concurrent_tree_lkr_insert_remove.cc +++ /dev/null @@ -1,210 +0,0 @@ -/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: -#ident "$Id$" -/* -COPYING CONDITIONS NOTICE: - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation, and provided that the - following conditions are met: - - * Redistributions of source code must retain this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below). - - * Redistributions in binary form must reproduce this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below) in the documentation and/or other materials - provided with the distribution. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -COPYRIGHT NOTICE: - - TokuDB, Tokutek Fractal Tree Indexing Library. - Copyright (C) 2007-2013 Tokutek, Inc. - -DISCLAIMER: - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - -UNIVERSITY PATENT NOTICE: - - The technology is licensed by the Massachusetts Institute of - Technology, Rutgers State University of New Jersey, and the Research - Foundation of State University of New York at Stony Brook under - United States of America Serial No. 11/760379 and to the patents - and/or patent applications resulting from it. - -PATENT MARKING NOTICE: - - This software is covered by US Patent No. 8,185,551. - This software is covered by US Patent No. 8,489,638. - -PATENT RIGHTS GRANT: - - "THIS IMPLEMENTATION" means the copyrightable works distributed by - Tokutek as part of the Fractal Tree project. - - "PATENT CLAIMS" means the claims of patents that are owned or - licensable by Tokutek, both currently or in the future; and that in - the absence of this license would be infringed by THIS - IMPLEMENTATION or by using or running THIS IMPLEMENTATION. - - "PATENT CHALLENGE" shall mean a challenge to the validity, - patentability, enforceability and/or non-infringement of any of the - PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS. - - Tokutek hereby grants to you, for the term and geographical scope of - the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free, - irrevocable (except as stated in this section) patent license to - make, have made, use, offer to sell, sell, import, transfer, and - otherwise run, modify, and propagate the contents of THIS - IMPLEMENTATION, where such license applies only to the PATENT - CLAIMS. This grant does not include claims that would be infringed - only as a consequence of further modifications of THIS - IMPLEMENTATION. If you or your agent or licensee institute or order - or agree to the institution of patent litigation against any entity - (including a cross-claim or counterclaim in a lawsuit) alleging that - THIS IMPLEMENTATION constitutes direct or contributory patent - infringement, or inducement of patent infringement, then any rights - granted to you under this License shall terminate as of the date - such litigation is filed. If you or your agent or exclusive - licensee institute or order or agree to the institution of a PATENT - CHALLENGE, then Tokutek may terminate any rights granted to you - under this License. -*/ - -#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved." -#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." - -#include "concurrent_tree_unit_test.h" - -namespace toku { - -// "random" (derived from the digits of PI) but deterministic keys -const uint64_t keys[] = { - 141, 592, 653, 589, 793, 238, 462, 643, 383, 327, 950, 288, 419, - 716, 939, 937, 510, 582, 97, 494, 459, 230, 781, 640, 628, 620, 899, - 862, 803, 482, 534, 211, 706, 798, 214, 808, 651, 328, 239, 664, 709, - 384, 460, 955, 58, 223, 172, 535, 940, 812, 848, -}; -const uint64_t num_keys = sizeof(keys) / sizeof(keys[0]); - -static const DBT *get_ith_key_from_set(uint64_t i) { - return get_dbt(keys[i]); -} - -static void verify_unique_keys(void) { - for (uint64_t i = 0; i < num_keys; i++) { - for (uint64_t j = 0; j < num_keys; j++) { - if (i != j) { - invariant(keys[i] != keys[j]); - } - } - } -} - -static uint64_t check_for_range_and_count(concurrent_tree::locked_keyrange *lkr, - comparator *cmp, const keyrange &range, bool range_should_exist) { - - struct check_fn_obj { - comparator *cmp; - uint64_t count; - keyrange target_range; - bool target_range_found; - - bool fn(const keyrange &query_range, TXNID txnid) { - (void) txnid; - if (query_range.compare(cmp, target_range) == keyrange::comparison::EQUALS) { - invariant(!target_range_found); - target_range_found = true; - } - count++; - return true; - } - } check_fn; - check_fn.cmp = cmp; - check_fn.count = 0; - check_fn.target_range = range; - check_fn.target_range_found = false; - - lkr->iterate(&check_fn); - - if (range_should_exist) { - invariant(check_fn.target_range_found); - } else { - invariant(!check_fn.target_range_found); - } - return check_fn.count; -} - -// test that insert/remove work properly together, confirming -// whether keys exist using iterate() -void concurrent_tree_unit_test::test_lkr_insert_remove(void) { - verify_unique_keys(); - comparator cmp; - cmp.create(compare_dbts, nullptr); - - concurrent_tree tree; - tree.create(&cmp); - - // prepare and acquire the infinte range - concurrent_tree::locked_keyrange lkr; - lkr.prepare(&tree); - lkr.acquire(keyrange::get_infinite_range()); - - // populate the tree with all the keys - uint64_t n; - const uint64_t cap = 15; - for (uint64_t i = 0; i < num_keys; i++) { - keyrange range; - range.create(get_ith_key_from_set(i), get_ith_key_from_set(i)); - // insert an element. it should exist and the - // count should be correct. - lkr.insert(range, i); - n = check_for_range_and_count(&lkr, &cmp, range, true); - if (i >= cap) { - invariant(n == cap + 1); - // remove an element previously inserted. it should - // no longer exist and the count should be correct. - range.create(get_ith_key_from_set(i - cap), get_ith_key_from_set(i - cap)); - lkr.remove(range); - n = check_for_range_and_count(&lkr, &cmp, range, false); - invariant(n == cap); - } else { - invariant(n == i + 1); - } - } - - // clean up the rest of the keys - for (uint64_t i = 0; i < cap; i++) { - keyrange range; - range.create(get_ith_key_from_set(num_keys - i - 1), get_ith_key_from_set(num_keys - i - 1)); - lkr.remove(range); - n = check_for_range_and_count(&lkr, &cmp, range, false); - invariant(n == (cap - i - 1)); - } - - lkr.release(); - tree.destroy(); -} - -} /* namespace toku */ - -int main(void) { - toku::concurrent_tree_unit_test test; - test.test_lkr_insert_remove(); - return 0; -} diff --git a/locktree/tests/concurrent_tree_lkr_insert_serial_large.cc b/locktree/tests/concurrent_tree_lkr_insert_serial_large.cc deleted file mode 100644 index 5f0f81dc2..000000000 --- a/locktree/tests/concurrent_tree_lkr_insert_serial_large.cc +++ /dev/null @@ -1,147 +0,0 @@ -/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: -#ident "$Id$" -/* -COPYING CONDITIONS NOTICE: - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation, and provided that the - following conditions are met: - - * Redistributions of source code must retain this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below). - - * Redistributions in binary form must reproduce this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below) in the documentation and/or other materials - provided with the distribution. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -COPYRIGHT NOTICE: - - TokuDB, Tokutek Fractal Tree Indexing Library. - Copyright (C) 2007-2013 Tokutek, Inc. - -DISCLAIMER: - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - -UNIVERSITY PATENT NOTICE: - - The technology is licensed by the Massachusetts Institute of - Technology, Rutgers State University of New Jersey, and the Research - Foundation of State University of New York at Stony Brook under - United States of America Serial No. 11/760379 and to the patents - and/or patent applications resulting from it. - -PATENT MARKING NOTICE: - - This software is covered by US Patent No. 8,185,551. - This software is covered by US Patent No. 8,489,638. - -PATENT RIGHTS GRANT: - - "THIS IMPLEMENTATION" means the copyrightable works distributed by - Tokutek as part of the Fractal Tree project. - - "PATENT CLAIMS" means the claims of patents that are owned or - licensable by Tokutek, both currently or in the future; and that in - the absence of this license would be infringed by THIS - IMPLEMENTATION or by using or running THIS IMPLEMENTATION. - - "PATENT CHALLENGE" shall mean a challenge to the validity, - patentability, enforceability and/or non-infringement of any of the - PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS. - - Tokutek hereby grants to you, for the term and geographical scope of - the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free, - irrevocable (except as stated in this section) patent license to - make, have made, use, offer to sell, sell, import, transfer, and - otherwise run, modify, and propagate the contents of THIS - IMPLEMENTATION, where such license applies only to the PATENT - CLAIMS. This grant does not include claims that would be infringed - only as a consequence of further modifications of THIS - IMPLEMENTATION. If you or your agent or licensee institute or order - or agree to the institution of patent litigation against any entity - (including a cross-claim or counterclaim in a lawsuit) alleging that - THIS IMPLEMENTATION constitutes direct or contributory patent - infringement, or inducement of patent infringement, then any rights - granted to you under this License shall terminate as of the date - such litigation is filed. If you or your agent or exclusive - licensee institute or order or agree to the institution of a PATENT - CHALLENGE, then Tokutek may terminate any rights granted to you - under this License. -*/ - -#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved." -#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." - -#include - -#include "concurrent_tree_unit_test.h" - -namespace toku { - -// This is intended to be a black-box test for the concurrent_tree's -// ability to rebalance in the face of many serial insertions. -// If the code survives many inserts, it is considered successful. -void concurrent_tree_unit_test::test_lkr_insert_serial_large(void) { - comparator cmp; - cmp.create(compare_dbts, nullptr); - - concurrent_tree tree; - tree.create(&cmp); - - // prepare and acquire the infinte range - concurrent_tree::locked_keyrange lkr; - lkr.prepare(&tree); - lkr.acquire(keyrange::get_infinite_range()); - - // 128k keys should be fairly stressful. - // a bad tree will flatten and die way earlier than 128k inserts. - // a good tree will rebalance and reach height logn(128k) ~= 17, - // survival the onslaught of inserts. - const uint64_t num_keys = 128 * 1024; - - // populate the tree with all the keys - for (uint64_t i = 0; i < num_keys; i++) { - DBT k; - toku_fill_dbt(&k, &i, sizeof(i)); - keyrange range; - range.create(&k, &k); - lkr.insert(range, i); - } - - // remove all of the keys - for (uint64_t i = 0; i < num_keys; i++) { - DBT k; - toku_fill_dbt(&k, &i, sizeof(i)); - keyrange range; - range.create(&k, &k); - lkr.remove(range); - } - - lkr.release(); - tree.destroy(); -} - -} /* namespace toku */ - -int main(void) { - toku::concurrent_tree_unit_test test; - test.test_lkr_insert_serial_large(); - return 0; -} diff --git a/locktree/tests/concurrent_tree_lkr_remove_all.cc b/locktree/tests/concurrent_tree_lkr_remove_all.cc deleted file mode 100644 index c7d5f4d32..000000000 --- a/locktree/tests/concurrent_tree_lkr_remove_all.cc +++ /dev/null @@ -1,143 +0,0 @@ -/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: -#ident "$Id$" -/* -COPYING CONDITIONS NOTICE: - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation, and provided that the - following conditions are met: - - * Redistributions of source code must retain this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below). - - * Redistributions in binary form must reproduce this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below) in the documentation and/or other materials - provided with the distribution. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -COPYRIGHT NOTICE: - - TokuDB, Tokutek Fractal Tree Indexing Library. - Copyright (C) 2007-2013 Tokutek, Inc. - -DISCLAIMER: - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - -UNIVERSITY PATENT NOTICE: - - The technology is licensed by the Massachusetts Institute of - Technology, Rutgers State University of New Jersey, and the Research - Foundation of State University of New York at Stony Brook under - United States of America Serial No. 11/760379 and to the patents - and/or patent applications resulting from it. - -PATENT MARKING NOTICE: - - This software is covered by US Patent No. 8,185,551. - This software is covered by US Patent No. 8,489,638. - -PATENT RIGHTS GRANT: - - "THIS IMPLEMENTATION" means the copyrightable works distributed by - Tokutek as part of the Fractal Tree project. - - "PATENT CLAIMS" means the claims of patents that are owned or - licensable by Tokutek, both currently or in the future; and that in - the absence of this license would be infringed by THIS - IMPLEMENTATION or by using or running THIS IMPLEMENTATION. - - "PATENT CHALLENGE" shall mean a challenge to the validity, - patentability, enforceability and/or non-infringement of any of the - PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS. - - Tokutek hereby grants to you, for the term and geographical scope of - the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free, - irrevocable (except as stated in this section) patent license to - make, have made, use, offer to sell, sell, import, transfer, and - otherwise run, modify, and propagate the contents of THIS - IMPLEMENTATION, where such license applies only to the PATENT - CLAIMS. This grant does not include claims that would be infringed - only as a consequence of further modifications of THIS - IMPLEMENTATION. If you or your agent or licensee institute or order - or agree to the institution of patent litigation against any entity - (including a cross-claim or counterclaim in a lawsuit) alleging that - THIS IMPLEMENTATION constitutes direct or contributory patent - infringement, or inducement of patent infringement, then any rights - granted to you under this License shall terminate as of the date - such litigation is filed. If you or your agent or exclusive - licensee institute or order or agree to the institution of a PATENT - CHALLENGE, then Tokutek may terminate any rights granted to you - under this License. -*/ - -#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved." -#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." - -#include "concurrent_tree_unit_test.h" - -namespace toku { - -// remove_all on a locked keyrange should properly remove everything -// from the tree and account correctly for the amount of memory released. -void concurrent_tree_unit_test::test_lkr_remove_all(void) { - comparator cmp; - cmp.create(compare_dbts, nullptr); - - // we'll test a tree that has values 0..20 - const uint64_t min = 0; - const uint64_t max = 20; - - // remove_all should work regardless of how the - // data was inserted into the tree, so we test it - // on a tree whose elements were populated starting - // at each value 0..20 (so we get different rotation - // behavior for each starting value in the tree). - for (uint64_t start = min; start <= max; start++) { - concurrent_tree tree; - concurrent_tree::locked_keyrange lkr; - - tree.create(&cmp); - populate_tree(&tree, start, min, max); - invariant(!tree.is_empty()); - - lkr.prepare(&tree); - invariant(lkr.m_subtree->is_root()); - invariant(!lkr.m_subtree->is_empty()); - - // remove_all() from the locked keyrange and assert that - // the number of elements and memory removed is correct. - lkr.remove_all(); - - invariant(lkr.m_subtree->is_empty()); - invariant(tree.is_empty()); - invariant_null(tree.m_root.m_right_child.ptr); - invariant_null(tree.m_root.m_left_child.ptr); - - lkr.release(); - tree.destroy(); - } -} - -} /* namespace toku */ - -int main(void) { - toku::concurrent_tree_unit_test test; - test.test_lkr_remove_all(); - return 0; -} diff --git a/locktree/tests/concurrent_tree_unit_test.h b/locktree/tests/concurrent_tree_unit_test.h deleted file mode 100644 index bda34978e..000000000 --- a/locktree/tests/concurrent_tree_unit_test.h +++ /dev/null @@ -1,146 +0,0 @@ -/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: -#ident "$Id$" -/* -COPYING CONDITIONS NOTICE: - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation, and provided that the - following conditions are met: - - * Redistributions of source code must retain this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below). - - * Redistributions in binary form must reproduce this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below) in the documentation and/or other materials - provided with the distribution. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -COPYRIGHT NOTICE: - - TokuDB, Tokutek Fractal Tree Indexing Library. - Copyright (C) 2007-2013 Tokutek, Inc. - -DISCLAIMER: - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - -UNIVERSITY PATENT NOTICE: - - The technology is licensed by the Massachusetts Institute of - Technology, Rutgers State University of New Jersey, and the Research - Foundation of State University of New York at Stony Brook under - United States of America Serial No. 11/760379 and to the patents - and/or patent applications resulting from it. - -PATENT MARKING NOTICE: - - This software is covered by US Patent No. 8,185,551. - This software is covered by US Patent No. 8,489,638. - -PATENT RIGHTS GRANT: - - "THIS IMPLEMENTATION" means the copyrightable works distributed by - Tokutek as part of the Fractal Tree project. - - "PATENT CLAIMS" means the claims of patents that are owned or - licensable by Tokutek, both currently or in the future; and that in - the absence of this license would be infringed by THIS - IMPLEMENTATION or by using or running THIS IMPLEMENTATION. - - "PATENT CHALLENGE" shall mean a challenge to the validity, - patentability, enforceability and/or non-infringement of any of the - PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS. - - Tokutek hereby grants to you, for the term and geographical scope of - the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free, - irrevocable (except as stated in this section) patent license to - make, have made, use, offer to sell, sell, import, transfer, and - otherwise run, modify, and propagate the contents of THIS - IMPLEMENTATION, where such license applies only to the PATENT - CLAIMS. This grant does not include claims that would be infringed - only as a consequence of further modifications of THIS - IMPLEMENTATION. If you or your agent or licensee institute or order - or agree to the institution of patent litigation against any entity - (including a cross-claim or counterclaim in a lawsuit) alleging that - THIS IMPLEMENTATION constitutes direct or contributory patent - infringement, or inducement of patent infringement, then any rights - granted to you under this License shall terminate as of the date - such litigation is filed. If you or your agent or exclusive - licensee institute or order or agree to the institution of a PATENT - CHALLENGE, then Tokutek may terminate any rights granted to you - under this License. -*/ - -#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved." -#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." - -#include "test.h" - -#include - -namespace toku { - -class concurrent_tree_unit_test { -public: - // creating a concurrent tree should initialize it to a valid, - // empty state. the root node should be properly marked, have - // no children, and the correct comparator. - void test_create_destroy(void); - - // acquiring a locked keyrange should lock and "root" itself at - // the proper subtree node. releasing it should unlock that node. - void test_lkr_acquire_release(void); - - // remove_all on a locked keyrange should properly remove everything - // from the tree and account correctly for the amount of memory released. - void test_lkr_remove_all(void); - - // test that insert/remove work properly together, confirming - // whether keys exist using iterate() - void test_lkr_insert_remove(void); - - // test that the concurrent tree can survive many serial inserts - // this is a blackbox test for tree rotations. - void test_lkr_insert_serial_large(void); - -private: - - // populate the given concurrent tree with elements from min..max but - // starting with a certain element. this allows the caller to modestly - // control the way the tree is built/rotated, for test variability. - static void populate_tree(concurrent_tree *tree, uint64_t start, uint64_t min, uint64_t max) { - concurrent_tree::locked_keyrange lkr; - lkr.prepare(tree); - lkr.acquire(keyrange::get_infinite_range()); - - for (uint64_t i = start; i <= max; i++) { - keyrange range; - range.create(get_dbt(i), get_dbt(i)); - lkr.insert(range, i); - } - for (uint64_t i = min; i < start; i++) { - keyrange range; - range.create(get_dbt(i), get_dbt(i)); - lkr.insert(range, i); - } - - lkr.release(); - } -}; - -} /* namespace toku */ diff --git a/locktree/tests/lock_request_create_set.cc b/locktree/tests/lock_request_create_set.cc deleted file mode 100644 index b309d9b6f..000000000 --- a/locktree/tests/lock_request_create_set.cc +++ /dev/null @@ -1,125 +0,0 @@ -/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: -#ident "$Id$" -/* -COPYING CONDITIONS NOTICE: - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation, and provided that the - following conditions are met: - - * Redistributions of source code must retain this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below). - - * Redistributions in binary form must reproduce this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below) in the documentation and/or other materials - provided with the distribution. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -COPYRIGHT NOTICE: - - TokuDB, Tokutek Fractal Tree Indexing Library. - Copyright (C) 2007-2013 Tokutek, Inc. - -DISCLAIMER: - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - -UNIVERSITY PATENT NOTICE: - - The technology is licensed by the Massachusetts Institute of - Technology, Rutgers State University of New Jersey, and the Research - Foundation of State University of New York at Stony Brook under - United States of America Serial No. 11/760379 and to the patents - and/or patent applications resulting from it. - -PATENT MARKING NOTICE: - - This software is covered by US Patent No. 8,185,551. - This software is covered by US Patent No. 8,489,638. - -PATENT RIGHTS GRANT: - - "THIS IMPLEMENTATION" means the copyrightable works distributed by - Tokutek as part of the Fractal Tree project. - - "PATENT CLAIMS" means the claims of patents that are owned or - licensable by Tokutek, both currently or in the future; and that in - the absence of this license would be infringed by THIS - IMPLEMENTATION or by using or running THIS IMPLEMENTATION. - - "PATENT CHALLENGE" shall mean a challenge to the validity, - patentability, enforceability and/or non-infringement of any of the - PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS. - - Tokutek hereby grants to you, for the term and geographical scope of - the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free, - irrevocable (except as stated in this section) patent license to - make, have made, use, offer to sell, sell, import, transfer, and - otherwise run, modify, and propagate the contents of THIS - IMPLEMENTATION, where such license applies only to the PATENT - CLAIMS. This grant does not include claims that would be infringed - only as a consequence of further modifications of THIS - IMPLEMENTATION. If you or your agent or licensee institute or order - or agree to the institution of patent litigation against any entity - (including a cross-claim or counterclaim in a lawsuit) alleging that - THIS IMPLEMENTATION constitutes direct or contributory patent - infringement, or inducement of patent infringement, then any rights - granted to you under this License shall terminate as of the date - such litigation is filed. If you or your agent or exclusive - licensee institute or order or agree to the institution of a PATENT - CHALLENGE, then Tokutek may terminate any rights granted to you - under this License. -*/ - -#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved." -#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." - -#include "lock_request_unit_test.h" - -namespace toku { - -// create and set the object's internals, destroy should not crash. -void lock_request_unit_test::test_create_destroy(void) { - lock_request request; - request.create(); - - invariant(request.m_txnid == TXNID_NONE); - invariant(request.m_left_key == nullptr); - invariant(request.m_right_key == nullptr); - invariant(request.m_left_key_copy.flags == 0); - invariant(request.m_left_key_copy.data == nullptr); - invariant(request.m_right_key_copy.flags == 0); - invariant(request.m_right_key_copy.data == nullptr); - - invariant(request.m_type == lock_request::type::UNKNOWN); - invariant(request.m_lt == nullptr); - - invariant(request.m_complete_r == 0); - invariant(request.m_state == lock_request::state::UNINITIALIZED); - - request.destroy(); -} - -} - -int main(void) { - toku::lock_request_unit_test test; - test.test_create_destroy(); - return 0; -} - diff --git a/locktree/tests/lock_request_get_set_keys.cc b/locktree/tests/lock_request_get_set_keys.cc deleted file mode 100644 index de4d0bb3a..000000000 --- a/locktree/tests/lock_request_get_set_keys.cc +++ /dev/null @@ -1,141 +0,0 @@ -/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: -#ident "$Id$" -/* -COPYING CONDITIONS NOTICE: - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation, and provided that the - following conditions are met: - - * Redistributions of source code must retain this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below). - - * Redistributions in binary form must reproduce this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below) in the documentation and/or other materials - provided with the distribution. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -COPYRIGHT NOTICE: - - TokuDB, Tokutek Fractal Tree Indexing Library. - Copyright (C) 2007-2013 Tokutek, Inc. - -DISCLAIMER: - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - -UNIVERSITY PATENT NOTICE: - - The technology is licensed by the Massachusetts Institute of - Technology, Rutgers State University of New Jersey, and the Research - Foundation of State University of New York at Stony Brook under - United States of America Serial No. 11/760379 and to the patents - and/or patent applications resulting from it. - -PATENT MARKING NOTICE: - - This software is covered by US Patent No. 8,185,551. - This software is covered by US Patent No. 8,489,638. - -PATENT RIGHTS GRANT: - - "THIS IMPLEMENTATION" means the copyrightable works distributed by - Tokutek as part of the Fractal Tree project. - - "PATENT CLAIMS" means the claims of patents that are owned or - licensable by Tokutek, both currently or in the future; and that in - the absence of this license would be infringed by THIS - IMPLEMENTATION or by using or running THIS IMPLEMENTATION. - - "PATENT CHALLENGE" shall mean a challenge to the validity, - patentability, enforceability and/or non-infringement of any of the - PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS. - - Tokutek hereby grants to you, for the term and geographical scope of - the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free, - irrevocable (except as stated in this section) patent license to - make, have made, use, offer to sell, sell, import, transfer, and - otherwise run, modify, and propagate the contents of THIS - IMPLEMENTATION, where such license applies only to the PATENT - CLAIMS. This grant does not include claims that would be infringed - only as a consequence of further modifications of THIS - IMPLEMENTATION. If you or your agent or licensee institute or order - or agree to the institution of patent litigation against any entity - (including a cross-claim or counterclaim in a lawsuit) alleging that - THIS IMPLEMENTATION constitutes direct or contributory patent - infringement, or inducement of patent infringement, then any rights - granted to you under this License shall terminate as of the date - such litigation is filed. If you or your agent or exclusive - licensee institute or order or agree to the institution of a PATENT - CHALLENGE, then Tokutek may terminate any rights granted to you - under this License. -*/ - -#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved." -#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." - -#include "lock_request_unit_test.h" - -namespace toku { - -// make setting keys and getting them back works properly. -// at a high level, we want to make sure keys are copied -// when appropriate and plays nice with +/- infinity. -void lock_request_unit_test::test_get_set_keys(void) { - lock_request request; - request.create(); - - locktree *const null_lt = nullptr; - - TXNID txnid_a = 1001; - - const DBT *one = get_dbt(1); - const DBT *two = get_dbt(2); - const DBT *neg_inf = toku_dbt_negative_infinity(); - const DBT *pos_inf = toku_dbt_negative_infinity(); - - // request should not copy dbts for neg/pos inf, so get_left - // and get_right should return the same pointer given - request.set(null_lt, txnid_a, neg_inf, pos_inf, lock_request::type::WRITE); - invariant(request.get_left_key() == neg_inf); - invariant(request.get_right_key() == pos_inf); - - // request should make copies of non-infinity-valued keys. - request.set(null_lt, txnid_a, neg_inf, one, lock_request::type::WRITE); - invariant(request.get_left_key() == neg_inf); - invariant(request.get_right_key() == one); - - request.set(null_lt, txnid_a, two, pos_inf, lock_request::type::WRITE); - invariant(request.get_left_key() == two); - invariant(request.get_right_key() == pos_inf); - - request.set(null_lt, txnid_a, one, two, lock_request::type::WRITE); - invariant(request.get_left_key() == one); - invariant(request.get_right_key() == two); - - request.destroy(); -} - -} - -int main(void) { - toku::lock_request_unit_test test; - test.test_get_set_keys(); - return 0; -} - diff --git a/locktree/tests/lock_request_start_deadlock.cc b/locktree/tests/lock_request_start_deadlock.cc deleted file mode 100644 index 6dc622fac..000000000 --- a/locktree/tests/lock_request_start_deadlock.cc +++ /dev/null @@ -1,173 +0,0 @@ -/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: -#ident "$Id$" -/* -COPYING CONDITIONS NOTICE: - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation, and provided that the - following conditions are met: - - * Redistributions of source code must retain this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below). - - * Redistributions in binary form must reproduce this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below) in the documentation and/or other materials - provided with the distribution. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -COPYRIGHT NOTICE: - - TokuDB, Tokutek Fractal Tree Indexing Library. - Copyright (C) 2007-2013 Tokutek, Inc. - -DISCLAIMER: - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - -UNIVERSITY PATENT NOTICE: - - The technology is licensed by the Massachusetts Institute of - Technology, Rutgers State University of New Jersey, and the Research - Foundation of State University of New York at Stony Brook under - United States of America Serial No. 11/760379 and to the patents - and/or patent applications resulting from it. - -PATENT MARKING NOTICE: - - This software is covered by US Patent No. 8,185,551. - This software is covered by US Patent No. 8,489,638. - -PATENT RIGHTS GRANT: - - "THIS IMPLEMENTATION" means the copyrightable works distributed by - Tokutek as part of the Fractal Tree project. - - "PATENT CLAIMS" means the claims of patents that are owned or - licensable by Tokutek, both currently or in the future; and that in - the absence of this license would be infringed by THIS - IMPLEMENTATION or by using or running THIS IMPLEMENTATION. - - "PATENT CHALLENGE" shall mean a challenge to the validity, - patentability, enforceability and/or non-infringement of any of the - PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS. - - Tokutek hereby grants to you, for the term and geographical scope of - the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free, - irrevocable (except as stated in this section) patent license to - make, have made, use, offer to sell, sell, import, transfer, and - otherwise run, modify, and propagate the contents of THIS - IMPLEMENTATION, where such license applies only to the PATENT - CLAIMS. This grant does not include claims that would be infringed - only as a consequence of further modifications of THIS - IMPLEMENTATION. If you or your agent or licensee institute or order - or agree to the institution of patent litigation against any entity - (including a cross-claim or counterclaim in a lawsuit) alleging that - THIS IMPLEMENTATION constitutes direct or contributory patent - infringement, or inducement of patent infringement, then any rights - granted to you under this License shall terminate as of the date - such litigation is filed. If you or your agent or exclusive - licensee institute or order or agree to the institution of a PATENT - CHALLENGE, then Tokutek may terminate any rights granted to you - under this License. -*/ - -#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved." -#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." - -#include "lock_request_unit_test.h" - -namespace toku { - -// make sure deadlocks are detected when a lock request starts -void lock_request_unit_test::test_start_deadlock(void) { - int r; - locktree::manager mgr; - locktree *lt; - // something short - const uint64_t lock_wait_time = 10; - - mgr.create(nullptr, nullptr, nullptr, nullptr); - DICTIONARY_ID dict_id = { 1 }; - lt = mgr.get_lt(dict_id, nullptr, compare_dbts, nullptr); - - TXNID txnid_a = 1001; - TXNID txnid_b = 2001; - TXNID txnid_c = 3001; - lock_request request_a; - lock_request request_b; - lock_request request_c; - request_a.create(); - request_b.create(); - request_c.create(); - - const DBT *one = get_dbt(1); - const DBT *two = get_dbt(2); - - // start and succeed 1,1 for A and 2,2 for B. - request_a.set(lt, txnid_a, one, one, lock_request::type::WRITE); - r = request_a.start(); - invariant_zero(r); - request_b.set(lt, txnid_b, two, two, lock_request::type::WRITE); - r = request_b.start(); - invariant_zero(r); - - // txnid A should not be granted a lock on 2,2, so it goes pending. - request_a.set(lt, txnid_a, two, two, lock_request::type::WRITE); - r = request_a.start(); - invariant(r == DB_LOCK_NOTGRANTED); - - // if txnid B wants a lock on 1,1 it should deadlock with A - request_b.set(lt, txnid_b, one, one, lock_request::type::WRITE); - r = request_b.start(); - invariant(r == DB_LOCK_DEADLOCK); - - // txnid C should not deadlock on either of these - it should just time out. - request_c.set(lt, txnid_c, one, one, lock_request::type::WRITE); - r = request_c.start(); - invariant(r == DB_LOCK_NOTGRANTED); - r = request_c.wait(lock_wait_time); - invariant(r == DB_LOCK_NOTGRANTED); - request_c.set(lt, txnid_c, two, two, lock_request::type::WRITE); - r = request_c.start(); - invariant(r == DB_LOCK_NOTGRANTED); - r = request_c.wait(lock_wait_time); - invariant(r == DB_LOCK_NOTGRANTED); - - // release locks for A and B, then wait on A's request which should succeed - // since B just unlocked and should have completed A's pending request. - release_lock_and_retry_requests(lt, txnid_a, one, one); - release_lock_and_retry_requests(lt, txnid_b, two, two); - r = request_a.wait(lock_wait_time); - invariant_zero(r); - release_lock_and_retry_requests(lt, txnid_a, two, two); - - request_a.destroy(); - request_b.destroy(); - request_c.destroy(); - mgr.release_lt(lt); - mgr.destroy(); -} - -} /* namespace toku */ - -int main(void) { - toku::lock_request_unit_test test; - test.test_start_deadlock(); - return 0; -} - diff --git a/locktree/tests/lock_request_start_pending.cc b/locktree/tests/lock_request_start_pending.cc deleted file mode 100644 index 8eb88a093..000000000 --- a/locktree/tests/lock_request_start_pending.cc +++ /dev/null @@ -1,160 +0,0 @@ -/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: -#ident "$Id$" -/* -COPYING CONDITIONS NOTICE: - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation, and provided that the - following conditions are met: - - * Redistributions of source code must retain this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below). - - * Redistributions in binary form must reproduce this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below) in the documentation and/or other materials - provided with the distribution. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -COPYRIGHT NOTICE: - - TokuDB, Tokutek Fractal Tree Indexing Library. - Copyright (C) 2007-2013 Tokutek, Inc. - -DISCLAIMER: - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - -UNIVERSITY PATENT NOTICE: - - The technology is licensed by the Massachusetts Institute of - Technology, Rutgers State University of New Jersey, and the Research - Foundation of State University of New York at Stony Brook under - United States of America Serial No. 11/760379 and to the patents - and/or patent applications resulting from it. - -PATENT MARKING NOTICE: - - This software is covered by US Patent No. 8,185,551. - This software is covered by US Patent No. 8,489,638. - -PATENT RIGHTS GRANT: - - "THIS IMPLEMENTATION" means the copyrightable works distributed by - Tokutek as part of the Fractal Tree project. - - "PATENT CLAIMS" means the claims of patents that are owned or - licensable by Tokutek, both currently or in the future; and that in - the absence of this license would be infringed by THIS - IMPLEMENTATION or by using or running THIS IMPLEMENTATION. - - "PATENT CHALLENGE" shall mean a challenge to the validity, - patentability, enforceability and/or non-infringement of any of the - PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS. - - Tokutek hereby grants to you, for the term and geographical scope of - the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free, - irrevocable (except as stated in this section) patent license to - make, have made, use, offer to sell, sell, import, transfer, and - otherwise run, modify, and propagate the contents of THIS - IMPLEMENTATION, where such license applies only to the PATENT - CLAIMS. This grant does not include claims that would be infringed - only as a consequence of further modifications of THIS - IMPLEMENTATION. If you or your agent or licensee institute or order - or agree to the institution of patent litigation against any entity - (including a cross-claim or counterclaim in a lawsuit) alleging that - THIS IMPLEMENTATION constitutes direct or contributory patent - infringement, or inducement of patent infringement, then any rights - granted to you under this License shall terminate as of the date - such litigation is filed. If you or your agent or exclusive - licensee institute or order or agree to the institution of a PATENT - CHALLENGE, then Tokutek may terminate any rights granted to you - under this License. -*/ - -#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved." -#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." - -#include "lock_request_unit_test.h" - -namespace toku { - -// starting a lock request without immediate success should get -// stored in the lock request set as pending. -locktree::manager mgr_pending; -void lock_request_unit_test::test_start_pending(void) { - int r; - locktree *lt; - lock_request request; - - mgr_pending.create(nullptr, nullptr, nullptr, nullptr); - DICTIONARY_ID dict_id = { 1 }; - lt = mgr_pending.get_lt(dict_id, nullptr, compare_dbts, nullptr); - - TXNID txnid_a = 1001; - TXNID txnid_b = 2001; - - const DBT *zero = get_dbt(0); - const DBT *one = get_dbt(1); - const DBT *two = get_dbt(2); - - // take a range lock using txnid b - r = lt->acquire_write_lock(txnid_b, zero, two, nullptr); - invariant_zero(r); - - locktree::lt_lock_request_info *info = lt->get_lock_request_info(); - - // start a lock request for 1,1 - // it should fail. the request should be stored and in the pending state. - request.create(); - request.set(lt, txnid_a, one, one, lock_request::type::WRITE); - r = request.start(); - invariant(r == DB_LOCK_NOTGRANTED); - invariant(info->pending_lock_requests.size() == 1); - invariant(request.m_state == lock_request::state::PENDING); - - // should have made copies of the keys, and they should be equal - invariant(request.m_left_key_copy.flags == DB_DBT_MALLOC); - invariant(request.m_right_key_copy.flags == DB_DBT_MALLOC); - invariant(compare_dbts(nullptr, &request.m_left_key_copy, one) == 0); - invariant(compare_dbts(nullptr, &request.m_right_key_copy, one) == 0); - - // release the range lock for txnid b - locktree_unit_test::locktree_test_release_lock(lt, txnid_b, zero, two); - - // now retry the lock requests. - // it should transition the request to successfully complete. - lock_request::retry_all_lock_requests(lt); - invariant(info->pending_lock_requests.size() == 0); - invariant(request.m_state == lock_request::state::COMPLETE); - invariant(request.m_complete_r == 0); - - locktree_unit_test::locktree_test_release_lock(lt, txnid_a, one, one); - - request.destroy(); - mgr_pending.release_lt(lt); - mgr_pending.destroy(); -} - -} /* namespace toku */ -extern "C" int test_lockrequest_pending(void); -int test_lockrequest_pending(void) { - toku::lock_request_unit_test test; - test.test_start_pending(); - return 0; -} - diff --git a/locktree/tests/lock_request_unit_test.h b/locktree/tests/lock_request_unit_test.h deleted file mode 100644 index 3183bf2b7..000000000 --- a/locktree/tests/lock_request_unit_test.h +++ /dev/null @@ -1,136 +0,0 @@ -/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: -#ident "$Id$" -/* -COPYING CONDITIONS NOTICE: - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation, and provided that the - following conditions are met: - - * Redistributions of source code must retain this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below). - - * Redistributions in binary form must reproduce this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below) in the documentation and/or other materials - provided with the distribution. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -COPYRIGHT NOTICE: - - TokuDB, Tokutek Fractal Tree Indexing Library. - Copyright (C) 2007-2013 Tokutek, Inc. - -DISCLAIMER: - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - -UNIVERSITY PATENT NOTICE: - - The technology is licensed by the Massachusetts Institute of - Technology, Rutgers State University of New Jersey, and the Research - Foundation of State University of New York at Stony Brook under - United States of America Serial No. 11/760379 and to the patents - and/or patent applications resulting from it. - -PATENT MARKING NOTICE: - - This software is covered by US Patent No. 8,185,551. - This software is covered by US Patent No. 8,489,638. - -PATENT RIGHTS GRANT: - - "THIS IMPLEMENTATION" means the copyrightable works distributed by - Tokutek as part of the Fractal Tree project. - - "PATENT CLAIMS" means the claims of patents that are owned or - licensable by Tokutek, both currently or in the future; and that in - the absence of this license would be infringed by THIS - IMPLEMENTATION or by using or running THIS IMPLEMENTATION. - - "PATENT CHALLENGE" shall mean a challenge to the validity, - patentability, enforceability and/or non-infringement of any of the - PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS. - - Tokutek hereby grants to you, for the term and geographical scope of - the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free, - irrevocable (except as stated in this section) patent license to - make, have made, use, offer to sell, sell, import, transfer, and - otherwise run, modify, and propagate the contents of THIS - IMPLEMENTATION, where such license applies only to the PATENT - CLAIMS. This grant does not include claims that would be infringed - only as a consequence of further modifications of THIS - IMPLEMENTATION. If you or your agent or licensee institute or order - or agree to the institution of patent litigation against any entity - (including a cross-claim or counterclaim in a lawsuit) alleging that - THIS IMPLEMENTATION constitutes direct or contributory patent - infringement, or inducement of patent infringement, then any rights - granted to you under this License shall terminate as of the date - such litigation is filed. If you or your agent or exclusive - licensee institute or order or agree to the institution of a PATENT - CHALLENGE, then Tokutek may terminate any rights granted to you - under this License. -*/ - -#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved." -#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." - -#ifndef TOKU_LOCK_REQUEST_UNIT_TEST_H -#define TOKU_LOCK_REQUEST_UNIT_TEST_H - -#include "test.h" -#include "locktree_unit_test.h" - -#include "lock_request.h" - -namespace toku { - -class lock_request_unit_test { -public: - // create and set the object's internals, destroy should not crash. - void test_create_destroy(void); - - // make setting keys and getting them back works properly. - // at a high level, we want to make sure keys are copied - // when appropriate and plays nice with +/- infinity. - void test_get_set_keys(void); - - // starting a lock request without immediate success should get - // stored in the lock request set as pending. - void test_start_pending(void); - - // make sure deadlocks are detected when a lock request starts - void test_start_deadlock(void); - - // test that the get_wait_time callback works - void test_wait_time_callback(void); - -private: - // releases a single range lock and retries all lock requests. - // this is kind of like what the ydb layer does, except that - // the ydb layer releases all of a txn's locks at once using - // lt->release_locks(), not individually using lt->remove_overlapping_locks_for_txnid). - void release_lock_and_retry_requests(locktree *lt, - TXNID txnid, const DBT *left_key, const DBT * right_key) { - locktree_unit_test::locktree_test_release_lock(lt, txnid, left_key, right_key); - lock_request::retry_all_lock_requests(lt); - } -}; - -} - -#endif diff --git a/locktree/tests/lock_request_wait_time_callback.cc b/locktree/tests/lock_request_wait_time_callback.cc deleted file mode 100644 index 4f40ee093..000000000 --- a/locktree/tests/lock_request_wait_time_callback.cc +++ /dev/null @@ -1,159 +0,0 @@ -/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: -#ident "$Id$" -/* -COPYING CONDITIONS NOTICE: - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation, and provided that the - following conditions are met: - - * Redistributions of source code must retain this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below). - - * Redistributions in binary form must reproduce this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below) in the documentation and/or other materials - provided with the distribution. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -COPYRIGHT NOTICE: - - TokuDB, Tokutek Fractal Tree Indexing Library. - Copyright (C) 2007-2013 Tokutek, Inc. - -DISCLAIMER: - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - -UNIVERSITY PATENT NOTICE: - - The technology is licensed by the Massachusetts Institute of - Technology, Rutgers State University of New Jersey, and the Research - Foundation of State University of New York at Stony Brook under - United States of America Serial No. 11/760379 and to the patents - and/or patent applications resulting from it. - -PATENT MARKING NOTICE: - - This software is covered by US Patent No. 8,185,551. - This software is covered by US Patent No. 8,489,638. - -PATENT RIGHTS GRANT: - - "THIS IMPLEMENTATION" means the copyrightable works distributed by - Tokutek as part of the Fractal Tree project. - - "PATENT CLAIMS" means the claims of patents that are owned or - licensable by Tokutek, both currently or in the future; and that in - the absence of this license would be infringed by THIS - IMPLEMENTATION or by using or running THIS IMPLEMENTATION. - - "PATENT CHALLENGE" shall mean a challenge to the validity, - patentability, enforceability and/or non-infringement of any of the - PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS. - - Tokutek hereby grants to you, for the term and geographical scope of - the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free, - irrevocable (except as stated in this section) patent license to - make, have made, use, offer to sell, sell, import, transfer, and - otherwise run, modify, and propagate the contents of THIS - IMPLEMENTATION, where such license applies only to the PATENT - CLAIMS. This grant does not include claims that would be infringed - only as a consequence of further modifications of THIS - IMPLEMENTATION. If you or your agent or licensee institute or order - or agree to the institution of patent litigation against any entity - (including a cross-claim or counterclaim in a lawsuit) alleging that - THIS IMPLEMENTATION constitutes direct or contributory patent - infringement, or inducement of patent infringement, then any rights - granted to you under this License shall terminate as of the date - such litigation is filed. If you or your agent or exclusive - licensee institute or order or agree to the institution of a PATENT - CHALLENGE, then Tokutek may terminate any rights granted to you - under this License. -*/ - -#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved." -#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." - -#include "lock_request_unit_test.h" - -namespace toku { - -static int my_calls = 0; - -static uint64_t my_lock_wait_time_callback(uint64_t default_lock_wait_time UU()) { - my_calls++; - return 1000; -} - -// make sure deadlocks are detected when a lock request starts -void lock_request_unit_test::test_wait_time_callback(void) { - int r; - locktree::manager mgr; - locktree *lt; - - mgr.create(nullptr, nullptr, nullptr, nullptr); - mgr.set_lock_wait_time(10*1000, my_lock_wait_time_callback); - DICTIONARY_ID dict_id = { 1 }; - lt = mgr.get_lt(dict_id, nullptr, compare_dbts, nullptr); - - TXNID txnid_a = 1001; - lock_request request_a; - request_a.create(); - - TXNID txnid_b = 2001; - lock_request request_b; - request_b.create(); - - const DBT *one = get_dbt(1); - const DBT *two = get_dbt(2); - - // a locks 'one' - request_a.set(lt, txnid_a, one, one, lock_request::type::WRITE); - r = request_a.start(); - assert_zero(r); - - // b tries to lock 'one' - request_b.set(lt, txnid_b, one, two, lock_request::type::WRITE); - r = request_b.start(); - assert(r == DB_LOCK_NOTGRANTED); - assert(my_calls == 0); - uint64_t t_start = toku_current_time_microsec(); - r = request_b.wait(mgr.get_lock_wait_time()); - uint64_t t_end = toku_current_time_microsec(); - assert(r == DB_LOCK_NOTGRANTED); - assert(my_calls == 1); - assert(t_end > t_start); - uint64_t t_delta = t_end - t_start; - assert(1000000 <= t_delta && t_delta < 10000000); - request_b.destroy(); - - release_lock_and_retry_requests(lt, txnid_a, one, one); - request_a.destroy(); - - mgr.release_lt(lt); - mgr.destroy(); -} - -} /* namespace toku */ - -int main(void) { - toku::lock_request_unit_test test; - test.test_wait_time_callback(); - return 0; -} - diff --git a/locktree/tests/locktree_conflicts.cc b/locktree/tests/locktree_conflicts.cc deleted file mode 100644 index 9c684a905..000000000 --- a/locktree/tests/locktree_conflicts.cc +++ /dev/null @@ -1,180 +0,0 @@ -/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: -#ident "$Id$" -/* -COPYING CONDITIONS NOTICE: - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation, and provided that the - following conditions are met: - - * Redistributions of source code must retain this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below). - - * Redistributions in binary form must reproduce this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below) in the documentation and/or other materials - provided with the distribution. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -COPYRIGHT NOTICE: - - TokuDB, Tokutek Fractal Tree Indexing Library. - Copyright (C) 2007-2013 Tokutek, Inc. - -DISCLAIMER: - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - -UNIVERSITY PATENT NOTICE: - - The technology is licensed by the Massachusetts Institute of - Technology, Rutgers State University of New Jersey, and the Research - Foundation of State University of New York at Stony Brook under - United States of America Serial No. 11/760379 and to the patents - and/or patent applications resulting from it. - -PATENT MARKING NOTICE: - - This software is covered by US Patent No. 8,185,551. - This software is covered by US Patent No. 8,489,638. - -PATENT RIGHTS GRANT: - - "THIS IMPLEMENTATION" means the copyrightable works distributed by - Tokutek as part of the Fractal Tree project. - - "PATENT CLAIMS" means the claims of patents that are owned or - licensable by Tokutek, both currently or in the future; and that in - the absence of this license would be infringed by THIS - IMPLEMENTATION or by using or running THIS IMPLEMENTATION. - - "PATENT CHALLENGE" shall mean a challenge to the validity, - patentability, enforceability and/or non-infringement of any of the - PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS. - - Tokutek hereby grants to you, for the term and geographical scope of - the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free, - irrevocable (except as stated in this section) patent license to - make, have made, use, offer to sell, sell, import, transfer, and - otherwise run, modify, and propagate the contents of THIS - IMPLEMENTATION, where such license applies only to the PATENT - CLAIMS. This grant does not include claims that would be infringed - only as a consequence of further modifications of THIS - IMPLEMENTATION. If you or your agent or licensee institute or order - or agree to the institution of patent litigation against any entity - (including a cross-claim or counterclaim in a lawsuit) alleging that - THIS IMPLEMENTATION constitutes direct or contributory patent - infringement, or inducement of patent infringement, then any rights - granted to you under this License shall terminate as of the date - such litigation is filed. If you or your agent or exclusive - licensee institute or order or agree to the institution of a PATENT - CHALLENGE, then Tokutek may terminate any rights granted to you - under this License. -*/ - -#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved." -#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." - -#include "locktree_unit_test.h" - -#include - -__attribute__((__unused__)) -static long current_time_usec(void) { - struct timeval t; - gettimeofday(&t, NULL); - return t.tv_usec + t.tv_sec * 1000000; -} - -namespace toku { - -// test write lock conflicts when read or write locks exist -// test read lock conflicts when write locks exist -void locktree_unit_test::test_conflicts(void) { - locktree::manager mgr; - mgr.create(nullptr, nullptr, nullptr, nullptr); - DESCRIPTOR desc = nullptr; - DICTIONARY_ID dict_id = { 1 }; - locktree *lt = mgr.get_lt(dict_id, desc, compare_dbts, nullptr); - - int r; - TXNID txnid_a = 1001; - TXNID txnid_b = 2001; - const DBT *zero = get_dbt(0); - const DBT *one = get_dbt(1); - const DBT *two = get_dbt(2); - const DBT *three = get_dbt(3); - const DBT *four = get_dbt(4); - const DBT *five = get_dbt(5); - - for (int test_run = 0; test_run < 2; test_run++) { - // test_run == 0 means test with read lock - // test_run == 1 means test with write lock -#define ACQUIRE_LOCK(txn, left, right, conflicts) \ - test_run == 0 ? lt->acquire_read_lock(txn, left, right, conflicts) \ - : lt->acquire_write_lock(txn, left, right, conflicts) - - // acquire some locks for txnid_a - r = ACQUIRE_LOCK(txnid_a, one, one, nullptr); - invariant(r == 0); - r = ACQUIRE_LOCK(txnid_a, three, four, nullptr); - invariant(r == 0); - -#undef ACQUIRE_LOCK - - for (int sub_test_run = 0; sub_test_run < 2; sub_test_run++) { - // sub_test_run == 0 means test read lock on top of write lock - // sub_test_run == 1 means test write lock on top of write lock - // if test_run == 0, then read locks exist. only test write locks. -#define ACQUIRE_LOCK(txn, left, right, conflicts) \ - sub_test_run == 0 && test_run == 1 ? \ - lt->acquire_read_lock(txn, left, right, conflicts) \ - : lt->acquire_write_lock(txn, left, right, conflicts) - // try to get point write locks for txnid_b, should fail - r = ACQUIRE_LOCK(txnid_b, one, one, nullptr); - invariant(r == DB_LOCK_NOTGRANTED); - r = ACQUIRE_LOCK(txnid_b, three, three, nullptr); - invariant(r == DB_LOCK_NOTGRANTED); - r = ACQUIRE_LOCK(txnid_b, four, four, nullptr); - invariant(r == DB_LOCK_NOTGRANTED); - - // try to get some overlapping range write locks for txnid_b, should fail - r = ACQUIRE_LOCK(txnid_b, zero, two, nullptr); - invariant(r == DB_LOCK_NOTGRANTED); - r = ACQUIRE_LOCK(txnid_b, four, five, nullptr); - invariant(r == DB_LOCK_NOTGRANTED); - r = ACQUIRE_LOCK(txnid_b, two, three, nullptr); - invariant(r == DB_LOCK_NOTGRANTED); -#undef ACQUIRE_LOCK - } - - lt->remove_overlapping_locks_for_txnid(txnid_a, one, one); - lt->remove_overlapping_locks_for_txnid(txnid_a, three, four); - invariant(no_row_locks(lt)); - } - - mgr.release_lt(lt); - mgr.destroy(); -} - -} /* namespace toku */ - -int main(void) { - toku::locktree_unit_test test; - test.test_conflicts(); - return 0; -} diff --git a/locktree/tests/locktree_create_destroy.cc b/locktree/tests/locktree_create_destroy.cc deleted file mode 100644 index bb3681d03..000000000 --- a/locktree/tests/locktree_create_destroy.cc +++ /dev/null @@ -1,127 +0,0 @@ -/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: -#ident "$Id$" -/* -COPYING CONDITIONS NOTICE: - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation, and provided that the - following conditions are met: - - * Redistributions of source code must retain this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below). - - * Redistributions in binary form must reproduce this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below) in the documentation and/or other materials - provided with the distribution. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -COPYRIGHT NOTICE: - - TokuDB, Tokutek Fractal Tree Indexing Library. - Copyright (C) 2007-2013 Tokutek, Inc. - -DISCLAIMER: - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - -UNIVERSITY PATENT NOTICE: - - The technology is licensed by the Massachusetts Institute of - Technology, Rutgers State University of New Jersey, and the Research - Foundation of State University of New York at Stony Brook under - United States of America Serial No. 11/760379 and to the patents - and/or patent applications resulting from it. - -PATENT MARKING NOTICE: - - This software is covered by US Patent No. 8,185,551. - This software is covered by US Patent No. 8,489,638. - -PATENT RIGHTS GRANT: - - "THIS IMPLEMENTATION" means the copyrightable works distributed by - Tokutek as part of the Fractal Tree project. - - "PATENT CLAIMS" means the claims of patents that are owned or - licensable by Tokutek, both currently or in the future; and that in - the absence of this license would be infringed by THIS - IMPLEMENTATION or by using or running THIS IMPLEMENTATION. - - "PATENT CHALLENGE" shall mean a challenge to the validity, - patentability, enforceability and/or non-infringement of any of the - PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS. - - Tokutek hereby grants to you, for the term and geographical scope of - the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free, - irrevocable (except as stated in this section) patent license to - make, have made, use, offer to sell, sell, import, transfer, and - otherwise run, modify, and propagate the contents of THIS - IMPLEMENTATION, where such license applies only to the PATENT - CLAIMS. This grant does not include claims that would be infringed - only as a consequence of further modifications of THIS - IMPLEMENTATION. If you or your agent or licensee institute or order - or agree to the institution of patent litigation against any entity - (including a cross-claim or counterclaim in a lawsuit) alleging that - THIS IMPLEMENTATION constitutes direct or contributory patent - infringement, or inducement of patent infringement, then any rights - granted to you under this License shall terminate as of the date - such litigation is filed. If you or your agent or exclusive - licensee institute or order or agree to the institution of a PATENT - CHALLENGE, then Tokutek may terminate any rights granted to you - under this License. -*/ - -#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved." -#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." - -#include "locktree_unit_test.h" - -namespace toku { - -// test simple create and destroy of the locktree -void locktree_unit_test::test_create_destroy(void) { - locktree::manager mgr; - mgr.create(nullptr, nullptr, nullptr, nullptr); - DESCRIPTOR desc = nullptr; - DICTIONARY_ID dict_id = { 1 }; - locktree *lt = mgr.get_lt(dict_id, desc, compare_dbts, nullptr); - - locktree::lt_lock_request_info *info = lt->get_lock_request_info(); - invariant_notnull(info); - toku_mutex_lock(&info->mutex); - toku_mutex_unlock(&info->mutex); - - invariant(lt->m_dict_id.dictid == dict_id.dictid); - invariant(lt->m_reference_count == 1); - invariant(lt->m_rangetree != nullptr); - invariant(lt->m_userdata == nullptr); - invariant(info->pending_lock_requests.size() == 0); - invariant(lt->m_sto_end_early_count == 0); - invariant(lt->m_sto_end_early_time == 0); - - mgr.release_lt(lt); - mgr.destroy(); -} - -} /* namespace toku */ - -int main(void) { - toku::locktree_unit_test test; - test.test_create_destroy(); - return 0; -} diff --git a/locktree/tests/locktree_escalation_stalls.cc b/locktree/tests/locktree_escalation_stalls.cc deleted file mode 100644 index 63bdfb3a2..000000000 --- a/locktree/tests/locktree_escalation_stalls.cc +++ /dev/null @@ -1,260 +0,0 @@ -/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: -#ident "$Id$" -/* -COPYING CONDITIONS NOTICE: - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation, and provided that the - following conditions are met: - - * Redistributions of source code must retain this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below). - - * Redistributions in binary form must reproduce this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below) in the documentation and/or other materials - provided with the distribution. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -COPYRIGHT NOTICE: - - TokuDB, Tokutek Fractal Tree Indexing Library. - Copyright (C) 2007-2013 Tokutek, Inc. - -DISCLAIMER: - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - -UNIVERSITY PATENT NOTICE: - - The technology is licensed by the Massachusetts Institute of - Technology, Rutgers State University of New Jersey, and the Research - Foundation of State University of New York at Stony Brook under - United States of America Serial No. 11/760379 and to the patents - and/or patent applications resulting from it. - -PATENT MARKING NOTICE: - - This software is covered by US Patent No. 8,185,551. - This software is covered by US Patent No. 8,489,638. - -PATENT RIGHTS GRANT: - - "THIS IMPLEMENTATION" means the copyrightable works distributed by - Tokutek as part of the Fractal Tree project. - - "PATENT CLAIMS" means the claims of patents that are owned or - licensable by Tokutek, both currently or in the future; and that in - the absence of this license would be infringed by THIS - IMPLEMENTATION or by using or running THIS IMPLEMENTATION. - - "PATENT CHALLENGE" shall mean a challenge to the validity, - patentability, enforceability and/or non-infringement of any of the - PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS. - - Tokutek hereby grants to you, for the term and geographical scope of - the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free, - irrevocable (except as stated in this section) patent license to - make, have made, use, offer to sell, sell, import, transfer, and - otherwise run, modify, and propagate the contents of THIS - IMPLEMENTATION, where such license applies only to the PATENT - CLAIMS. This grant does not include claims that would be infringed - only as a consequence of further modifications of THIS - IMPLEMENTATION. If you or your agent or licensee institute or order - or agree to the institution of patent litigation against any entity - (including a cross-claim or counterclaim in a lawsuit) alleging that - THIS IMPLEMENTATION constitutes direct or contributory patent - infringement, or inducement of patent infringement, then any rights - granted to you under this License shall terminate as of the date - such litigation is filed. If you or your agent or exclusive - licensee institute or order or agree to the institution of a PATENT - CHALLENGE, then Tokutek may terminate any rights granted to you - under this License. -*/ - -#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved." -#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." - -#include -#include "locktree.h" -#include "test.h" - -using namespace toku; - -static int verbose = 0; -static int killed = 0; - -static void locktree_release_lock(locktree *lt, TXNID txn_id, int64_t left_k, int64_t right_k) { - range_buffer buffer; - buffer.create(); - DBT left; toku_fill_dbt(&left, &left_k, sizeof left_k); - DBT right; toku_fill_dbt(&right, &right_k, sizeof right_k); - buffer.append(&left, &right); - lt->release_locks(txn_id, &buffer); - buffer.destroy(); -} - -// grab a write range lock on int64 keys bounded by left_k and right_k -static int locktree_write_lock(locktree *lt, TXNID txn_id, int64_t left_k, int64_t right_k) { - DBT left; toku_fill_dbt(&left, &left_k, sizeof left_k); - DBT right; toku_fill_dbt(&right, &right_k, sizeof right_k); - return lt->acquire_write_lock(txn_id, &left, &right, nullptr); -} - -static void run_big_txn(locktree::manager *mgr UU(), locktree *lt, TXNID txn_id) { - int64_t last_i = -1; - for (int64_t i = 0; !killed; i++) { - uint64_t t_start = toku_current_time_microsec(); - int r = locktree_write_lock(lt, txn_id, i, i); - assert(r == 0); - last_i = i; - uint64_t t_end = toku_current_time_microsec(); - uint64_t t_duration = t_end - t_start; - if (t_duration > 100000) { - printf("%u %s %" PRId64 " %" PRIu64 "\n", toku_os_gettid(), __FUNCTION__, i, t_duration); - } - toku_pthread_yield(); - } - if (last_i != -1) - locktree_release_lock(lt, txn_id, 0, last_i); // release the range 0 .. last_i -} - -static void run_small_txn(locktree::manager *mgr UU(), locktree *lt, TXNID txn_id, int64_t k) { - for (int64_t i = 0; !killed; i++) { - uint64_t t_start = toku_current_time_microsec(); - int r = locktree_write_lock(lt, txn_id, k, k); - assert(r == 0); - uint64_t t_end = toku_current_time_microsec(); - uint64_t t_duration = t_end - t_start; - if (t_duration > 100000) { - printf("%u %s %" PRId64 " %" PRIu64 "\n", toku_os_gettid(), __FUNCTION__, i, t_duration); - } - locktree_release_lock(lt, txn_id, k, k); - toku_pthread_yield(); - } -} - -struct arg { - locktree::manager *mgr; - locktree *lt; - TXNID txn_id; - int64_t k; -}; - -static void *big_f(void *_arg) { - struct arg *arg = (struct arg *) _arg; - run_big_txn(arg->mgr, arg->lt, arg->txn_id); - return arg; -} - -static void *small_f(void *_arg) { - struct arg *arg = (struct arg *) _arg; - run_small_txn(arg->mgr, arg->lt, arg->txn_id, arg->k); - return arg; -} - -static void e_callback(TXNID txnid, const locktree *lt, const range_buffer &buffer, void *extra) { - if (verbose) - printf("%u %s %" PRIu64 " %p %d %p\n", toku_os_gettid(), __FUNCTION__, txnid, lt, buffer.get_num_ranges(), extra); -} - -static uint64_t get_escalation_count(locktree::manager &mgr) { - LTM_STATUS_S ltm_status; - mgr.get_status(<m_status); - - TOKU_ENGINE_STATUS_ROW key_status = NULL; - // lookup keyname in status - for (int i = 0; ; i++) { - TOKU_ENGINE_STATUS_ROW status = <m_status.status[i]; - if (status->keyname == NULL) - break; - if (strcmp(status->keyname, "LTM_ESCALATION_COUNT") == 0) { - key_status = status; - break; - } - } - assert(key_status); - return key_status->value.num; -} - -int main(int argc, const char *argv[]) { - uint64_t stalls = 0; - for (int i = 1; i < argc; i++) { - if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--verbose") == 0) { - verbose++; - continue; - } - if (strcmp(argv[i], "--stalls") == 0 && i+1 < argc) { - stalls = atoll(argv[++i]); - continue; - } - } - - int r; - - // create a manager - locktree::manager mgr; - mgr.create(nullptr, nullptr, e_callback, nullptr); - mgr.set_max_lock_memory(1000000000); - - // create lock trees - DESCRIPTOR desc_0 = nullptr; - DICTIONARY_ID dict_id_0 = { 1 }; - locktree *lt_0 = mgr.get_lt(dict_id_0, desc_0, compare_dbts, nullptr); - - DESCRIPTOR desc_1 = nullptr; - DICTIONARY_ID dict_id_1 = { 2 }; - locktree *lt_1 = mgr.get_lt(dict_id_1, desc_1, compare_dbts, nullptr); - - // create the worker threads - struct arg big_arg = { &mgr, lt_0, 1000 }; - pthread_t big_id; - r = toku_pthread_create(&big_id, nullptr, big_f, &big_arg); - assert(r == 0); - - const int n_small = 7; - pthread_t small_ids[n_small]; - struct arg small_args[n_small]; - - for (int i = 0; i < n_small; i++) { - small_args[i] = { &mgr, lt_1, (TXNID)(2000+i), i }; - r = toku_pthread_create(&small_ids[i], nullptr, small_f, &small_args[i]); - assert(r == 0); - } - - // wait for some escalations to occur - while (get_escalation_count(mgr) < stalls) { - sleep(1); - } - killed = 1; - - // cleanup - void *ret; - r = toku_pthread_join(big_id, &ret); - assert(r == 0); - - for (int i = 0; i < n_small; i++) { - r = toku_pthread_join(small_ids[i], &ret); - assert(r == 0); - } - - mgr.release_lt(lt_0); - mgr.release_lt(lt_1); - mgr.destroy(); - - return 0; -} diff --git a/locktree/tests/locktree_infinity.cc b/locktree/tests/locktree_infinity.cc deleted file mode 100644 index fd3dd1ca6..000000000 --- a/locktree/tests/locktree_infinity.cc +++ /dev/null @@ -1,177 +0,0 @@ -/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: -#ident "$Id$" -/* -COPYING CONDITIONS NOTICE: - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation, and provided that the - following conditions are met: - - * Redistributions of source code must retain this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below). - - * Redistributions in binary form must reproduce this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below) in the documentation and/or other materials - provided with the distribution. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -COPYRIGHT NOTICE: - - TokuDB, Tokutek Fractal Tree Indexing Library. - Copyright (C) 2007-2013 Tokutek, Inc. - -DISCLAIMER: - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - -UNIVERSITY PATENT NOTICE: - - The technology is licensed by the Massachusetts Institute of - Technology, Rutgers State University of New Jersey, and the Research - Foundation of State University of New York at Stony Brook under - United States of America Serial No. 11/760379 and to the patents - and/or patent applications resulting from it. - -PATENT MARKING NOTICE: - - This software is covered by US Patent No. 8,185,551. - This software is covered by US Patent No. 8,489,638. - -PATENT RIGHTS GRANT: - - "THIS IMPLEMENTATION" means the copyrightable works distributed by - Tokutek as part of the Fractal Tree project. - - "PATENT CLAIMS" means the claims of patents that are owned or - licensable by Tokutek, both currently or in the future; and that in - the absence of this license would be infringed by THIS - IMPLEMENTATION or by using or running THIS IMPLEMENTATION. - - "PATENT CHALLENGE" shall mean a challenge to the validity, - patentability, enforceability and/or non-infringement of any of the - PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS. - - Tokutek hereby grants to you, for the term and geographical scope of - the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free, - irrevocable (except as stated in this section) patent license to - make, have made, use, offer to sell, sell, import, transfer, and - otherwise run, modify, and propagate the contents of THIS - IMPLEMENTATION, where such license applies only to the PATENT - CLAIMS. This grant does not include claims that would be infringed - only as a consequence of further modifications of THIS - IMPLEMENTATION. If you or your agent or licensee institute or order - or agree to the institution of patent litigation against any entity - (including a cross-claim or counterclaim in a lawsuit) alleging that - THIS IMPLEMENTATION constitutes direct or contributory patent - infringement, or inducement of patent infringement, then any rights - granted to you under this License shall terminate as of the date - such litigation is filed. If you or your agent or exclusive - licensee institute or order or agree to the institution of a PATENT - CHALLENGE, then Tokutek may terminate any rights granted to you - under this License. -*/ - -#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved." -#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." - -#include "locktree_unit_test.h" - -namespace toku { - -// test that ranges with infinite endpoints work -void locktree_unit_test::test_infinity(void) { - locktree::manager mgr; - mgr.create(nullptr, nullptr, nullptr, nullptr); - DESCRIPTOR desc = nullptr; - DICTIONARY_ID dict_id = { 1 }; - locktree *lt = mgr.get_lt(dict_id, desc, compare_dbts, nullptr); - - int r; - TXNID txnid_a = 1001; - TXNID txnid_b = 2001; - const DBT *zero = get_dbt(0); - const DBT *one = get_dbt(1); - const DBT *two = get_dbt(2); - const DBT *five = get_dbt(5); - const DBT min_int = min_dbt(); - const DBT max_int = max_dbt(); - - // txn A will lock -inf, 5. - r = lt->acquire_write_lock(txnid_a, toku_dbt_negative_infinity(), five, nullptr); - invariant(r == 0); - // txn B will fail to get any lock <= 5, even min_int - r = lt->acquire_write_lock(txnid_b, five, five, nullptr); - invariant(r == DB_LOCK_NOTGRANTED); - r = lt->acquire_write_lock(txnid_b, zero, one, nullptr); - invariant(r == DB_LOCK_NOTGRANTED); - r = lt->acquire_write_lock(txnid_b, &min_int, &min_int, nullptr); - invariant(r == DB_LOCK_NOTGRANTED); - r = lt->acquire_write_lock(txnid_b, toku_dbt_negative_infinity(), &min_int, nullptr); - invariant(r == DB_LOCK_NOTGRANTED); - - lt->remove_overlapping_locks_for_txnid(txnid_a, toku_dbt_negative_infinity(), five); - - // txn A will lock 1, +inf - r = lt->acquire_write_lock(txnid_a, one, toku_dbt_positive_infinity(), nullptr); - invariant(r == 0); - // txn B will fail to get any lock >= 1, even max_int - r = lt->acquire_write_lock(txnid_b, one, one, nullptr); - invariant(r == DB_LOCK_NOTGRANTED); - r = lt->acquire_write_lock(txnid_b, two, five, nullptr); - invariant(r == DB_LOCK_NOTGRANTED); - r = lt->acquire_write_lock(txnid_b, &max_int, &max_int, nullptr); - invariant(r == DB_LOCK_NOTGRANTED); - r = lt->acquire_write_lock(txnid_b, &max_int, toku_dbt_positive_infinity(), nullptr); - invariant(r == DB_LOCK_NOTGRANTED); - - lt->remove_overlapping_locks_for_txnid(txnid_a, toku_dbt_negative_infinity(), five); - - // txn A will lock -inf, +inf - r = lt->acquire_write_lock(txnid_a, toku_dbt_negative_infinity(), toku_dbt_positive_infinity(), nullptr); - invariant(r == 0); - // txn B will fail to get any lock - r = lt->acquire_write_lock(txnid_b, zero, one, nullptr); - invariant(r == DB_LOCK_NOTGRANTED); - r = lt->acquire_write_lock(txnid_b, two, five, nullptr); - invariant(r == DB_LOCK_NOTGRANTED); - r = lt->acquire_write_lock(txnid_b, &min_int, &min_int, nullptr); - invariant(r == DB_LOCK_NOTGRANTED); - r = lt->acquire_write_lock(txnid_b, &min_int, &max_int, nullptr); - invariant(r == DB_LOCK_NOTGRANTED); - r = lt->acquire_write_lock(txnid_b, &max_int, &max_int, nullptr); - invariant(r == DB_LOCK_NOTGRANTED); - r = lt->acquire_write_lock(txnid_b, toku_dbt_negative_infinity(), toku_dbt_negative_infinity(), nullptr); - invariant(r == DB_LOCK_NOTGRANTED); - r = lt->acquire_write_lock(txnid_b, toku_dbt_negative_infinity(), toku_dbt_positive_infinity(), nullptr); - invariant(r == DB_LOCK_NOTGRANTED); - r = lt->acquire_write_lock(txnid_b, toku_dbt_positive_infinity(), toku_dbt_positive_infinity(), nullptr); - invariant(r == DB_LOCK_NOTGRANTED); - - lt->remove_overlapping_locks_for_txnid(txnid_a, toku_dbt_negative_infinity(), toku_dbt_positive_infinity()); - - mgr.release_lt(lt); - mgr.destroy(); -} - -} /* namespace toku */ - -int main(void) { - toku::locktree_unit_test test; - test.test_infinity(); - return 0; -} diff --git a/locktree/tests/locktree_misc.cc b/locktree/tests/locktree_misc.cc deleted file mode 100644 index 591691429..000000000 --- a/locktree/tests/locktree_misc.cc +++ /dev/null @@ -1,150 +0,0 @@ -/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: -#ident "$Id$" -/* -COPYING CONDITIONS NOTICE: - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation, and provided that the - following conditions are met: - - * Redistributions of source code must retain this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below). - - * Redistributions in binary form must reproduce this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below) in the documentation and/or other materials - provided with the distribution. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -COPYRIGHT NOTICE: - - TokuDB, Tokutek Fractal Tree Indexing Library. - Copyright (C) 2007-2013 Tokutek, Inc. - -DISCLAIMER: - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - -UNIVERSITY PATENT NOTICE: - - The technology is licensed by the Massachusetts Institute of - Technology, Rutgers State University of New Jersey, and the Research - Foundation of State University of New York at Stony Brook under - United States of America Serial No. 11/760379 and to the patents - and/or patent applications resulting from it. - -PATENT MARKING NOTICE: - - This software is covered by US Patent No. 8,185,551. - This software is covered by US Patent No. 8,489,638. - -PATENT RIGHTS GRANT: - - "THIS IMPLEMENTATION" means the copyrightable works distributed by - Tokutek as part of the Fractal Tree project. - - "PATENT CLAIMS" means the claims of patents that are owned or - licensable by Tokutek, both currently or in the future; and that in - the absence of this license would be infringed by THIS - IMPLEMENTATION or by using or running THIS IMPLEMENTATION. - - "PATENT CHALLENGE" shall mean a challenge to the validity, - patentability, enforceability and/or non-infringement of any of the - PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS. - - Tokutek hereby grants to you, for the term and geographical scope of - the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free, - irrevocable (except as stated in this section) patent license to - make, have made, use, offer to sell, sell, import, transfer, and - otherwise run, modify, and propagate the contents of THIS - IMPLEMENTATION, where such license applies only to the PATENT - CLAIMS. This grant does not include claims that would be infringed - only as a consequence of further modifications of THIS - IMPLEMENTATION. If you or your agent or licensee institute or order - or agree to the institution of patent litigation against any entity - (including a cross-claim or counterclaim in a lawsuit) alleging that - THIS IMPLEMENTATION constitutes direct or contributory patent - infringement, or inducement of patent infringement, then any rights - granted to you under this License shall terminate as of the date - such litigation is filed. If you or your agent or exclusive - licensee institute or order or agree to the institution of a PATENT - CHALLENGE, then Tokutek may terminate any rights granted to you - under this License. -*/ - -#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved." -#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." - -#include "locktree_unit_test.h" - -namespace toku { - -static DBT *expected_a; -static DBT *expected_b; -static DESCRIPTOR expected_descriptor; -static int expected_comparison_magic = 55; - -static int my_compare_dbts(DB *db, const DBT *a, const DBT *b) { - invariant(db->cmp_descriptor == expected_descriptor); - (void) a; - (void) b; - return expected_comparison_magic; -} - -// test that get/set userdata works, and that get_manager() works -void locktree_unit_test::test_misc(void) { - locktree::manager mgr; - mgr.create(nullptr, nullptr, nullptr, nullptr); - DESCRIPTOR desc = nullptr; - DICTIONARY_ID dict_id = { 1 }; - locktree *lt = mgr.get_lt(dict_id, desc, my_compare_dbts, nullptr); - - invariant(lt->get_userdata() == nullptr); - int userdata; - lt->set_userdata(&userdata); - invariant(lt->get_userdata() == &userdata); - lt->set_userdata(nullptr); - invariant(lt->get_userdata() == nullptr); - - int r; - DBT dbt_a, dbt_b; - DESCRIPTOR_S d1, d2; - expected_a = &dbt_a; - expected_b = &dbt_b; - - // make sure the comparator object has the correct - // descriptor when we set the locktree's descriptor - lt->set_descriptor(&d1); - expected_descriptor = &d1; - r = lt->m_cmp->compare(&dbt_a, &dbt_b); - invariant(r == expected_comparison_magic); - lt->set_descriptor(&d2); - expected_descriptor = &d2; - r = lt->m_cmp->compare(&dbt_a, &dbt_b); - invariant(r == expected_comparison_magic); - - mgr.release_lt(lt); - mgr.destroy(); -} - -} /* namespace toku */ - -int main(void) { - toku::locktree_unit_test test; - test.test_misc(); - return 0; -} diff --git a/locktree/tests/locktree_overlapping_relock.cc b/locktree/tests/locktree_overlapping_relock.cc deleted file mode 100644 index 34af2c698..000000000 --- a/locktree/tests/locktree_overlapping_relock.cc +++ /dev/null @@ -1,220 +0,0 @@ -/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: -#ident "$Id$" -/* -COPYING CONDITIONS NOTICE: - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation, and provided that the - following conditions are met: - - * Redistributions of source code must retain this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below). - - * Redistributions in binary form must reproduce this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below) in the documentation and/or other materials - provided with the distribution. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -COPYRIGHT NOTICE: - - TokuDB, Tokutek Fractal Tree Indexing Library. - Copyright (C) 2007-2013 Tokutek, Inc. - -DISCLAIMER: - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - -UNIVERSITY PATENT NOTICE: - - The technology is licensed by the Massachusetts Institute of - Technology, Rutgers State University of New Jersey, and the Research - Foundation of State University of New York at Stony Brook under - United States of America Serial No. 11/760379 and to the patents - and/or patent applications resulting from it. - -PATENT MARKING NOTICE: - - This software is covered by US Patent No. 8,185,551. - This software is covered by US Patent No. 8,489,638. - -PATENT RIGHTS GRANT: - - "THIS IMPLEMENTATION" means the copyrightable works distributed by - Tokutek as part of the Fractal Tree project. - - "PATENT CLAIMS" means the claims of patents that are owned or - licensable by Tokutek, both currently or in the future; and that in - the absence of this license would be infringed by THIS - IMPLEMENTATION or by using or running THIS IMPLEMENTATION. - - "PATENT CHALLENGE" shall mean a challenge to the validity, - patentability, enforceability and/or non-infringement of any of the - PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS. - - Tokutek hereby grants to you, for the term and geographical scope of - the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free, - irrevocable (except as stated in this section) patent license to - make, have made, use, offer to sell, sell, import, transfer, and - otherwise run, modify, and propagate the contents of THIS - IMPLEMENTATION, where such license applies only to the PATENT - CLAIMS. This grant does not include claims that would be infringed - only as a consequence of further modifications of THIS - IMPLEMENTATION. If you or your agent or licensee institute or order - or agree to the institution of patent litigation against any entity - (including a cross-claim or counterclaim in a lawsuit) alleging that - THIS IMPLEMENTATION constitutes direct or contributory patent - infringement, or inducement of patent infringement, then any rights - granted to you under this License shall terminate as of the date - such litigation is filed. If you or your agent or exclusive - licensee institute or order or agree to the institution of a PATENT - CHALLENGE, then Tokutek may terminate any rights granted to you - under this License. -*/ - -#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved." -#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." - -#include "locktree_unit_test.h" - -namespace toku { - -// test that the same txn can relock ranges it already owns -// ensure that existing read locks can be upgrading to -// write locks if overlapping and ensure that existing read -// or write locks are consolidated by overlapping relocks. -locktree::manager mgr_tor; -void locktree_unit_test::test_overlapping_relock(void) { - mgr_tor.create(nullptr, nullptr, nullptr, nullptr); - DESCRIPTOR desc = nullptr; - DICTIONARY_ID dict_id = { 1 }; - locktree *lt = mgr_tor.get_lt(dict_id, desc, compare_dbts, nullptr); - - const DBT *zero = get_dbt(0); - const DBT *one = get_dbt(1); - const DBT *two = get_dbt(2); - const DBT *three = get_dbt(3); - const DBT *four = get_dbt(4); - const DBT *five = get_dbt(5); - - int r; - TXNID txnid_a = 1001; - - // because of the single txnid optimization, there is no consolidation - // of read or write ranges until there is at least two txnids in - // the locktree. so here we add some arbitrary txnid to get a point - // lock [100, 100] so that the test below can expect to actually - // do something. at the end of the test, we release 100, 100. - const TXNID the_other_txnid = 9999; - const DBT *hundred = get_dbt(100); - r = lt->acquire_write_lock(the_other_txnid, hundred, hundred, nullptr); - invariant(r == 0); - - for (int test_run = 0; test_run < 2; test_run++) { - // test_run == 0 means test with read lock - // test_run == 1 means test with write lock -#define ACQUIRE_LOCK(txn, left, right, conflicts) \ - test_run == 0 ? lt->acquire_read_lock(txn, left, right, conflicts) \ - : lt->acquire_write_lock(txn, left, right, conflicts) - - // lock [1,1] and [2,2]. then lock [1,2]. - // ensure only [1,2] exists in the tree - r = ACQUIRE_LOCK(txnid_a, one, one, nullptr); - invariant(r == 0); - r = ACQUIRE_LOCK(txnid_a, two, two, nullptr); - invariant(r == 0); - r = ACQUIRE_LOCK(txnid_a, one, two, nullptr); - invariant(r == 0); - - struct verify_fn_obj { - bool saw_the_other; - TXNID expected_txnid; - keyrange *expected_range; - comparator *cmp; - bool fn(const keyrange &range, TXNID txnid) { - if (txnid == the_other_txnid) { - invariant(!saw_the_other); - saw_the_other = true; - return true; - } - invariant(txnid == expected_txnid); - keyrange::comparison c = range.compare(cmp, *expected_range); - invariant(c == keyrange::comparison::EQUALS); - return true; - } - } verify_fn; - verify_fn.cmp = lt->m_cmp; - -#define do_verify() \ - do { verify_fn.saw_the_other = false; locktree_iterate(lt, &verify_fn); } while (0) - - keyrange range; - range.create(one, two); - verify_fn.expected_txnid = txnid_a; - verify_fn.expected_range = ⦥ - do_verify(); - - // unlocking [1,1] should remove the only range, - // the other unlocks shoudl do nothing. - lt->remove_overlapping_locks_for_txnid(txnid_a, one, one); - lt->remove_overlapping_locks_for_txnid(txnid_a, two, two); - lt->remove_overlapping_locks_for_txnid(txnid_a, one, two); - - // try overlapping from the right - r = ACQUIRE_LOCK(txnid_a, one, three, nullptr); - r = ACQUIRE_LOCK(txnid_a, two, five, nullptr); - verify_fn.expected_txnid = txnid_a; - range.create(one, five); - verify_fn.expected_range = ⦥ - do_verify(); - - // now overlap from the left - r = ACQUIRE_LOCK(txnid_a, zero, four, nullptr); - verify_fn.expected_txnid = txnid_a; - range.create(zero, five); - verify_fn.expected_range = ⦥ - do_verify(); - - // now relock in a range that is already dominated - r = ACQUIRE_LOCK(txnid_a, five, five, nullptr); - verify_fn.expected_txnid = txnid_a; - range.create(zero, five); - verify_fn.expected_range = ⦥ - do_verify(); - - // release one of the locks we acquired. this should clean up the whole range. - lt->remove_overlapping_locks_for_txnid(txnid_a, zero, four); - -#undef ACQUIRE_LOCK - } - - // remove the other txnid's lock now - lt->remove_overlapping_locks_for_txnid(the_other_txnid, hundred, hundred); - - mgr_tor.release_lt(lt); - mgr_tor.destroy(); -} - -} /* namespace toku */ - -extern "C" int test_locktree_overlapping(void); - -int test_locktree_overlapping(void) { - toku::locktree_unit_test test; - test.test_overlapping_relock(); - return 0; -} diff --git a/locktree/tests/locktree_simple_lock.cc b/locktree/tests/locktree_simple_lock.cc deleted file mode 100644 index eb0393018..000000000 --- a/locktree/tests/locktree_simple_lock.cc +++ /dev/null @@ -1,223 +0,0 @@ -/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: -#ident "$Id$" -/* -COPYING CONDITIONS NOTICE: - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation, and provided that the - following conditions are met: - - * Redistributions of source code must retain this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below). - - * Redistributions in binary form must reproduce this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below) in the documentation and/or other materials - provided with the distribution. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -COPYRIGHT NOTICE: - - TokuDB, Tokutek Fractal Tree Indexing Library. - Copyright (C) 2007-2013 Tokutek, Inc. - -DISCLAIMER: - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - -UNIVERSITY PATENT NOTICE: - - The technology is licensed by the Massachusetts Institute of - Technology, Rutgers State University of New Jersey, and the Research - Foundation of State University of New York at Stony Brook under - United States of America Serial No. 11/760379 and to the patents - and/or patent applications resulting from it. - -PATENT MARKING NOTICE: - - This software is covered by US Patent No. 8,185,551. - This software is covered by US Patent No. 8,489,638. - -PATENT RIGHTS GRANT: - - "THIS IMPLEMENTATION" means the copyrightable works distributed by - Tokutek as part of the Fractal Tree project. - - "PATENT CLAIMS" means the claims of patents that are owned or - licensable by Tokutek, both currently or in the future; and that in - the absence of this license would be infringed by THIS - IMPLEMENTATION or by using or running THIS IMPLEMENTATION. - - "PATENT CHALLENGE" shall mean a challenge to the validity, - patentability, enforceability and/or non-infringement of any of the - PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS. - - Tokutek hereby grants to you, for the term and geographical scope of - the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free, - irrevocable (except as stated in this section) patent license to - make, have made, use, offer to sell, sell, import, transfer, and - otherwise run, modify, and propagate the contents of THIS - IMPLEMENTATION, where such license applies only to the PATENT - CLAIMS. This grant does not include claims that would be infringed - only as a consequence of further modifications of THIS - IMPLEMENTATION. If you or your agent or licensee institute or order - or agree to the institution of patent litigation against any entity - (including a cross-claim or counterclaim in a lawsuit) alleging that - THIS IMPLEMENTATION constitutes direct or contributory patent - infringement, or inducement of patent infringement, then any rights - granted to you under this License shall terminate as of the date - such litigation is filed. If you or your agent or exclusive - licensee institute or order or agree to the institution of a PATENT - CHALLENGE, then Tokutek may terminate any rights granted to you - under this License. -*/ - -#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved." -#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." - -#include "locktree_unit_test.h" - -#define KERN_ALERT "\0011" -extern "C" int printk(const char *fmt, ...); - -namespace toku { - -// test simple, non-overlapping read locks and then write locks -void locktree_unit_test::test_simple_lock(void) { - locktree::manager mgr; - mgr.create(nullptr, nullptr, nullptr, nullptr); - DESCRIPTOR desc = nullptr; - DICTIONARY_ID dict_id = { 1 }; - locktree *lt = mgr.get_lt(dict_id, desc, compare_dbts, nullptr); - - int r; - TXNID txnid_a = 1001; - TXNID txnid_b = 2001; - TXNID txnid_c = 3001; - TXNID txnid_d = 4001; - const DBT *one = get_dbt(1); - const DBT *two = get_dbt(2); - const DBT *three = get_dbt(3); - const DBT *four = get_dbt(4); - - for (int test_run = 0; test_run < 2; test_run++) { - // test_run == 0 means test with read lock - // test_run == 1 means test with write lock -#define ACQUIRE_LOCK(txn, left, right, conflicts) \ - test_run == 0 ? lt->acquire_read_lock(txn, left, right, conflicts) \ - : lt->acquire_write_lock(txn, left, right, conflicts) - - // four txns, four points - printk(KERN_ALERT "ACQUIRE_LOCK(txnid_a, one, one)"); - r = ACQUIRE_LOCK(txnid_a, one, one, nullptr); - invariant(r == 0); - printk(KERN_ALERT "ACQUIRE_LOCK(txnid_b, two, two)"); - r = ACQUIRE_LOCK(txnid_b, two, two, nullptr); - invariant(r == 0); - printk(KERN_ALERT "ACQUIRE_LOCK(txnid_c, three, three)"); - r = ACQUIRE_LOCK(txnid_c, three, three, nullptr); - invariant(r == 0); - printk(KERN_ALERT "ACQUIRE_LOCK(txnid_d, four, four)"); - r = ACQUIRE_LOCK(txnid_d, four, four, nullptr); - invariant(r == 0); - printk(KERN_ALERT "release_lock(txnid_a, one, one)"); - locktree_test_release_lock(lt, txnid_a, one, one); - printk(KERN_ALERT "release_lock(txnid_b, two, two)"); - locktree_test_release_lock(lt, txnid_b, two, two); - printk(KERN_ALERT "release_lock(txnid_c, three, three)"); - locktree_test_release_lock(lt, txnid_c, three, three); - printk(KERN_ALERT "release_lock(txnid_d, four, four)"); - locktree_test_release_lock(lt, txnid_d, four, four); - printk(KERN_ALERT "done 4 txns, 4 points, test_run: %d\n", test_run); - invariant(no_row_locks(lt)); - printk(KERN_ALERT "invariant held\n"); - - // two txns, two ranges - r = ACQUIRE_LOCK(txnid_c, one, two, nullptr); - invariant(r == 0); - r = ACQUIRE_LOCK(txnid_b, three, four, nullptr); - invariant(r == 0); - locktree_test_release_lock(lt, txnid_c, one, two); - locktree_test_release_lock(lt, txnid_b, three, four); - invariant(no_row_locks(lt)); - printk(KERN_ALERT "done 2 txns, 2 ranges, test_run: %d\n", test_run); - - // two txns, one range, one point - r = ACQUIRE_LOCK(txnid_c, three, four, nullptr); - invariant(r == 0); - r = ACQUIRE_LOCK(txnid_d, one, one, nullptr); - invariant(r == 0); - locktree_test_release_lock(lt, txnid_c, three, four); - locktree_test_release_lock(lt, txnid_d, one, one); - invariant(no_row_locks(lt)); - printk(KERN_ALERT "done 2 txns, 1 range, 1 point, test_run: %d\n", - test_run); -#undef ACQUIRE_LOCK - } - - const int64_t num_locks = 10000; - - int64_t *keys = (int64_t *) toku_malloc(num_locks * sizeof(int64_t)); - for (int64_t i = 0; i < num_locks; i++) { - keys[i] = i; - } - printk(KERN_ALERT "permuting keys:"); - for (int64_t i = 0; i < num_locks; i++) { - int64_t k = rand() % num_locks; - int64_t tmp = keys[k]; - keys[k] = keys[i]; - keys[i] = tmp; - } - - for (int64_t i = 0; i < num_locks; i++) { - printk(KERN_ALERT "\tkey[%d] = %lu\n", i, keys[i]); - } - - r = mgr.set_max_lock_memory((num_locks + 1) * 500); - invariant_zero(r); - printk(KERN_ALERT "set max lock memory", (num_locks + 1) * 500); - DBT k; - k.ulen = 0; - k.size = sizeof(keys[0]); - k.flags = DB_DBT_USERMEM; - - for (int64_t i = 0; i < num_locks; i++) { - k.data = (void *) &keys[i]; - r = lt->acquire_read_lock(txnid_a, &k, &k, nullptr); - invariant(r == 0); - } - printk(KERN_ALERT "acquired read locks"); - - for (int64_t i = 0; i < num_locks; i++) { - k.data = (void *) &keys[i]; - printk(KERN_ALERT "releasing lock %lu", keys[i]); - locktree_test_release_lock(lt, txnid_a, &k, &k); - } - printk(KERN_ALERT "released read locks"); - toku_free(keys); - - mgr.release_lt(lt); - mgr.destroy(); -} - -} /* namespace toku */ - -int main(void) { - toku::locktree_unit_test test; - test.test_simple_lock(); - return 0; -} diff --git a/locktree/tests/locktree_single_txnid_optimization.cc b/locktree/tests/locktree_single_txnid_optimization.cc deleted file mode 100644 index 1c9e80f57..000000000 --- a/locktree/tests/locktree_single_txnid_optimization.cc +++ /dev/null @@ -1,184 +0,0 @@ -/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: -#ident "$Id$" -/* -COPYING CONDITIONS NOTICE: - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation, and provided that the - following conditions are met: - - * Redistributions of source code must retain this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below). - - * Redistributions in binary form must reproduce this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below) in the documentation and/or other materials - provided with the distribution. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -COPYRIGHT NOTICE: - - TokuDB, Tokutek Fractal Tree Indexing Library. - Copyright (C) 2007-2013 Tokutek, Inc. - -DISCLAIMER: - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - -UNIVERSITY PATENT NOTICE: - - The technology is licensed by the Massachusetts Institute of - Technology, Rutgers State University of New Jersey, and the Research - Foundation of State University of New York at Stony Brook under - United States of America Serial No. 11/760379 and to the patents - and/or patent applications resulting from it. - -PATENT MARKING NOTICE: - - This software is covered by US Patent No. 8,185,551. - This software is covered by US Patent No. 8,489,638. - -PATENT RIGHTS GRANT: - - "THIS IMPLEMENTATION" means the copyrightable works distributed by - Tokutek as part of the Fractal Tree project. - - "PATENT CLAIMS" means the claims of patents that are owned or - licensable by Tokutek, both currently or in the future; and that in - the absence of this license would be infringed by THIS - IMPLEMENTATION or by using or running THIS IMPLEMENTATION. - - "PATENT CHALLENGE" shall mean a challenge to the validity, - patentability, enforceability and/or non-infringement of any of the - PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS. - - Tokutek hereby grants to you, for the term and geographical scope of - the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free, - irrevocable (except as stated in this section) patent license to - make, have made, use, offer to sell, sell, import, transfer, and - otherwise run, modify, and propagate the contents of THIS - IMPLEMENTATION, where such license applies only to the PATENT - CLAIMS. This grant does not include claims that would be infringed - only as a consequence of further modifications of THIS - IMPLEMENTATION. If you or your agent or licensee institute or order - or agree to the institution of patent litigation against any entity - (including a cross-claim or counterclaim in a lawsuit) alleging that - THIS IMPLEMENTATION constitutes direct or contributory patent - infringement, or inducement of patent infringement, then any rights - granted to you under this License shall terminate as of the date - such litigation is filed. If you or your agent or exclusive - licensee institute or order or agree to the institution of a PATENT - CHALLENGE, then Tokutek may terminate any rights granted to you - under this License. -*/ - -#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved." -#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." - -#include "locktree_unit_test.h" - -namespace toku { - -// test that the same txn can relock ranges it already owns -// ensure that existing read locks can be upgrading to -// write locks if overlapping and ensure that existing read -// or write locks are consolidated by overlapping relocks. -void locktree_unit_test::test_single_txnid_optimization(void) { - locktree::manager mgr; - mgr.create(nullptr, nullptr, nullptr, nullptr); - DESCRIPTOR desc = nullptr; - DICTIONARY_ID dict_id = { 1 }; - locktree *lt = mgr.get_lt(dict_id, desc, compare_dbts, nullptr); - - const DBT *zero = get_dbt(0); - const DBT *one = get_dbt(1); - const DBT *two = get_dbt(2); - const DBT *three = get_dbt(3); - - int r; - TXNID txnid_a = 1001; - TXNID txnid_b = 2001; - - // the single txnid optimization takes advantage of the fact that - // a locktree with only locks for a single txnid can be unlocked - // by just destroy every node. if this is implemented incorrectly, - // then some other txnid's lock might get lost. so test that no - // matter where txnid b takes its write lock in the middle of a bunch - // of txnid a locks, the txnid b lock does not get lost. - for (int where = 0; where < 4; where++) { - range_buffer buffer; - buffer.create(); - -#define lock_and_append_point_for_txnid_a(key) \ - r = lt->acquire_write_lock(txnid_a, key, key, nullptr); \ - invariant_zero(r); \ - buffer.append(key, key); - -#define maybe_point_locks_for_txnid_b(i) \ - if (where == i) { \ - r = lt->acquire_write_lock(txnid_b, one, one, nullptr); \ - invariant_zero(r); \ - } - - lock_and_append_point_for_txnid_a(two); - maybe_point_locks_for_txnid_b(0); - - lock_and_append_point_for_txnid_a(three); - maybe_point_locks_for_txnid_b(1); - - lock_and_append_point_for_txnid_a(zero); - maybe_point_locks_for_txnid_b(2); - - lt->release_locks(txnid_a, &buffer); - - // txnid b does not take a lock on iteration 3 - if (where != 3) { - struct verify_fn_obj { - TXNID expected_txnid; - keyrange *expected_range; - comparator *cmp; - bool fn(const keyrange &range, TXNID txnid) { - invariant(txnid == expected_txnid); - keyrange::comparison c = range.compare(cmp, *expected_range); - invariant(c == keyrange::comparison::EQUALS); - return true; - } - } verify_fn; - verify_fn.cmp = lt->m_cmp; - - keyrange range; - range.create(one, one); - verify_fn.expected_txnid = txnid_b; - verify_fn.expected_range = ⦥ - locktree_iterate(lt, &verify_fn); - lt->remove_overlapping_locks_for_txnid(txnid_b, one, one); - } - - buffer.destroy(); - } - - mgr.release_lt(lt); - mgr.destroy(); -} - -} /* namespace toku */ - -int main(void) { - toku::locktree_unit_test test; - test.test_single_txnid_optimization(); - return 0; -} diff --git a/locktree/tests/locktree_unit_test.h b/locktree/tests/locktree_unit_test.h deleted file mode 100644 index b074cc837..000000000 --- a/locktree/tests/locktree_unit_test.h +++ /dev/null @@ -1,161 +0,0 @@ -/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: -#ident "$Id$" -/* -COPYING CONDITIONS NOTICE: - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation, and provided that the - following conditions are met: - - * Redistributions of source code must retain this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below). - - * Redistributions in binary form must reproduce this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below) in the documentation and/or other materials - provided with the distribution. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -COPYRIGHT NOTICE: - - TokuDB, Tokutek Fractal Tree Indexing Library. - Copyright (C) 2007-2013 Tokutek, Inc. - -DISCLAIMER: - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - -UNIVERSITY PATENT NOTICE: - - The technology is licensed by the Massachusetts Institute of - Technology, Rutgers State University of New Jersey, and the Research - Foundation of State University of New York at Stony Brook under - United States of America Serial No. 11/760379 and to the patents - and/or patent applications resulting from it. - -PATENT MARKING NOTICE: - - This software is covered by US Patent No. 8,185,551. - This software is covered by US Patent No. 8,489,638. - -PATENT RIGHTS GRANT: - - "THIS IMPLEMENTATION" means the copyrightable works distributed by - Tokutek as part of the Fractal Tree project. - - "PATENT CLAIMS" means the claims of patents that are owned or - licensable by Tokutek, both currently or in the future; and that in - the absence of this license would be infringed by THIS - IMPLEMENTATION or by using or running THIS IMPLEMENTATION. - - "PATENT CHALLENGE" shall mean a challenge to the validity, - patentability, enforceability and/or non-infringement of any of the - PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS. - - Tokutek hereby grants to you, for the term and geographical scope of - the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free, - irrevocable (except as stated in this section) patent license to - make, have made, use, offer to sell, sell, import, transfer, and - otherwise run, modify, and propagate the contents of THIS - IMPLEMENTATION, where such license applies only to the PATENT - CLAIMS. This grant does not include claims that would be infringed - only as a consequence of further modifications of THIS - IMPLEMENTATION. If you or your agent or licensee institute or order - or agree to the institution of patent litigation against any entity - (including a cross-claim or counterclaim in a lawsuit) alleging that - THIS IMPLEMENTATION constitutes direct or contributory patent - infringement, or inducement of patent infringement, then any rights - granted to you under this License shall terminate as of the date - such litigation is filed. If you or your agent or exclusive - licensee institute or order or agree to the institution of a PATENT - CHALLENGE, then Tokutek may terminate any rights granted to you - under this License. -*/ - -#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved." -#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." - -#ifndef TOKU_LOCKTREE_UNIT_TEST_H -#define TOKU_LOCKTREE_UNIT_TEST_H - -#include "test.h" - -#include "locktree.h" -#include "concurrent_tree.h" - -namespace toku { - -class locktree_unit_test { -public: - // test simple create and destroy of the locktree - void test_create_destroy(void); - - // test that get/set userdata works, and that get_manager() works - void test_misc(void); - - // test that simple read and write locks can be acquired - void test_simple_lock(void); - - // test that: - // - existing read locks can be upgrading to write locks - // - overlapping locks are consolidated in the tree - // - dominated locks succeed and are not stored in the tree - void test_overlapping_relock(void); - - // test write lock conflicts when read or write locks exist - // test read lock conflicts when write locks exist - void test_conflicts(void); - - // test that ranges with infinite endpoints work - void test_infinity(void); - - // make sure the single txnid optimization does not screw - // up when there is more than one txnid with locks in the tree - void test_single_txnid_optimization(void); - -private: - - - template - static void locktree_iterate(const locktree *lt, F *function) { - concurrent_tree::locked_keyrange ltr; - keyrange infinite_range = keyrange::get_infinite_range(); - - ltr.prepare(lt->m_rangetree); - ltr.acquire(infinite_range); - ltr.iterate(function); - ltr.release(); - } - - static bool no_row_locks(const locktree *lt) { - return lt->m_rangetree->is_empty() && lt->m_sto_buffer.is_empty(); - } - - static void locktree_test_release_lock(locktree *lt, TXNID txnid, const DBT *left_key, const DBT *right_key) { - range_buffer buffer; - buffer.create(); - buffer.append(left_key, right_key); - lt->release_locks(txnid, &buffer); - buffer.destroy(); - } - - friend class lock_request_unit_test; -}; - -} /* namespace toku */ - -#endif /* TOKU_LOCKTREE_UNIT_TEST_H */ diff --git a/locktree/tests/manager_create_destroy.cc b/locktree/tests/manager_create_destroy.cc deleted file mode 100644 index c0c218c8a..000000000 --- a/locktree/tests/manager_create_destroy.cc +++ /dev/null @@ -1,132 +0,0 @@ -/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: -#ident "$Id$" -/* -COPYING CONDITIONS NOTICE: - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation, and provided that the - following conditions are met: - - * Redistributions of source code must retain this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below). - - * Redistributions in binary form must reproduce this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below) in the documentation and/or other materials - provided with the distribution. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -COPYRIGHT NOTICE: - - TokuDB, Tokutek Fractal Tree Indexing Library. - Copyright (C) 2007-2013 Tokutek, Inc. - -DISCLAIMER: - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - -UNIVERSITY PATENT NOTICE: - - The technology is licensed by the Massachusetts Institute of - Technology, Rutgers State University of New Jersey, and the Research - Foundation of State University of New York at Stony Brook under - United States of America Serial No. 11/760379 and to the patents - and/or patent applications resulting from it. - -PATENT MARKING NOTICE: - - This software is covered by US Patent No. 8,185,551. - This software is covered by US Patent No. 8,489,638. - -PATENT RIGHTS GRANT: - - "THIS IMPLEMENTATION" means the copyrightable works distributed by - Tokutek as part of the Fractal Tree project. - - "PATENT CLAIMS" means the claims of patents that are owned or - licensable by Tokutek, both currently or in the future; and that in - the absence of this license would be infringed by THIS - IMPLEMENTATION or by using or running THIS IMPLEMENTATION. - - "PATENT CHALLENGE" shall mean a challenge to the validity, - patentability, enforceability and/or non-infringement of any of the - PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS. - - Tokutek hereby grants to you, for the term and geographical scope of - the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free, - irrevocable (except as stated in this section) patent license to - make, have made, use, offer to sell, sell, import, transfer, and - otherwise run, modify, and propagate the contents of THIS - IMPLEMENTATION, where such license applies only to the PATENT - CLAIMS. This grant does not include claims that would be infringed - only as a consequence of further modifications of THIS - IMPLEMENTATION. If you or your agent or licensee institute or order - or agree to the institution of patent litigation against any entity - (including a cross-claim or counterclaim in a lawsuit) alleging that - THIS IMPLEMENTATION constitutes direct or contributory patent - infringement, or inducement of patent infringement, then any rights - granted to you under this License shall terminate as of the date - such litigation is filed. If you or your agent or exclusive - licensee institute or order or agree to the institution of a PATENT - CHALLENGE, then Tokutek may terminate any rights granted to you - under this License. -*/ - -#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved." -#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." - -#include "manager_unit_test.h" - -namespace toku { - -void manager_unit_test::test_create_destroy(void) { - locktree::manager mgr; - locktree::manager::lt_create_cb create_callback = - (locktree::manager::lt_create_cb) (long) 1; - locktree::manager::lt_destroy_cb destroy_callback = - (locktree::manager::lt_destroy_cb) (long) 2; - locktree::manager::lt_escalate_cb escalate_callback = - (locktree::manager::lt_escalate_cb) (long) 3; - void *extra = (void *) (long) 4; - mgr.create(create_callback, destroy_callback, escalate_callback, extra); - - invariant(mgr.m_max_lock_memory == locktree::manager::DEFAULT_MAX_LOCK_MEMORY); - invariant(mgr.m_current_lock_memory == 0); - invariant(mgr.m_escalation_count == 0); - invariant(mgr.m_escalation_time == 0); - invariant(mgr.m_escalation_latest_result == 0); - invariant(mgr.m_lock_wait_time_ms == locktree::manager::DEFAULT_LOCK_WAIT_TIME); - - invariant(mgr.m_locktree_map.size() == 0); - invariant(mgr.m_lt_create_callback == create_callback); - invariant(mgr.m_lt_destroy_callback == destroy_callback); - invariant(mgr.m_lt_escalate_callback == escalate_callback); - invariant(mgr.m_lt_escalate_callback_extra == extra); - - mgr.mutex_lock(); - mgr.mutex_unlock(); - - mgr.destroy(); -} - -} /* namespace toku */ - -int main(void) { - toku::manager_unit_test test; - test.test_create_destroy(); - return 0; -} diff --git a/locktree/tests/manager_locktree_map.cc b/locktree/tests/manager_locktree_map.cc deleted file mode 100644 index 1235f15f8..000000000 --- a/locktree/tests/manager_locktree_map.cc +++ /dev/null @@ -1,153 +0,0 @@ -/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: -#ident "$Id$" -/* -COPYING CONDITIONS NOTICE: - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation, and provided that the - following conditions are met: - - * Redistributions of source code must retain this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below). - - * Redistributions in binary form must reproduce this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below) in the documentation and/or other materials - provided with the distribution. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -COPYRIGHT NOTICE: - - TokuDB, Tokutek Fractal Tree Indexing Library. - Copyright (C) 2007-2013 Tokutek, Inc. - -DISCLAIMER: - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - -UNIVERSITY PATENT NOTICE: - - The technology is licensed by the Massachusetts Institute of - Technology, Rutgers State University of New Jersey, and the Research - Foundation of State University of New York at Stony Brook under - United States of America Serial No. 11/760379 and to the patents - and/or patent applications resulting from it. - -PATENT MARKING NOTICE: - - This software is covered by US Patent No. 8,185,551. - This software is covered by US Patent No. 8,489,638. - -PATENT RIGHTS GRANT: - - "THIS IMPLEMENTATION" means the copyrightable works distributed by - Tokutek as part of the Fractal Tree project. - - "PATENT CLAIMS" means the claims of patents that are owned or - licensable by Tokutek, both currently or in the future; and that in - the absence of this license would be infringed by THIS - IMPLEMENTATION or by using or running THIS IMPLEMENTATION. - - "PATENT CHALLENGE" shall mean a challenge to the validity, - patentability, enforceability and/or non-infringement of any of the - PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS. - - Tokutek hereby grants to you, for the term and geographical scope of - the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free, - irrevocable (except as stated in this section) patent license to - make, have made, use, offer to sell, sell, import, transfer, and - otherwise run, modify, and propagate the contents of THIS - IMPLEMENTATION, where such license applies only to the PATENT - CLAIMS. This grant does not include claims that would be infringed - only as a consequence of further modifications of THIS - IMPLEMENTATION. If you or your agent or licensee institute or order - or agree to the institution of patent litigation against any entity - (including a cross-claim or counterclaim in a lawsuit) alleging that - THIS IMPLEMENTATION constitutes direct or contributory patent - infringement, or inducement of patent infringement, then any rights - granted to you under this License shall terminate as of the date - such litigation is filed. If you or your agent or exclusive - licensee institute or order or agree to the institution of a PATENT - CHALLENGE, then Tokutek may terminate any rights granted to you - under this License. -*/ - -#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved." -#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." - -#include "manager_unit_test.h" - -namespace toku { - -void manager_unit_test::test_lt_map(void) { - locktree::manager mgr; - mgr.create(nullptr, nullptr, nullptr, nullptr); - - locktree aa; - locktree bb; - locktree cc; - locktree *alt = &aa; - locktree *blt = &bb; - locktree *clt = &cc; - DICTIONARY_ID a = { 1 }; - DICTIONARY_ID b = { 2 }; - DICTIONARY_ID c = { 3 }; - DICTIONARY_ID d = { 4 }; - alt->m_dict_id = a; - blt->m_dict_id = b; - clt->m_dict_id = c; - - mgr.locktree_map_put(alt); - mgr.locktree_map_put(blt); - mgr.locktree_map_put(clt); - - locktree *lt; - - lt = mgr.locktree_map_find(a); - invariant(lt == alt); - lt = mgr.locktree_map_find(c); - invariant(lt == clt); - lt = mgr.locktree_map_find(b); - invariant(lt == blt); - - mgr.locktree_map_remove(alt); - lt = mgr.locktree_map_find(a); - invariant(lt == nullptr); - lt = mgr.locktree_map_find(c); - invariant(lt == clt); - lt = mgr.locktree_map_find(b); - invariant(lt == blt); - lt = mgr.locktree_map_find(d); - invariant(lt == nullptr); - - mgr.locktree_map_remove(clt); - mgr.locktree_map_remove(blt); - lt = mgr.locktree_map_find(c); - invariant(lt == nullptr); - lt = mgr.locktree_map_find(b); - invariant(lt == nullptr); - - mgr.destroy(); -} - -} /* namespace toku */ - -int main(void) { - toku::manager_unit_test test; - test.test_lt_map(); - return 0; -} diff --git a/locktree/tests/manager_params.cc b/locktree/tests/manager_params.cc deleted file mode 100644 index 1ba86d4a2..000000000 --- a/locktree/tests/manager_params.cc +++ /dev/null @@ -1,125 +0,0 @@ -/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: -#ident "$Id$" -/* -COPYING CONDITIONS NOTICE: - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation, and provided that the - following conditions are met: - - * Redistributions of source code must retain this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below). - - * Redistributions in binary form must reproduce this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below) in the documentation and/or other materials - provided with the distribution. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -COPYRIGHT NOTICE: - - TokuDB, Tokutek Fractal Tree Indexing Library. - Copyright (C) 2007-2013 Tokutek, Inc. - -DISCLAIMER: - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - -UNIVERSITY PATENT NOTICE: - - The technology is licensed by the Massachusetts Institute of - Technology, Rutgers State University of New Jersey, and the Research - Foundation of State University of New York at Stony Brook under - United States of America Serial No. 11/760379 and to the patents - and/or patent applications resulting from it. - -PATENT MARKING NOTICE: - - This software is covered by US Patent No. 8,185,551. - This software is covered by US Patent No. 8,489,638. - -PATENT RIGHTS GRANT: - - "THIS IMPLEMENTATION" means the copyrightable works distributed by - Tokutek as part of the Fractal Tree project. - - "PATENT CLAIMS" means the claims of patents that are owned or - licensable by Tokutek, both currently or in the future; and that in - the absence of this license would be infringed by THIS - IMPLEMENTATION or by using or running THIS IMPLEMENTATION. - - "PATENT CHALLENGE" shall mean a challenge to the validity, - patentability, enforceability and/or non-infringement of any of the - PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS. - - Tokutek hereby grants to you, for the term and geographical scope of - the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free, - irrevocable (except as stated in this section) patent license to - make, have made, use, offer to sell, sell, import, transfer, and - otherwise run, modify, and propagate the contents of THIS - IMPLEMENTATION, where such license applies only to the PATENT - CLAIMS. This grant does not include claims that would be infringed - only as a consequence of further modifications of THIS - IMPLEMENTATION. If you or your agent or licensee institute or order - or agree to the institution of patent litigation against any entity - (including a cross-claim or counterclaim in a lawsuit) alleging that - THIS IMPLEMENTATION constitutes direct or contributory patent - infringement, or inducement of patent infringement, then any rights - granted to you under this License shall terminate as of the date - such litigation is filed. If you or your agent or exclusive - licensee institute or order or agree to the institution of a PATENT - CHALLENGE, then Tokutek may terminate any rights granted to you - under this License. -*/ - -#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved." -#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." - -#include "manager_unit_test.h" - -namespace toku { - -void manager_unit_test::test_params(void) { - int r; - locktree::manager mgr; - mgr.create(nullptr, nullptr, nullptr, nullptr); - - uint64_t new_max_lock_memory = 15307752356; - r = mgr.set_max_lock_memory(new_max_lock_memory); - invariant(r == 0); - invariant(mgr.get_max_lock_memory() == new_max_lock_memory); - - uint64_t new_lock_wait_time = 62345234; - mgr.set_lock_wait_time(new_lock_wait_time, nullptr); - invariant(mgr.get_lock_wait_time() == new_lock_wait_time); - - mgr.m_current_lock_memory = 100000; - r = mgr.set_max_lock_memory(mgr.m_current_lock_memory - 1); - invariant(r == EDOM); - invariant(mgr.get_max_lock_memory() == new_max_lock_memory); - - mgr.m_current_lock_memory = 0; - mgr.destroy(); -} - -} /* namespace toku */ - -int main(void) { - toku::manager_unit_test test; - test.test_params(); - return 0; -} diff --git a/locktree/tests/manager_reference_release_lt.cc b/locktree/tests/manager_reference_release_lt.cc deleted file mode 100644 index ca23f15dd..000000000 --- a/locktree/tests/manager_reference_release_lt.cc +++ /dev/null @@ -1,185 +0,0 @@ -/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: -#ident "$Id$" -/* -COPYING CONDITIONS NOTICE: - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation, and provided that the - following conditions are met: - - * Redistributions of source code must retain this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below). - - * Redistributions in binary form must reproduce this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below) in the documentation and/or other materials - provided with the distribution. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -COPYRIGHT NOTICE: - - TokuDB, Tokutek Fractal Tree Indexing Library. - Copyright (C) 2007-2013 Tokutek, Inc. - -DISCLAIMER: - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - -UNIVERSITY PATENT NOTICE: - - The technology is licensed by the Massachusetts Institute of - Technology, Rutgers State University of New Jersey, and the Research - Foundation of State University of New York at Stony Brook under - United States of America Serial No. 11/760379 and to the patents - and/or patent applications resulting from it. - -PATENT MARKING NOTICE: - - This software is covered by US Patent No. 8,185,551. - This software is covered by US Patent No. 8,489,638. - -PATENT RIGHTS GRANT: - - "THIS IMPLEMENTATION" means the copyrightable works distributed by - Tokutek as part of the Fractal Tree project. - - "PATENT CLAIMS" means the claims of patents that are owned or - licensable by Tokutek, both currently or in the future; and that in - the absence of this license would be infringed by THIS - IMPLEMENTATION or by using or running THIS IMPLEMENTATION. - - "PATENT CHALLENGE" shall mean a challenge to the validity, - patentability, enforceability and/or non-infringement of any of the - PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS. - - Tokutek hereby grants to you, for the term and geographical scope of - the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free, - irrevocable (except as stated in this section) patent license to - make, have made, use, offer to sell, sell, import, transfer, and - otherwise run, modify, and propagate the contents of THIS - IMPLEMENTATION, where such license applies only to the PATENT - CLAIMS. This grant does not include claims that would be infringed - only as a consequence of further modifications of THIS - IMPLEMENTATION. If you or your agent or licensee institute or order - or agree to the institution of patent litigation against any entity - (including a cross-claim or counterclaim in a lawsuit) alleging that - THIS IMPLEMENTATION constitutes direct or contributory patent - infringement, or inducement of patent infringement, then any rights - granted to you under this License shall terminate as of the date - such litigation is filed. If you or your agent or exclusive - licensee institute or order or agree to the institution of a PATENT - CHALLENGE, then Tokutek may terminate any rights granted to you - under this License. -*/ - -#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved." -#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." - -#include -#include "manager_unit_test.h" - -namespace toku { - -static int create_cb(locktree *lt, void *extra) { - lt->set_userdata(extra); - bool *k = (bool *) extra; - invariant(!(*k)); - (*k) = true; - return 0; -} - -static void destroy_cb(locktree *lt) { - bool *k = (bool *) lt->get_userdata(); - invariant(*k); - (*k) = false; -} - -void manager_unit_test::test_reference_release_lt(void) { - locktree::manager mgr; - mgr.create(create_cb, destroy_cb, nullptr, nullptr); - - DICTIONARY_ID a = { 0 }; - DICTIONARY_ID b = { 1 }; - DICTIONARY_ID c = { 2 }; - bool aok = false; - bool bok = false; - bool cok = false; - - int d = 5; - DESCRIPTOR_S desc_s; - desc_s.dbt.data = &d; - desc_s.dbt.size = desc_s.dbt.ulen = sizeof(d); - desc_s.dbt.flags = DB_DBT_USERMEM; - - locktree *alt = mgr.get_lt(a, &desc_s, nullptr, &aok); - assert(!IS_ERR(alt)); - locktree *blt = mgr.get_lt(b, &desc_s, nullptr, &bok); - assert(!IS_ERR(blt)); - locktree *clt = mgr.get_lt(c, &desc_s, nullptr, &cok); - assert(!IS_ERR(alt)); - invariant_notnull(clt); - - // three distinct locktrees should have been returned - invariant(alt != blt && alt != clt && blt != clt); - - // on create callbacks should have been called - invariant(aok); - invariant(bok); - invariant(cok); - - // add 3 refs. b should still exist. - mgr.reference_lt(blt); - mgr.reference_lt(blt); - mgr.reference_lt(blt); - invariant(bok); - // remove 3 refs. b should still exist. - mgr.release_lt(blt); - mgr.release_lt(blt); - mgr.release_lt(blt); - invariant(bok); - - // get another handle on a and b, they shoudl be the same - // as the original alt and blt - locktree *blt2 = mgr.get_lt(b, &desc_s, nullptr, &bok); - invariant(blt2 == blt); - locktree *alt2 = mgr.get_lt(a, &desc_s, nullptr, &aok); - invariant(alt2 == alt); - - // remove one ref from everything. c should die. a and b are ok. - mgr.release_lt(alt); - mgr.release_lt(blt); - mgr.release_lt(clt); - invariant(aok); - invariant(bok); - invariant(!cok); - - // release a and b. both should die. - mgr.release_lt(blt2); - mgr.release_lt(alt2); - invariant(!aok); - invariant(!bok); - - mgr.destroy(); -} - -} /* namespace toku */ - -int main(void) { - toku::manager_unit_test test; - test.test_reference_release_lt(); - return 0; -} diff --git a/locktree/tests/manager_status.cc b/locktree/tests/manager_status.cc deleted file mode 100644 index dc2be2f6f..000000000 --- a/locktree/tests/manager_status.cc +++ /dev/null @@ -1,174 +0,0 @@ -/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: -#ident "$Id$" -/* -COPYING CONDITIONS NOTICE: - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation, and provided that the - following conditions are met: - - * Redistributions of source code must retain this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below). - - * Redistributions in binary form must reproduce this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below) in the documentation and/or other materials - provided with the distribution. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -COPYRIGHT NOTICE: - - TokuDB, Tokutek Fractal Tree Indexing Library. - Copyright (C) 2007-2013 Tokutek, Inc. - -DISCLAIMER: - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - -UNIVERSITY PATENT NOTICE: - - The technology is licensed by the Massachusetts Institute of - Technology, Rutgers State University of New Jersey, and the Research - Foundation of State University of New York at Stony Brook under - United States of America Serial No. 11/760379 and to the patents - and/or patent applications resulting from it. - -PATENT MARKING NOTICE: - - This software is covered by US Patent No. 8,185,551. - This software is covered by US Patent No. 8,489,638. - -PATENT RIGHTS GRANT: - - "THIS IMPLEMENTATION" means the copyrightable works distributed by - Tokutek as part of the Fractal Tree project. - - "PATENT CLAIMS" means the claims of patents that are owned or - licensable by Tokutek, both currently or in the future; and that in - the absence of this license would be infringed by THIS - IMPLEMENTATION or by using or running THIS IMPLEMENTATION. - - "PATENT CHALLENGE" shall mean a challenge to the validity, - patentability, enforceability and/or non-infringement of any of the - PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS. - - Tokutek hereby grants to you, for the term and geographical scope of - the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free, - irrevocable (except as stated in this section) patent license to - make, have made, use, offer to sell, sell, import, transfer, and - otherwise run, modify, and propagate the contents of THIS - IMPLEMENTATION, where such license applies only to the PATENT - CLAIMS. This grant does not include claims that would be infringed - only as a consequence of further modifications of THIS - IMPLEMENTATION. If you or your agent or licensee institute or order - or agree to the institution of patent litigation against any entity - (including a cross-claim or counterclaim in a lawsuit) alleging that - THIS IMPLEMENTATION constitutes direct or contributory patent - infringement, or inducement of patent infringement, then any rights - granted to you under this License shall terminate as of the date - such litigation is filed. If you or your agent or exclusive - licensee institute or order or agree to the institution of a PATENT - CHALLENGE, then Tokutek may terminate any rights granted to you - under this License. -*/ - -#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved." -#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." - -#include "manager_unit_test.h" -#include "locktree_unit_test.h" -#include "lock_request_unit_test.h" - -namespace toku { - -static void assert_status(LTM_STATUS ltm_status, const char *keyname, uint64_t v) { - TOKU_ENGINE_STATUS_ROW key_status = NULL; - // lookup keyname in status - for (int i = 0; ; i++) { - TOKU_ENGINE_STATUS_ROW status = <m_status->status[i]; - if (status->keyname == NULL) - break; - if (strcmp(status->keyname, keyname) == 0) { - key_status = status; - break; - } - } - assert(key_status); - assert(key_status->value.num == v); -} - -void manager_unit_test::test_status(void) { - - locktree::manager mgr; - mgr.create(nullptr, nullptr, nullptr, nullptr); - - LTM_STATUS_S status; - mgr.get_status(&status); - assert_status(&status, "LTM_WAIT_COUNT", 0); - assert_status(&status, "LTM_TIMEOUT_COUNT", 0); - - DESCRIPTOR desc = nullptr; - DICTIONARY_ID dict_id = { 1 }; - locktree *lt = mgr.get_lt(dict_id, desc, compare_dbts, nullptr); - int r; - TXNID txnid_a = 1001; - TXNID txnid_b = 2001; - const DBT *one = get_dbt(1); - - // txn a write locks one - r = lt->acquire_write_lock(txnid_a, one, one, nullptr); - assert(r == 0); - - // txn b tries to write lock one, conflicts, waits, and fails to lock one - lock_request request_b; - request_b.create(); - request_b.set(lt, txnid_b, one, one, lock_request::type::WRITE); - r = request_b.start(); - assert(r == DB_LOCK_NOTGRANTED); - r = request_b.wait(1000); - assert(r == DB_LOCK_NOTGRANTED); - request_b.destroy(); - - range_buffer buffer; - buffer.create(); - buffer.append(one, one); - lt->release_locks(txnid_a, &buffer); - buffer.destroy(); - - assert(lt->m_rangetree->is_empty() && lt->m_sto_buffer.is_empty()); - - // assert that wait counters incremented - mgr.get_status(&status); - assert_status(&status, "LTM_WAIT_COUNT", 1); - assert_status(&status, "LTM_TIMEOUT_COUNT", 1); - - // assert that wait counters are persistent after the lock tree is destroyed - mgr.release_lt(lt); - mgr.get_status(&status); - assert_status(&status, "LTM_WAIT_COUNT", 1); - assert_status(&status, "LTM_TIMEOUT_COUNT", 1); - - mgr.destroy(); -} - -} /* namespace toku */ - -int main(void) { - toku::manager_unit_test test; - test.test_status(); - return 0; -} diff --git a/locktree/tests/manager_unit_test.h b/locktree/tests/manager_unit_test.h deleted file mode 100644 index ba38b9798..000000000 --- a/locktree/tests/manager_unit_test.h +++ /dev/null @@ -1,115 +0,0 @@ -/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: -#ident "$Id$" -/* -COPYING CONDITIONS NOTICE: - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation, and provided that the - following conditions are met: - - * Redistributions of source code must retain this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below). - - * Redistributions in binary form must reproduce this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below) in the documentation and/or other materials - provided with the distribution. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -COPYRIGHT NOTICE: - - TokuDB, Tokutek Fractal Tree Indexing Library. - Copyright (C) 2007-2013 Tokutek, Inc. - -DISCLAIMER: - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - -UNIVERSITY PATENT NOTICE: - - The technology is licensed by the Massachusetts Institute of - Technology, Rutgers State University of New Jersey, and the Research - Foundation of State University of New York at Stony Brook under - United States of America Serial No. 11/760379 and to the patents - and/or patent applications resulting from it. - -PATENT MARKING NOTICE: - - This software is covered by US Patent No. 8,185,551. - This software is covered by US Patent No. 8,489,638. - -PATENT RIGHTS GRANT: - - "THIS IMPLEMENTATION" means the copyrightable works distributed by - Tokutek as part of the Fractal Tree project. - - "PATENT CLAIMS" means the claims of patents that are owned or - licensable by Tokutek, both currently or in the future; and that in - the absence of this license would be infringed by THIS - IMPLEMENTATION or by using or running THIS IMPLEMENTATION. - - "PATENT CHALLENGE" shall mean a challenge to the validity, - patentability, enforceability and/or non-infringement of any of the - PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS. - - Tokutek hereby grants to you, for the term and geographical scope of - the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free, - irrevocable (except as stated in this section) patent license to - make, have made, use, offer to sell, sell, import, transfer, and - otherwise run, modify, and propagate the contents of THIS - IMPLEMENTATION, where such license applies only to the PATENT - CLAIMS. This grant does not include claims that would be infringed - only as a consequence of further modifications of THIS - IMPLEMENTATION. If you or your agent or licensee institute or order - or agree to the institution of patent litigation against any entity - (including a cross-claim or counterclaim in a lawsuit) alleging that - THIS IMPLEMENTATION constitutes direct or contributory patent - infringement, or inducement of patent infringement, then any rights - granted to you under this License shall terminate as of the date - such litigation is filed. If you or your agent or exclusive - licensee institute or order or agree to the institution of a PATENT - CHALLENGE, then Tokutek may terminate any rights granted to you - under this License. -*/ - -#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved." -#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." - -#ifndef TOKU_MANAGER_TEST_H -#define TOKU_MANAGER_TEST_H - -#include -#include - -namespace toku { - -class manager_unit_test { -public: - void test_create_destroy(void); - - void test_params(void); - - void test_lt_map(void); - - void test_reference_release_lt(void); - - void test_status(void); -}; - -} /* namespace toku */ - -#endif /* TOKU_MANAGER_TEST_H */ diff --git a/locktree/tests/range_buffer_test.cc b/locktree/tests/range_buffer_test.cc deleted file mode 100644 index 2fbc27e0d..000000000 --- a/locktree/tests/range_buffer_test.cc +++ /dev/null @@ -1,253 +0,0 @@ -/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: -#ident "$Id$" -/* -COPYING CONDITIONS NOTICE: - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation, and provided that the - following conditions are met: - - * Redistributions of source code must retain this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below). - - * Redistributions in binary form must reproduce this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below) in the documentation and/or other materials - provided with the distribution. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -COPYRIGHT NOTICE: - - TokuDB, Tokutek Fractal Tree Indexing Library. - Copyright (C) 2007-2013 Tokutek, Inc. - -DISCLAIMER: - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - -UNIVERSITY PATENT NOTICE: - - The technology is licensed by the Massachusetts Institute of - Technology, Rutgers State University of New Jersey, and the Research - Foundation of State University of New York at Stony Brook under - United States of America Serial No. 11/760379 and to the patents - and/or patent applications resulting from it. - -PATENT MARKING NOTICE: - - This software is covered by US Patent No. 8,185,551. - This software is covered by US Patent No. 8,489,638. - -PATENT RIGHTS GRANT: - - "THIS IMPLEMENTATION" means the copyrightable works distributed by - Tokutek as part of the Fractal Tree project. - - "PATENT CLAIMS" means the claims of patents that are owned or - licensable by Tokutek, both currently or in the future; and that in - the absence of this license would be infringed by THIS - IMPLEMENTATION or by using or running THIS IMPLEMENTATION. - - "PATENT CHALLENGE" shall mean a challenge to the validity, - patentability, enforceability and/or non-infringement of any of the - PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS. - - Tokutek hereby grants to you, for the term and geographical scope of - the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free, - irrevocable (except as stated in this section) patent license to - make, have made, use, offer to sell, sell, import, transfer, and - otherwise run, modify, and propagate the contents of THIS - IMPLEMENTATION, where such license applies only to the PATENT - CLAIMS. This grant does not include claims that would be infringed - only as a consequence of further modifications of THIS - IMPLEMENTATION. If you or your agent or licensee institute or order - or agree to the institution of patent litigation against any entity - (including a cross-claim or counterclaim in a lawsuit) alleging that - THIS IMPLEMENTATION constitutes direct or contributory patent - infringement, or inducement of patent infringement, then any rights - granted to you under this License shall terminate as of the date - such litigation is filed. If you or your agent or exclusive - licensee institute or order or agree to the institution of a PATENT - CHALLENGE, then Tokutek may terminate any rights granted to you - under this License. -*/ - -#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved." -#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." - -#include "test.h" - -#include - -#include - -#include - -namespace toku { - -const size_t num_points = 60; - -static const DBT *get_dbt_by_iteration(size_t i) { - if (i == 0) { - return toku_dbt_negative_infinity(); - } else if (i < (num_points - 1)) { - return get_dbt(i); - } else { - return toku_dbt_positive_infinity(); - } -} - -static void test_points(void) { - range_buffer buffer; - buffer.create(); - - for (size_t i = 0; i < num_points; i++) { - const DBT *point = get_dbt_by_iteration(i); - buffer.append(point, point); - } - - size_t i = 0; - range_buffer::iterator iter; - range_buffer::iterator::record rec; - iter.create(&buffer); - while (iter.current(&rec)) { - const DBT *expected_point = get_dbt_by_iteration(i); - invariant(compare_dbts(nullptr, expected_point, rec.get_left_key()) == 0); - invariant(compare_dbts(nullptr, expected_point, rec.get_right_key()) == 0); - iter.next(); - i++; - } - invariant(i == num_points); - - buffer.destroy(); -} - -static void test_ranges(void) { - range_buffer buffer; - buffer.create(); - - // we are going to store adjacent points as ranges, - // so make sure there are an even number of points. - invariant(num_points % 2 == 0); - - for (size_t i = 0; i < num_points; i += 2) { - const DBT *left = get_dbt_by_iteration(i); - const DBT *right = get_dbt_by_iteration(i + 1); - buffer.append(left, right); - } - - size_t i = 0; - range_buffer::iterator iter; - range_buffer::iterator::record rec; - iter.create(&buffer); - while (iter.current(&rec)) { - const DBT *expected_left = get_dbt_by_iteration(i); - const DBT *expected_right = get_dbt_by_iteration(i + 1); - invariant(compare_dbts(nullptr, expected_left, rec.get_left_key()) == 0); - invariant(compare_dbts(nullptr, expected_right, rec.get_right_key()) == 0); - iter.next(); - i += 2; - } - invariant(i == num_points); - - buffer.destroy(); - -} - -static void test_mixed(void) { - range_buffer buffer; - buffer.create(); - buffer.destroy(); - - // we are going to store adjacent points as ranges, - // followed by a single point, so make sure the - // number of points is a multiple of 3. - invariant(num_points % 3 == 0); - - for (size_t i = 0; i < num_points; i += 3) { - const DBT *left = get_dbt_by_iteration(i); - const DBT *right = get_dbt_by_iteration(i + 1); - const DBT *point = get_dbt_by_iteration(i + 2); - buffer.append(left, right); - buffer.append(point, point); - } - - size_t i = 0; - range_buffer::iterator iter; - range_buffer::iterator::record rec; - iter.create(&buffer); - while (iter.current(&rec)) { - const DBT *expected_left = get_dbt_by_iteration(i); - const DBT *expected_right = get_dbt_by_iteration(i + 1); - invariant(compare_dbts(nullptr, expected_left, rec.get_left_key()) == 0); - invariant(compare_dbts(nullptr, expected_right, rec.get_right_key()) == 0); - iter.next(); - - const DBT *expected_point = get_dbt_by_iteration(i + 2); - bool had_point = iter.current(&rec); - invariant(had_point); - invariant(compare_dbts(nullptr, expected_point, rec.get_left_key()) == 0); - invariant(compare_dbts(nullptr, expected_point, rec.get_right_key()) == 0); - iter.next(); - i += 3; - } - invariant(i == num_points); - - buffer.destroy(); -} - -static void test_small_and_large_points(void) { - range_buffer buffer; - buffer.create(); - buffer.destroy(); - - // Test a bug where a small append would cause - // the range buffer to not grow properly for - // a subsequent large append. - const size_t small_size = 32; - const size_t large_size = 16 * 1024; - char *small_buf = (char *) toku_xmalloc(small_size); - char *large_buf = (char *) toku_xmalloc(large_size); - DBT small_dbt, large_dbt; - memset(&small_dbt, 0, sizeof(DBT)); - memset(&large_dbt, 0, sizeof(DBT)); - small_dbt.data = small_buf; - small_dbt.size = small_size; - large_dbt.data = large_buf; - large_dbt.size = large_size; - - // Append a small dbt, the buf should be able to fit it. - buffer.append(&small_dbt, &small_dbt); - invariant(buffer.m_buf_size >= small_dbt.size); - // Append a large dbt, the buf should be able to fit it. - buffer.append(&large_dbt, &large_dbt); - invariant(buffer.m_buf_size >= (small_dbt.size + large_dbt.size)); - - toku_free(small_buf); - toku_free(large_buf); - buffer.destroy(); -} - -} /* namespace toku */ - -int main(void) { - toku::test_points(); - toku::test_ranges(); - toku::test_mixed(); - toku::test_small_and_large_points(); - return 0; -} diff --git a/locktree/tests/test.h b/locktree/tests/test.h deleted file mode 100644 index cf9a80554..000000000 --- a/locktree/tests/test.h +++ /dev/null @@ -1,164 +0,0 @@ -/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: -#ident "$Id$" -/* -COPYING CONDITIONS NOTICE: - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation, and provided that the - following conditions are met: - - * Redistributions of source code must retain this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below). - - * Redistributions in binary form must reproduce this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below) in the documentation and/or other materials - provided with the distribution. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -COPYRIGHT NOTICE: - - TokuDB, Tokutek Fractal Tree Indexing Library. - Copyright (C) 2007-2013 Tokutek, Inc. - -DISCLAIMER: - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - -UNIVERSITY PATENT NOTICE: - - The technology is licensed by the Massachusetts Institute of - Technology, Rutgers State University of New Jersey, and the Research - Foundation of State University of New York at Stony Brook under - United States of America Serial No. 11/760379 and to the patents - and/or patent applications resulting from it. - -PATENT MARKING NOTICE: - - This software is covered by US Patent No. 8,185,551. - This software is covered by US Patent No. 8,489,638. - -PATENT RIGHTS GRANT: - - "THIS IMPLEMENTATION" means the copyrightable works distributed by - Tokutek as part of the Fractal Tree project. - - "PATENT CLAIMS" means the claims of patents that are owned or - licensable by Tokutek, both currently or in the future; and that in - the absence of this license would be infringed by THIS - IMPLEMENTATION or by using or running THIS IMPLEMENTATION. - - "PATENT CHALLENGE" shall mean a challenge to the validity, - patentability, enforceability and/or non-infringement of any of the - PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS. - - Tokutek hereby grants to you, for the term and geographical scope of - the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free, - irrevocable (except as stated in this section) patent license to - make, have made, use, offer to sell, sell, import, transfer, and - otherwise run, modify, and propagate the contents of THIS - IMPLEMENTATION, where such license applies only to the PATENT - CLAIMS. This grant does not include claims that would be infringed - only as a consequence of further modifications of THIS - IMPLEMENTATION. If you or your agent or licensee institute or order - or agree to the institution of patent litigation against any entity - (including a cross-claim or counterclaim in a lawsuit) alleging that - THIS IMPLEMENTATION constitutes direct or contributory patent - infringement, or inducement of patent infringement, then any rights - granted to you under this License shall terminate as of the date - such litigation is filed. If you or your agent or exclusive - licensee institute or order or agree to the institution of a PATENT - CHALLENGE, then Tokutek may terminate any rights granted to you - under this License. -*/ - -#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved." -#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." - -#ifndef TOKU_TEST_H -#define TOKU_TEST_H - -#include -#include - -namespace toku { - -__attribute__((__unused__)) -static DBT min_dbt(void) { - static int64_t min = INT_MIN; - DBT dbt; - toku_fill_dbt(&dbt, &min, sizeof(int64_t)); - dbt.flags = DB_DBT_USERMEM; - return dbt; -} - -__attribute__((__unused__)) -static DBT max_dbt(void) { - static int64_t max = INT_MAX; - DBT dbt; - toku_fill_dbt(&dbt, &max, sizeof(int64_t)); - dbt.flags = DB_DBT_USERMEM; - return dbt; -} - -__attribute__((__unused__)) -static const DBT *get_dbt(int64_t key) { - static const int NUM_DBTS = 1000; - static bool initialized; - static int64_t static_ints[NUM_DBTS]; - static DBT static_dbts[NUM_DBTS]; - invariant(key < NUM_DBTS); - if (!initialized) { - for (int i = 0; i < NUM_DBTS; i++) { - static_ints[i] = i; - toku_fill_dbt(&static_dbts[i], - &static_ints[i], - sizeof(int64_t)); - static_dbts[i].flags = DB_DBT_USERMEM; - } - initialized = true; - } - - invariant(key < NUM_DBTS); - return &static_dbts[key]; -} - -__attribute__((__unused__)) -static int compare_dbts(DB *db, const DBT *key1, const DBT *key2) { - (void) db; - - // this emulates what a "infinity-aware" comparator object does - if (toku_dbt_is_infinite(key1) || toku_dbt_is_infinite(key2)) { - return toku_dbt_infinite_compare(key1, key2); - } else { - invariant(key1->size == sizeof(int64_t)); - invariant(key2->size == sizeof(int64_t)); - int64_t a = *(int64_t*) key1->data; - int64_t b = *(int64_t*) key2->data; - if (a < b) { - return -1; - } else if (a == b) { - return 0; - } else { - return 1; - } - } -} - -} /* namespace toku */ - -#endif diff --git a/locktree/tests/txnid_set_test.cc b/locktree/tests/txnid_set_test.cc deleted file mode 100644 index fe442a506..000000000 --- a/locktree/tests/txnid_set_test.cc +++ /dev/null @@ -1,164 +0,0 @@ -/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: -#ident "$Id$" -/* -COPYING CONDITIONS NOTICE: - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation, and provided that the - following conditions are met: - - * Redistributions of source code must retain this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below). - - * Redistributions in binary form must reproduce this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below) in the documentation and/or other materials - provided with the distribution. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -COPYRIGHT NOTICE: - - TokuDB, Tokutek Fractal Tree Indexing Library. - Copyright (C) 2007-2013 Tokutek, Inc. - -DISCLAIMER: - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - -UNIVERSITY PATENT NOTICE: - - The technology is licensed by the Massachusetts Institute of - Technology, Rutgers State University of New Jersey, and the Research - Foundation of State University of New York at Stony Brook under - United States of America Serial No. 11/760379 and to the patents - and/or patent applications resulting from it. - -PATENT MARKING NOTICE: - - This software is covered by US Patent No. 8,185,551. - This software is covered by US Patent No. 8,489,638. - -PATENT RIGHTS GRANT: - - "THIS IMPLEMENTATION" means the copyrightable works distributed by - Tokutek as part of the Fractal Tree project. - - "PATENT CLAIMS" means the claims of patents that are owned or - licensable by Tokutek, both currently or in the future; and that in - the absence of this license would be infringed by THIS - IMPLEMENTATION or by using or running THIS IMPLEMENTATION. - - "PATENT CHALLENGE" shall mean a challenge to the validity, - patentability, enforceability and/or non-infringement of any of the - PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS. - - Tokutek hereby grants to you, for the term and geographical scope of - the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free, - irrevocable (except as stated in this section) patent license to - make, have made, use, offer to sell, sell, import, transfer, and - otherwise run, modify, and propagate the contents of THIS - IMPLEMENTATION, where such license applies only to the PATENT - CLAIMS. This grant does not include claims that would be infringed - only as a consequence of further modifications of THIS - IMPLEMENTATION. If you or your agent or licensee institute or order - or agree to the institution of patent litigation against any entity - (including a cross-claim or counterclaim in a lawsuit) alleging that - THIS IMPLEMENTATION constitutes direct or contributory patent - infringement, or inducement of patent infringement, then any rights - granted to you under this License shall terminate as of the date - such litigation is filed. If you or your agent or exclusive - licensee institute or order or agree to the institution of a PATENT - CHALLENGE, then Tokutek may terminate any rights granted to you - under this License. -*/ - -#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved." -#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." - -#include -#include - -int main(void) { - toku::txnid_set set; - set.create(); - // make sure this set is a real set - for (size_t i = 0; i < 5; i++) { - set.add(0); - invariant(set.size() == 1); - } - set.add(1); - set.add(100); - invariant(set.size() == 3); - invariant(!set.contains(2)); - invariant(!set.contains(99)); - invariant(!set.contains(101)); - invariant(set.contains(100)); - invariant(set.contains(1)); - - // go through the set and make sure we saw everything - bool saw0 = false, saw1 = false, saw100 = false; - for (size_t i = 0; i < set.size(); i++) { - TXNID x = set.get(i); - if (x == 0) { - invariant(!saw0); - saw0 = true; - } else if (x == 1) { - invariant(!saw1); - saw1 = true; - } else if (x == 100) { - invariant(!saw100); - saw100 = true; - } else { - assert(false); - } - } - invariant(saw0); - invariant(saw1); - invariant(saw100); - - // make sure we see 0 and 100 but not 1 - set.remove(1); - saw0 = false; - saw100 = false; - for (size_t i = 0; i < set.size(); i++) { - TXNID x = set.get(i); - if (x == 0) { - invariant(!saw0); - saw0 = true; - } else if (x == 100) { - invariant(!saw100); - saw100 = true; - } else { - assert(false); - } - } - invariant(saw0); - invariant(saw100); - - // removing non-existant things is okay - set.remove(0); - set.remove(100); - set.remove(1); - set.remove(1010101); - set.remove(1212121); - - // empty out what we know is in there - set.remove(100); - set.remove(0); - invariant(set.size() == 0); - set.destroy(); -} diff --git a/locktree/tests/wfg_test.cc b/locktree/tests/wfg_test.cc deleted file mode 100644 index a7669135b..000000000 --- a/locktree/tests/wfg_test.cc +++ /dev/null @@ -1,225 +0,0 @@ -/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: -#ident "$Id$" -/* -COPYING CONDITIONS NOTICE: - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation, and provided that the - following conditions are met: - - * Redistributions of source code must retain this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below). - - * Redistributions in binary form must reproduce this COPYING - CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the - DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the - PATENT MARKING NOTICE (below), and the PATENT RIGHTS - GRANT (below) in the documentation and/or other materials - provided with the distribution. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -COPYRIGHT NOTICE: - - TokuDB, Tokutek Fractal Tree Indexing Library. - Copyright (C) 2007-2013 Tokutek, Inc. - -DISCLAIMER: - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - -UNIVERSITY PATENT NOTICE: - - The technology is licensed by the Massachusetts Institute of - Technology, Rutgers State University of New Jersey, and the Research - Foundation of State University of New York at Stony Brook under - United States of America Serial No. 11/760379 and to the patents - and/or patent applications resulting from it. - -PATENT MARKING NOTICE: - - This software is covered by US Patent No. 8,185,551. - This software is covered by US Patent No. 8,489,638. - -PATENT RIGHTS GRANT: - - "THIS IMPLEMENTATION" means the copyrightable works distributed by - Tokutek as part of the Fractal Tree project. - - "PATENT CLAIMS" means the claims of patents that are owned or - licensable by Tokutek, both currently or in the future; and that in - the absence of this license would be infringed by THIS - IMPLEMENTATION or by using or running THIS IMPLEMENTATION. - - "PATENT CHALLENGE" shall mean a challenge to the validity, - patentability, enforceability and/or non-infringement of any of the - PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS. - - Tokutek hereby grants to you, for the term and geographical scope of - the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free, - irrevocable (except as stated in this section) patent license to - make, have made, use, offer to sell, sell, import, transfer, and - otherwise run, modify, and propagate the contents of THIS - IMPLEMENTATION, where such license applies only to the PATENT - CLAIMS. This grant does not include claims that would be infringed - only as a consequence of further modifications of THIS - IMPLEMENTATION. If you or your agent or licensee institute or order - or agree to the institution of patent litigation against any entity - (including a cross-claim or counterclaim in a lawsuit) alleging that - THIS IMPLEMENTATION constitutes direct or contributory patent - infringement, or inducement of patent infringement, then any rights - granted to you under this License shall terminate as of the date - such litigation is filed. If you or your agent or exclusive - licensee institute or order or agree to the institution of a PATENT - CHALLENGE, then Tokutek may terminate any rights granted to you - under this License. -*/ - -#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved." -#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." - -#include - -namespace toku { - -enum { - WFG_TEST_MAX_TXNID = 10 -}; - -struct visit_extra { - bool nodes_visited[WFG_TEST_MAX_TXNID]; - bool edges_visited[WFG_TEST_MAX_TXNID][WFG_TEST_MAX_TXNID]; - - void clear(void) { - memset(nodes_visited, 0, sizeof(nodes_visited)); - memset(edges_visited, 0, sizeof(edges_visited)); - } -}; - -// wfg node visit callback -static int visit_nodes(TXNID txnid, void *extra) { - visit_extra *ve = static_cast(extra); - invariant(txnid < WFG_TEST_MAX_TXNID); - invariant(!ve->nodes_visited[txnid]); - ve->nodes_visited[txnid] = true; - return 0; -} - -// wfg edge visit callback -static int visit_edges(TXNID txnid, TXNID edge_txnid, void *extra) { - visit_extra *ve = static_cast(extra); - invariant(txnid < WFG_TEST_MAX_TXNID); - invariant(edge_txnid < WFG_TEST_MAX_TXNID); - invariant(!ve->edges_visited[txnid][edge_txnid]); - ve->edges_visited[txnid][edge_txnid] = true; - return 0; -} - -// the graph should only have 3 nodes labelled 0 1 and 2 -static void verify_only_nodes_012_exist(wfg *g) { - visit_extra ve; - ve.clear(); - g->apply_nodes(visit_nodes, &ve); - for (int i = 0; i < WFG_TEST_MAX_TXNID; i++) { - if (i == 0 || i == 1 || i == 2) { - invariant(ve.nodes_visited[i]); - } else { - invariant(!ve.nodes_visited[i]); - } - } -} - -// the graph should only have edges 0->1 and 1->2 -static void verify_only_edges_01_12_exist(wfg *g) { - visit_extra ve; - ve.clear(); - g->apply_edges(0, visit_edges, &ve); - g->apply_edges(1, visit_edges, &ve); - g->apply_edges(2, visit_edges, &ve); - for (int i = 0; i < WFG_TEST_MAX_TXNID; i++) { - for (int j = 0; j < WFG_TEST_MAX_TXNID; j++) { - if ((i == 0 && j == 1) || (i == 1 && j == 2)) { - invariant(ve.edges_visited[i][j]); - } else { - invariant(!ve.edges_visited[i][j]); - } - } - } -} - -static void test_add_cycle_exists() { - wfg g; - g.create(); - - // test that adding edges works and is idempotent - - g.add_edge(0, 1); - invariant(g.node_exists(0)); - invariant(g.node_exists(1)); - g.add_edge(1, 2); - invariant(g.node_exists(0)); - invariant(g.node_exists(1)); - invariant(g.node_exists(2)); - - // verify that adding edges with the same nodes - // does not store multiple nodes with the same txnid. - verify_only_nodes_012_exist(&g); - verify_only_edges_01_12_exist(&g); - g.add_edge(0, 1); - g.add_edge(1, 2); - verify_only_nodes_012_exist(&g); - verify_only_edges_01_12_exist(&g); - - // confirm that no cycle exists from txnid 0 1 or 2 - invariant(!g.cycle_exists_from_txnid(0)); - invariant(!g.cycle_exists_from_txnid(1)); - invariant(!g.cycle_exists_from_txnid(2)); - - // add 2,3 and 3,1. now there should be a cycle - // from 1 2 and 3 but not 0. - // - // 0 --> 1 --> 2 - // ^ / - // ^ 3 < - g.add_edge(2, 3); - g.add_edge(3, 1); - invariant(!g.cycle_exists_from_txnid(0)); - invariant(g.cycle_exists_from_txnid(1)); - invariant(g.cycle_exists_from_txnid(2)); - invariant(g.cycle_exists_from_txnid(3)); - - // add 2,4. should not have a cycle from 4, but yes from 2. - g.add_edge(2, 4); - invariant(!g.cycle_exists_from_txnid(4)); - invariant(g.cycle_exists_from_txnid(2)); - - g.destroy(); -} - -static void test_find_cycles() { - wfg g; - g.create(); - - // TODO: verify that finding cycles works - - g.destroy(); -} - -} /* namespace toku */ - -int main(void) { - toku::test_add_cycle_exists(); - toku::test_find_cycles(); - return 0; -}