load_config() {
    source "$EXP_ROOT/configs/memcached.sh"
    source "$EXP_ROOT/configs/mutilate.sh"
}

cleanup_mutilate() {
    echo "Killing all mutilate processes on clients"
    sudo -u $SSH_USER pdsh -R ssh -w $MEMCLIENTS pkill mutilate || true
}

cleanup_memcached() {
    echo "Killing memcached process"
    kill $MEMCACHED_PID
}

start_memcached() {
    echo "Starting memcached"
    taskset -c 0-$THREADS $MEMCACHED -u root -t $THREADS -b 16384 -c 32768 -m 10240 -o hashpower=24,no_lru_maintainer,no_lru_crawler $@ 2>&1 > /dev/null &
    MEMCACHED_PID=$!
}

start_mutilate() {
    echo "Starting mutilate"
    # Mutilate client agents always run on 8 cores
    sudo -u $SSH_USER pdsh -R ssh -w $MEMCLIENTS taskset -c 0-7 mutilate -A -T 8 2>/dev/null & sleep 1
}

warmup() {
    echo "Warming up Memcached..."
    sudo -u $SSH_USER $MUTILATE --noload -c100 $MUTCLIENTS -t30 -u 0
}

run_mutilate() {
    echo "Running mutilate with $CONNS connections per agent (core) and QPS = $QPS"
    sudo -u $SSH_USER $MUTILATE --noload -c$CONNS $MUTCLIENTS -t30 -u 0 -q $QPS | tee $DATA_OUT/$1.txt
}
