Skip to content

Instantly share code, notes, and snippets.

@denisshevchenko
Last active March 7, 2018 11:21
Show Gist options
  • Save denisshevchenko/f4893539c70eda0e0f310f8066990aa3 to your computer and use it in GitHub Desktop.
Save denisshevchenko/f4893539c70eda0e0f310f8066990aa3 to your computer and use it in GitHub Desktop.

Steps to prepare concurrent benchmarking

  1. $ cd cardano-sl
  2. Go to branch with dbgen: $ git checkout master
  3. Build: $ ./scripts/build/cardano-sl.sh
  4. Clean wallet database: $ ./scripts/clean/db.sh
  5. Launch dev cluster: $ ./scripts/launch/demo-with-wallet-api.sh
  6. Copy value from System start, for example, 1518114979000000, from any tmux window. It will be used in next steps.
  7. Generate keys: $ stack exec -- cardano-keygen --system-start 1518114979000000 generate-keys-by-spec --genesis-out-dir tmp-secrets
  8. Get your first money: $ curl -X POST --insecure https://localhost:8090/api/wallets/keys -H 'cache-control: no-cache' -H 'content-type: application/json' -d '"/home/denis/Code/cardano-sl/tmp-secrets/generated-keys/poor/key0.sk"'. You should see something like this:
    {"Right":{"cwId":"Ae2tdPwUPEZEK5DvxPMtnTnUfQg8coWAAbNfLEvQ4GqWTe9h8d6AEkBDMce","cwMeta":{"cwName":"Genesis wallet","cwAssurance":"CWANormal","cwUnit":0},"cwAccountsNumber":1,"cwAmount":{"getCCoin":"37499999999166"},"cwHasPassphrase":false,"cwPassphraseLU":1.518106557627431431e9}}
    
    As you can see, we have a wallet, and getCCoin isn't empty.
  9. Please keep wallet id, we'll use it later.
  10. Check an account in your new wallet: $ curl -k https://localhost:8090/api/accounts. You should see something like this:
    {"Right":[{"caId":"Ae2tdPwUPEZEK5DvxPMtnTnUfQg8coWAAbNfLEvQ4GqWTe9h8d6AEkBDMce@2147483648","caMeta":{"caName":"Genesis account"},"caAddresses":[{"cadId":"DdzFFzCqrhsg9ngNRhHEa49se7qEMKyubT9tcE13Fkvh8QC82trpTDsNvdQV7mg9SCZiuENkf77zrtwPXrTyGMNznUsSinPC1gb2ZCqK","cadAmount":{"getCCoin":"37499999999166"},"cadIsUsed":false,"cadIsChange":false}],"caAmount":{"getCCoin":"37499999999166"}}]}
    
  11. Copy account id, we'll use it later.
  12. Open tools/src/dbgen/config.json and paste:
    {
    "wallets":1,
    "walletSpec":{
      "accounts":1,
      "accountSpec":{"addresses":100},
      "fakeUtxoCoinDistr":{"type":"range","range":100,"amount":1},
      "fakeTxsHistory":{"type":"simple","txsCount":100,"numOutgoingAddress":3}
      }
    }
    
    So, we want 100 addresses and 100 transactions. Change these values if you need.
  13. Stop the cluster and create addresses and transactions: $ stack exec dbgen -- --add-to Ae2tdPwUPEZEK5DvxPMtnTnUfQg8coWAAbNfLEvQ4GqWTe9h8d6AEkBDMce@2147483648 --config ./tools/src/dbgen/config.json --nodeDB run/node-db3 --secretKey node-3.secret.key --configProf dev --walletDB wallet-db --configPath node/configuration.yaml --systemStart 1518077932000000
  14. Wait for a while. ;-)
  15. Revert: $ git checkout -- tools/src/dbgen/config.json
  16. Go to wallet bench branch: $ git checkout feature/CBR-23-wallet-bench
  17. Build again: $ ./scripts/build/cardano-sl.sh
  18. Wait for a while. ;-)
  19. Check it again: $ curl -k https://localhost:8090/api/wallets. You should see something like this:
    {"Right":[{"cwId":"Ae2tdPwUPEYxziM5uuHFok9fjeADJX7mf1kwuERMHmDcr5C1vipvvDjwEL1","cwMeta":{"cwName":"Wallet #1","cwAssurance":"CWANormal","cwUnit":0},"cwAccountsNumber":2,"cwAmount":{"getCCoin":"100000000000"},"cwHasPassphrase":false,"cwPassphraseLU":1.518078888483675628e9}]}
    
  20. Get some addresses: $ curl -k https://localhost:8090/api/accounts. You will see a lot of addresses, copy few of them.
  21. Open wallets config wallet/bench/config/Wallets.yaml and paste here wallet id, account id and addresses.
    • wallet id - from step 19,
    • account id - from step 10,
    • addresses (at least one) - from step 20.
  22. Open endpoints config wallet/bench/config/Endpoints.csv and specify benchmarks for particular endpoints. For example, based on CSL-2249:
    BenchName,NumberOfMeasures,MinDelayBetweenCalls,MaxDelayBetweenCalls,PathToReportFile,PathToResponseReportsFile
    NewPaymentBench,10,0.0,0.0,/home/denis/Code/cardano-sl/wallet/bench/results/NewPaymentBenchReport.csv,/home/denis/Code/cardano-sl/wallet/bench/results/NewPaymentResponseReports.txt
    GetWalletsBench,10,55.0,59.0,/home/denis/Code/cardano-sl/wallet/bench/results/GetWalletsBenchReport.csv,/home/denis/Code/cardano-sl/wallet/bench/results/GetWalletsResponseReports.txt
    GetHistoryBench,10,0.0,0.0,/home/denis/Code/cardano-sl/wallet/bench/results/GetHistoryBenchReport.csv,/home/denis/Code/cardano-sl/wallet/bench/results/GetHistoryResponseReports.txt
    
    Specify full paths to reports that are actual for your system.
  23. Launch benchmarking: $ stack bench cardano-sl-wallet-new --benchmark-arguments "--tls-pub-cert=$PWD/scripts/tls-files/ca.crt --tls-priv-key=$PWD/scripts/tls-files/server.key --wal-conf=$PWD/wallet-new/bench/config/Wallets.yaml --ep-conf=$PWD/wallet-new/bench/config/Endpoints.csv --analyze --async"
  24. Wait for a while again. ;-)
  25. After Benchmark cardano-sl-wallet-bench: RUNNING..., see responses from the wallet in:
    • wallet/bench/results/NewPaymentResponseReports.txt
    • wallet/bench/results/GetWalletsResponseReports.txt
    • wallet/bench/results/GetHistoryResponseReports.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment