Skip to content

Commit

Permalink
feat: fix metrics capture CI job
Browse files Browse the repository at this point in the history
Make sure cargo is installed on remote machine.
Automatically add remote ssh key to known hosts.
Replace remaining election post references with window

feat: enable proof validate by default on merkleproof bench

While proofs_count is CLI configurable, if it's more than the number
of nodes in the tree, just sequentially challenge each node in the
tree instead of randomly selecting and over-proving.
  • Loading branch information
cryptonemo committed Jul 22, 2020
1 parent 0ffa7d8 commit 450ec25
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ jobs:
steps:
- add_ssh_keys:
fingerprints:
- "f8:db:3c:6d:f9:74:2c:9e:07:42:3f:3f:23:07:f7:6d"
- "96:12:32:00:d7:ef:4e:ff:ae:1e:04:e2:5f:ce:23:bd"
- run:
name: Add benchmark server's public key to known hosts
command: |
Expand All @@ -159,6 +159,7 @@ jobs:
echo "
${BENCHMARK_SERVER_RSA_FINGERPRINT}
" >> ~/.ssh/known_hosts
ssh-keyscan -H 147.75.55.201 >> ~/.ssh/known_hosts
fi
- checkout
- attach_workspace:
Expand Down
6 changes: 3 additions & 3 deletions fil-proofs-tooling/scripts/aggregate-benchmarks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ set -e
stacked_path=$1
micro_path=$2
hash_constraints_path=$3
election_post_path=$4
window_post_path=$4

jq --sort-keys -s '{ benchmarks: { "stacked-benchmarks": { outputs: { "max-resident-set-size-kb": .[0] } } } } * .[1]' \
<(jq '.["max-resident-set-size-kb"]' $stacked_path) \
<(jq -s '.[0] * { benchmarks: { "hash-constraints": .[1], "stacked-benchmarks": .[2], "micro-benchmarks": .[3], "election-post-benchmarks": .[4] } }' \
<(jq -s '.[0] * { benchmarks: { "hash-constraints": .[1], "stacked-benchmarks": .[2], "micro-benchmarks": .[3], "window-post-benchmarks": .[4] } }' \
<(jq 'del (.benchmarks)' $micro_path) \
<(jq '.benchmarks' $hash_constraints_path) \
<(jq '.benchmarks' $stacked_path) \
<(jq '.benchmarks' $micro_path) \
<(jq '.benchmarks' $election_post_path))
<(jq '.benchmarks' $window_post_path))
7 changes: 2 additions & 5 deletions fil-proofs-tooling/scripts/run-remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,13 @@ find /tmp/metrics/ -maxdepth 1 -mindepth 1 -type d -printf "%f\n" \
| xargs -I {} bash -c 'if (({} < \$(date +%s))) ; then rm -rf /tmp/metrics/{} ; fi' 2> /dev/null
# Make sure rust is installed on the remote host.
curl https://sh.rustup.rs -sSf | sh -s -- -y
source $HOME/.cargo/env
curl https://sh.rustup.rs -sSf | sh -s -- -y > /dev/null 2>&1
source $HOME/.cargo/env /dev/null 2>&1
git clone -b $1 --single-branch https://github.com/filecoin-project/rust-fil-proofs.git \$_metrics_dir || true
cd \$_metrics_dir
cargo update
cargo fetch
./fil-proofs-tooling/scripts/retry.sh 42 10 60000 \
./fil-proofs-tooling/scripts/with-lock.sh 42 /tmp/metrics.lock \
./fil-proofs-tooling/scripts/with-dots.sh \
Expand Down
2 changes: 1 addition & 1 deletion fil-proofs-tooling/src/bin/benchy/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ fn main() -> Result<()> {
Arg::with_name("validate")
.long("validate")
.required(false)
.default_value("false")
.default_value("true")
.help("Validate proofs if specified")
.takes_value(false),
);
Expand Down
18 changes: 16 additions & 2 deletions fil-proofs-tooling/src/bin/benchy/merkleproofs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,32 @@ fn generate_proofs<R: Rng, Tree: MerkleTreeTrait>(
proofs_count: usize,
validate: bool,
) -> Result<()> {
let proofs_count = if proofs_count >= nodes {
info!(
"requested {} proofs, but instead challenging all {} nodes sequentially",
proofs_count, nodes
);

nodes
} else {
proofs_count
};

info!(
"creating {} inclusion proofs over {} nodes (validate enabled? {})",
proofs_count, nodes, validate
);

let proofs_count = std::cmp::min(nodes, proofs_count);
let rows_to_discard = default_rows_to_discard(
base_tree_nodes,
<Tree as MerkleTreeTrait>::Arity::to_usize(),
);
for i in 0..proofs_count {
let challenge = rng.gen_range(0, nodes);
let challenge = if proofs_count == nodes {
i
} else {
rng.gen_range(0, nodes)
};
debug!("challenge[{}] = {}", i, challenge);
let proof = tree
.gen_cached_proof(challenge, Some(rows_to_discard))
Expand Down

0 comments on commit 450ec25

Please # to comment.