Skip to content

Commit

Permalink
Add client for Checksum application for MD5, SHA1, SHA256, SHA512 has…
Browse files Browse the repository at this point in the history
…hing.
  • Loading branch information
ankitbhrdwj committed Sep 15, 2019
1 parent 9965ff2 commit 01f9212
Show file tree
Hide file tree
Showing 8 changed files with 1,109 additions and 38 deletions.
6 changes: 6 additions & 0 deletions db/src/master.rs
Expand Up @@ -657,6 +657,12 @@ impl Master {
if self.extensions.load(name, tenant, "ycsbt") == false {
panic!("Failed to load ycsbt() extension.");
}

// Load the checksum() extension.
let name = "../ext/checksum/target/release/libchecksum.so";
if self.extensions.load(name, tenant, "checksum") == false {
panic!("Failed to load checksum() extension.");
}
}

/// Loads the get(), put(), and tao() extensions once, and shares them across multiple tenants.
Expand Down
71 changes: 37 additions & 34 deletions ext/checksum/src/lib.rs
Expand Up @@ -79,13 +79,15 @@ pub fn init(db: Rc<DB>) -> Box<Generator<Yield = u64, Return = u64>> {
let mut err = INVALIDARG;
let mut num: u32 = 0;
let mut aggr: u64 = 0;
let mut optype: u8 = 0;
let mut obj: Option<ReadBuf> = None;
let mut buf: Option<MultiReadBuf> = None;
{
let arg: &[u8] = db.args();
let (t, val) = arg.split_at(size_of::<u64>());
let (n, val) = val.split_at(size_of::<u32>());
let (o, key) = val.split_at(size_of::<u32>());
let (t, rem) = arg.split_at(size_of::<u64>());
let (n, rem) = rem.split_at(size_of::<u32>());
let (key, op) = rem.split_at(size_of::<u64>());
optype = op[0];

// Get the table id from the unwrapped arguments.
let mut table: u64 = 0;
Expand All @@ -94,13 +96,7 @@ pub fn init(db: Rc<DB>) -> Box<Generator<Yield = u64, Return = u64>> {
}

// Get the number of keys to aggregate across.
let mut num_k: u32 = 0;
for (idx, e) in n.iter().enumerate() {
num_k |= (*e as u32) << (idx << 3);
}

// Get the order.
for (idx, e) in o.iter().enumerate() {
num |= (*e as u32) << (idx << 3);
}

Expand All @@ -110,38 +106,45 @@ pub fn init(db: Rc<DB>) -> Box<Generator<Yield = u64, Return = u64>> {

// Try performing the aggregate if the key list was successfully retrieved.
if let Some(val) = obj {
let value = val
.read()
.split_at((KEYLENGTH as usize) * (num_k as usize))
.0;
let value = val.read().split_at((KEYLENGTH as usize) * (num as usize)).0;

MULTIGET1!(db, table, KEYLENGTH, value, buf);

match buf {
Some(vals) => {
let mut i = 0;
while vals.next() {
if i < num {
let result = digest(Algorithm::MD5, vals.read());
//let result = digest(Algorithm::SHA1, vals.read());
//let result = digest(Algorithm::SHA256, vals.read());
//let result = digest(Algorithm::SHA512, vals.read());
aggr += result[0] as u64;
} else {
break;
}
}
}
match buf {
Some(vals) => {
let mut i = 0;
while vals.next() {
if i < num {
if optype == 1 {
let result = digest(Algorithm::MD5, vals.read());
aggr += result[0] as u64;
}
if optype == 2 {
let result = digest(Algorithm::SHA1, vals.read());
aggr += result[0] as u64;
}
if optype == 3 {
let result = digest(Algorithm::SHA256, vals.read());
aggr += result[0] as u64;
}
if optype == 4 {
let result = digest(Algorithm::SHA512, vals.read());
aggr += result[0] as u64;
}
} else {
break;
}

None => {
err = INVALIDKEY;
db.resp(pack(&err));
return 0;
}
yield 0;
}
}

None => {
err = INVALIDKEY;
db.resp(pack(&err));
return 0;
}
}
yield 0;

err = SUCCESSFUL;
// First write in the response code.
Expand Down
83 changes: 83 additions & 0 deletions scripts/run-checksum
@@ -0,0 +1,83 @@
#!/bin/bash
#
# Copyright (c) 2019 University of Utah
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR(S) DISCLAIM ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL AUTHORS BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

# Export DPDK bindings to the current shell.
export LD_LIBRARY_PATH=$(pwd)/net/target/native

cd splinter

# Check for a TOML file with client related configuration.
if [[ ! -f client.toml ]]; then
echo "Missing client.toml file (in splinter directory)."
exit -1
fi

# If a command line argument was provided, use it as a request rate for PUSHBACK.
if [ $# -eq 2 ]
then
# The number of records per operation.
sed -i "s/num_aggr = [1-9][0-9]*/num_aggr = $1/g" client.toml

# The amount of compute per operation.
sed -i "s/order = [0-9][0-9]*/order = $2/g" client.toml


# Remove any preexisting temp files.
rm -f ../samples.temp

# Run PUSHBACK.
RUST_LOG=debug ./target/release/checksum 2>&1 | tee -a ../samples.temp

# Calculate the total throughput.
thrpt=$(cat ../samples.temp | grep "Client Throughput" | \
awk 'BEGIN { sum = 0 } { sum += $3 } END { print sum }')
abort=$(cat ../samples.temp | grep "Client Aborted" | \
awk 'BEGIN { sum = 0 } { sum += $3 } END { print sum }')


# Print out final numbers.
m=$(cat ../samples.temp | grep ">>>" | awk '{ print $2 }')
t=$(cat ../samples.temp | grep ">>>" | awk '{ print $3 }')
echo ""
echo "Median(ns): $m, Tail(ns): $t, Aborted-tp(op/s): $abort"
echo "Median(ns): $m, Tail(ns): $t, Throughput(op/s): $thrpt"

rm -f ../samples.temp

exit 0
fi

# Remove any preexisting temp files.
rm -f ../samples.temp

# Run AUTH.
RUST_LOG=debug ./target/release/checksum >> ../samples.temp

# Calculate the total throughput.
cat ../samples.temp | grep "Client"
thrpt=$(cat ../samples.temp | grep "Client Throughput" | \
awk 'BEGIN { sum = 0 } { sum += $3 } END { print sum }')
abort=$(cat ../samples.temp | grep "Client Aborted" | \
awk 'BEGIN { sum = 0 } { sum += $3 } END { print sum }')


# Print out final numbers.
m=$(cat ../samples.temp | grep ">>>" | awk '{ print $2 }')
t=$(cat ../samples.temp | grep ">>>" | awk '{ print $3 }')
echo ""
echo "Median(ns): $m, Tail(ns): $t, Aborted-tp(op/s): $abort"
echo "Median(ns): $m, Tail(ns): $t, Throughput(op/s): $thrpt"
rm -f ../samples.temp
4 changes: 3 additions & 1 deletion scripts/setup.py
Expand Up @@ -48,7 +48,9 @@ def setupCargo():
"cargo update -p getopts --precise 0.2.19; " + \
"cargo update -p unicode-width --precise 0.1.5; " +\
"cargo update -p proc-macro2 --precise 0.4.30; " + \
"cargo update -p cc --precise 1.0.40; "
"cargo update -p cc --precise 1.0.40; " + \
"cargo update -p pkg-config --precise 0.3.15; "


ext_fix = "cargo generate-lockfile; " + \
"cargo update -p spin --precise 0.4.7; " + \
Expand Down
8 changes: 7 additions & 1 deletion splinter/Cargo.toml
Expand Up @@ -56,8 +56,13 @@ path = "src/bin/client/client.rs"
name = "ycsb-t"
path = "src/bin/client/ycsb-t.rs"

[[bin]]
name = "checksum"
path = "src/bin/client/checksum.rs"

[dependencies]
bincode = "1.0"
crypto-hash = "0.3.4"
rust-crypto = "0.2.36"
libc = "0.2.43"
nix = "0.11.0"
Expand All @@ -81,6 +86,7 @@ util = {path = "../util"}
# Add feature name in default features to enable cyclecounter for the given stage,
# where stage name can be ["execution"].
[features]
default = ["ml-model"]
default = ["ml-model", "checksum"]
execution = []
ml-model = []
checksum = []

0 comments on commit 01f9212

Please sign in to comment.