Skip to content

Commit

Permalink
add sql ledger, fix merkle tree
Browse files Browse the repository at this point in the history
  • Loading branch information
yc1111 committed Dec 15, 2022
1 parent a61f975 commit 4c2f1ab
Show file tree
Hide file tree
Showing 53 changed files with 118 additions and 195 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
build/
exps/result/
exps/shard*
.vscode
5 changes: 4 additions & 1 deletion distributed/store/common/backend/versionstore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ bool VersionedKVStore::GetProof(
strongstore::proto::Reply* reply) {
timeval t0, t1;
gettimeofday(&t0, NULL);
int nkey = 0;
#ifdef LEDGERDB
std::vector<ledgebase::ledgerdb::Proof> mtproof;
std::vector<ledgebase::ledgerdb::MPTProof> mptproof;
Expand All @@ -243,6 +244,7 @@ bool VersionedKVStore::GetProof(
blks.push_back(vkey.first);
}
}
nkey = ks.size();

ldb->GetProofs(ks, blks, mtproof, mptproof, &mtdigest,
&block, &mptdigest);
Expand Down Expand Up @@ -270,6 +272,7 @@ bool VersionedKVStore::GetProof(
GetDigest(reply);
for (auto& entry : keys) {
for (auto& key : entry.second) {
nkey++;
auto res = sqlledger_->getProof(key, entry.first);
auto p = reply->add_sproof();
auto blk_proof = p->mutable_blk_proof();
Expand All @@ -296,7 +299,7 @@ bool VersionedKVStore::GetProof(

gettimeofday(&t1, NULL);
auto lat = (t1.tv_sec - t0.tv_sec)*1000000 + t1.tv_usec - t0.tv_usec;
//std::cout << "getproof " << lat << " " << ks.size() << std::endl;
//std::cout << "getproof " << lat << " " << nkey << std::endl;
return true;
}

Expand Down
14 changes: 13 additions & 1 deletion distributed/store/strongstore/shardclient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ ShardClient::GetProofCallback(size_t uid,
gettimeofday(&t1, NULL);
auto elapsed = ((t1.tv_sec - t0.tv_sec)*1000000 +
(t1.tv_usec - t0.tv_usec));
// std::cout << "verify " << elapsed << " " << reply.ByteSizeLong() << " " << keys.size() << " " << res << std::endl;
//std::cout << "verify " << elapsed << " " << reply.ByteSizeLong() << " " << keys.size() << " " << res << std::endl;

Promise *w = verifyPromise[uid];
verifyPromise.erase(uid);
Expand Down Expand Up @@ -514,6 +514,8 @@ ShardClient::BatchGetCallback(const string &request_str, const string &reply_str
}
#endif
#ifdef AMZQLDB
struct timeval t0, t1;
gettimeofday(&t0, NULL);
VerifyStatus vs = VerifyStatus::PASS;
ledgebase::Hash digest;
std::string ledger = "test";
Expand Down Expand Up @@ -542,6 +544,10 @@ ShardClient::BatchGetCallback(const string &request_str, const string &reply_str
vs = VerifyStatus::FAILED;
}
}
gettimeofday(&t1, NULL);
auto elapsed = ((t1.tv_sec - t0.tv_sec)*1000000 +
(t1.tv_usec - t0.tv_usec));
// std::cout << "verify " << elapsed << " " << reply.ByteSizeLong() << " " << reply.qproof_size() << " " << vs << std::endl;
#endif

Promise *w = waiting;
Expand Down Expand Up @@ -574,6 +580,8 @@ ShardClient::CommitCallback(const string &request_str, const string &reply_str)
}
#endif
#ifdef AMZQLDB
struct timeval t0, t1;
gettimeofday(&t0, NULL);
vs = VerifyStatus::PASS;
std::string ledger = "test";
auto digest = ledgebase::Hash::FromBase32(reply.digest().hash());
Expand All @@ -597,6 +605,10 @@ ShardClient::CommitCallback(const string &request_str, const string &reply_str)
vs = VerifyStatus::FAILED;
}
}
gettimeofday(&t1, NULL);
auto elapsed = ((t1.tv_sec - t0.tv_sec)*1000000 +
(t1.tv_usec - t0.tv_usec));
std::cout << "verify " << elapsed << " " << reply.ByteSizeLong() << " " << reply.qproof_size() << " " << vs << std::endl;
#endif

Promise *w = waiting;
Expand Down
8 changes: 8 additions & 0 deletions exps/aggregate_ycsb.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
sumH = 0.0
numV = 0.0
sumV = 0.0
sumN = 0.0

path = sys.argv[1]
outpath = sys.argv[2]
Expand All @@ -34,6 +35,7 @@
sumH = sumH + float(lines[10])
numV = numV + float(lines[11])
sumV = sumV + float(lines[12])
sumN = sumN + float(lines[13])

outfile = open(outpath, "w")
outfile.write(str(numSuccess/duration) + "\n")
Expand All @@ -60,3 +62,9 @@
outfile.write("0\n")
else:
outfile.write(str(sumV/numV) + "\n")

if sumN > 0:
outfile.write(str(sumV/sumN) + "\n")
else:
outfile.write("0\n")

3 changes: 3 additions & 0 deletions exps/parse_ycsb.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def print_result(fp, path, wper, servers, clients, t, lineno):
wlat = open(path + "/write", "w")
hlat = open(path + "/history", "w")
vlat = open(path + "/verify", "w")
vpk = open(path + "/verifyperkey", "w")

print_result(ftps, path, wper, servers, clients, t, 0)
print_result(flat, path, wper, servers, clients, t, 1)
Expand All @@ -44,6 +45,7 @@ def print_result(fp, path, wper, servers, clients, t, lineno):
print_result(wlat, path, wper, servers, clients, t, 6)
print_result(hlat, path, wper, servers, clients, t, 7)
print_result(vlat, path, wper, servers, clients, t, 8)
print_result(vpk, path, wper, servers, clients, t, 9)

ftps.close()
flat.close()
Expand All @@ -52,3 +54,4 @@ def print_result(fp, path, wper, servers, clients, t, lineno):
wlat.close()
hlat.close()
vlat.close()
vpk.close()
7 changes: 7 additions & 0 deletions exps/process_ycsb.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
wLatency = []
hLatency = []
vLatency = []
nkey = 0
nkeys = []

tExtra = 0.0
sExtra = 0.0
Expand All @@ -23,6 +25,9 @@
for line in open(sys.argv[1]):
if line.startswith('#') or line.strip() == "":
continue
if line.startswith("verifynkeys"):
nkey = float(line[12:-1])
continue

line = line.strip().split()
if not line[0].isdigit() or len(line) < 4:
Expand Down Expand Up @@ -56,6 +61,7 @@
elif op == 2:
hLatency.append(latency)
elif int(line[0]) > 0:
nkeys.append(nkey)
vLatency.append(latency)

tLatency.append(latency)
Expand Down Expand Up @@ -90,6 +96,7 @@
outfile.write(str(sum(hLatency)) + "\n")
outfile.write(str(len(vLatency)) + "\n")
outfile.write(str(sum(vLatency)) + "\n")
outfile.write(str(sum(nkeys)) + "\n")
# print "Transactions(All/Success): ", len(tLatency), len(sLatency)
# print "Abort Rate: ", (float)(len(tLatency)-len(sLatency))/len(tLatency)
# print "Throughput (All/Success): ", len(tLatency)/(end-start), len(sLatency)/(end-start)
Expand Down
9 changes: 0 additions & 9 deletions exps/result/50_16_10_0

This file was deleted.

9 changes: 0 additions & 9 deletions exps/result/50_16_1_0

This file was deleted.

9 changes: 0 additions & 9 deletions exps/result/50_16_20_0

This file was deleted.

9 changes: 0 additions & 9 deletions exps/result/50_16_2_0

This file was deleted.

9 changes: 0 additions & 9 deletions exps/result/50_16_3_0

This file was deleted.

9 changes: 0 additions & 9 deletions exps/result/50_16_4_0

This file was deleted.

9 changes: 0 additions & 9 deletions exps/result/50_16_5_0

This file was deleted.

9 changes: 0 additions & 9 deletions exps/result/50_16_6_0

This file was deleted.

9 changes: 0 additions & 9 deletions exps/result/50_16_7_0

This file was deleted.

9 changes: 0 additions & 9 deletions exps/result/50_16_8_0

This file was deleted.

9 changes: 0 additions & 9 deletions exps/result/50_16_9_0

This file was deleted.

2 changes: 0 additions & 2 deletions exps/result/abort_50_0

This file was deleted.

2 changes: 0 additions & 2 deletions exps/result/history

This file was deleted.

2 changes: 0 additions & 2 deletions exps/result/lat_50_0

This file was deleted.

2 changes: 0 additions & 2 deletions exps/result/read

This file was deleted.

2 changes: 0 additions & 2 deletions exps/result/tps_50_0

This file was deleted.

2 changes: 0 additions & 2 deletions exps/result/verify

This file was deleted.

2 changes: 0 additions & 2 deletions exps/result/write

This file was deleted.

4 changes: 3 additions & 1 deletion exps/run_exp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ wperc=(50)
nshards=(16)

# Number of client processes per client node
nclients=(1)
nclients=(10)

# Zipf factor
theta=(0)
Expand All @@ -33,6 +33,7 @@ thetas=$( IFS=$','; echo "${theta[*]}" )

for i in ${wperc[@]}
do
let rper=100-$i
for j in ${nshards[@]}
do
./load.sh $j
Expand All @@ -47,6 +48,7 @@ do
sed -i -e "s/tlen=[0-9]*/tlen=${tlen}/g" run_$driver.sh
sed -i -e "s/rtime=[0-9]*/rtime=${rtime}/g" run_$driver.sh
sed -i -e "s/wper=[0-9]*/wper=$i/g" run_$driver.sh
sed -i -e "s/rper=[0-9]*/rper=$rper/g" run_$driver.sh
sed -i -e "s/nshard=[0-9]*/nshard=$j/g" run_$driver.sh
sed -i -e "s/nclient=[0-9]*/nclient=$c/g" run_$driver.sh
sed -i -e "s/zalpha=[0-9\.]*/zalpha=$k/g" run_$driver.sh
Expand Down
10 changes: 5 additions & 5 deletions exps/run_tpcc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

#============= Parameters to fill ============
nshard=16 # number of shards
nclient=20 # number of clients / machine
nclient=10 # number of clients / machine
rtime=120 # duration to run
delay=100 # verification delay
delay=1000 # verification delay

wper=50 # writes percentage
wper=0 # writes percentage
zalpha=0 # zipf alpha
#============= Start Experiment =============
. env.sh
Expand Down Expand Up @@ -34,12 +34,12 @@ for ((i=0; i<$nshard; i++))
do
echo "Starting shard$i replicas.."
$expdir/start_replica.sh shard$i $expdir/shard$i.config \
"$bindir/$store -m $mode -e 0 -s 0 -w tpcc -f $initfile -N $nshard -n $i" $logdir
"$bindir/$store -m $mode -e 0 -s 0 -w tpcc -f $initfile -N $nshard -n $i -t 100" $logdir
done


# Wait a bit for all replicas to start up
sleep 10
sleep 50

# Run the clients
echo "Running the client(s)"
Expand Down
10 changes: 5 additions & 5 deletions exps/run_ycsb.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/bash

#============= Parameters to fill ============
nshard=16 # number of shards
nclient=1 # number of clients / machine
nshard=1 # number of shards
nclient=20 # number of clients / machine
rtime=120 # duration to run
delay=100 # verification delay

tlen=10 # transaction length
tlen=1 # transaction length
wper=50 # writes percentage
rper=50 # reads percentage
zalpha=0 # zipf alpha
Expand All @@ -19,7 +19,7 @@ clients=`cat clients`
client="verifyClient"
store="strongstore"
mode="occ"
txnrate=1000
txnrate=120

# Print out configuration being used.
echo "Configuration:"
Expand All @@ -40,7 +40,7 @@ for ((i=0; i<$nshard; i++))
do
echo "Starting shard$i replicas.."
$expdir/start_replica.sh shard$i $expdir/shard$i.config \
"$bindir/$store -m $mode -e 0 -s 0 -N $nshard -n $i -w ycsb -k 100000" $logdir
"$bindir/$store -m $mode -e 0 -s 0 -N $nshard -n $i -t 100 -w ycsb -k 100000" $logdir
done

# Wait a bit for all replicas to start up
Expand Down
2 changes: 0 additions & 2 deletions exps/shard.tss.config

This file was deleted.

2 changes: 0 additions & 2 deletions exps/shard0.config

This file was deleted.

2 changes: 0 additions & 2 deletions exps/shard1.config

This file was deleted.

Loading

0 comments on commit 4c2f1ab

Please sign in to comment.