cacti icon indicating copy to clipboard operation
cacti copied to clipboard

feat(connector-besu): add continuous benchmarking with JMeter

Open ruzell22 opened this issue 1 year ago • 7 comments

Commit to be reviewed


feat(connector-besu): add continuous benchmarking with JMeter

Primary Changes
---------------

1. Added continuous benchmarking using JMeter that reports performance in cactus-plugin-ledger-connector-besu using one of its endpoint.

fixes: #2672

Pull Request Requirements

  • [x] Rebased onto upstream/main branch and squashed into single commit to help maintainers review it more efficient and to avoid spaghetti git commit graphs that obfuscate which commit did exactly what change, when and, why.
  • [x] Have git sign off at the end of commit message to avoid being marked red. You can add -s flag when using git commit command. You may refer to this link for more information.
  • [x] Follow the Commit Linting specification. You may refer to this link for more information.

Character Limit

  • [x] Pull Request Title and Commit Subject must not exceed 72 characters (including spaces and special characters).
  • [x] Commit Message per line must not exceed 80 characters (including spaces and special characters).

A Must Read for Beginners For rebasing and squashing, here's a must read guide for beginners.

ruzell22 avatar Mar 08 '24 08:03 ruzell22

In addition, the yarn run configure is running successfully image

and running yarn run benchmark inside the ./packages/cactus-plugin-ledger-connector-besu gives a successful run of the performance benchmarking tested locally image

ruzell22 avatar Mar 08 '24 08:03 ruzell22

Hello @outSH @petermetz , I have done the requested changes and have tested the yarn run benchmark with the latest clone of repository and it is working as expected. image

ruzell22 avatar Mar 31 '24 14:03 ruzell22

Hello @outSH , with regards to the try - catch finally block, there is a code where it will run on complete or error which is similar to try-catch block before shutting down the apiServer. .on("complete", function () { log.info("%s Benchmark.js COMPLETE.", LOG_TAG); resolve(suite); }) .on("error", async (ex: unknown) => { log.info("%s Benchmark.js ERROR: %o", LOG_TAG, ex); reject(ex); })

Do I still need to put it into try-catch block and put the shutdown in finally segment? Thank you.

As for the other requested changes, they are all resolved with the latest push I have.

ruzell22 avatar Apr 08 '24 07:04 ruzell22

@ruzell22 catch and finally are Promise alternaives of try-catch block so you can use it, but in your case it doesn't clean up allocated resources. Please have a look at code that peter has perepered where he uses catch and finally callbacks on promise returned from main to stop apiServer and test ledger, that's the cleanup we need :)

outSH avatar Apr 08 '24 09:04 outSH

@outSH on my latest push, I have implemented the try and finally with cleanup to stop and destroy besuTestLedger. I have also tested the performance benchmarking locally and no containers are left running and the stopped containers were also destroyed/pruned.

ruzell22 avatar Apr 08 '24 09:04 ruzell22

@ruzell22 Right now you're stopping the ledger right after createTestInfrastructure is done (i.e. before the benchmark is run). This works fine because your test doesn't use the ledger (it calls only getOpenApiSpecV1) so this whole ledger setup could be removed. My assumption was that this script will be extended in the future, and when the test is to use the ledger at some point then the ledger must be running during the test, and clean up at the very end (once again, check out the sample code provided by peter where he cleans it up in main. So:

  • If you plan on extending this script in the future, please keep the ledger running and clean it up at the very end in finally callback / block (so that it is stopped even in case of error).
  • If you don't plan on extending this any further, please remove unnecessary code in setup, like starting the ledger, creating the keychain plugin etc.., that will solve most of the problems.
  • Put the await apiServer.shutdown(); in a finally block so that it's called in case of error. Random error can be thrown by any method between server start and the shutdown (like filesystem errors onwriteFile or mkdirp, or errors originating from benchmark suite itself. If we don't handle it, the exception will skipp the shutdown code and we'll have a resource leak.

outSH avatar Apr 09 '24 08:04 outSH

@outSH I have made a new push wherein the await apiServer.shutdown(); , await besuTestLedger.stop(); and await besuTestLedger.destroy(); are in a finally block at the end of main. I have tested running yarn run benchmark as well to see if the ledger is running during the test and is only stopped and destroyed after and that is what's happening with the new push.

I also tried putting it at the end after the .then .catch like Peter did, however, the ledger isn't being stopped nor destroyed that's why I tried to put it at the end of the main instead, together with the apiServer.shutdown.

ruzell22 avatar Apr 10 '24 06:04 ruzell22