-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SmallBank benchmark implementation #45
Conversation
074d589
to
c0d5772
Compare
@feeblefakie @jnmt I copied related contracts from the caliper project, and also have a default Please kindly advise. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looking good. Thank you!
Let me start off with some questions.
benchmark/smallbank-bench
Outdated
const [ | ||
properties, | ||
numberOfAccount, | ||
numberOfThread, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand this is named for consistency, but I think it should be renamed to concurrency
or something since Javascript is single-threaded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I forgot, maybe adding a readme that details the execution order of the 3 programs would be helpful.
Thank you.
Will do.
benchmark/smallbank-bench
Outdated
|
||
const start = Date.now(); | ||
let from = start; | ||
for (let i = 0; i < numberOfThread; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it using a single CPU core, right?
Java bench is using multiple cores using threads, so I'm wondering how we can compare them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the async functions (the one that executes contracts) can leverage multiple CPU cores because they are non-blocking functions.
I am not exactly sure the details though.
Let me check this.
There is another way.
Node.js provides a concurrent practice called worker thread.
(It seems to me like a child process in runtime)
This for sure is leveraging multiple CPU cores.
If the async function
practice doesn't really use multiple CPU cores,
then I will try to use worker thread to do it.
@supl Are we supposed to be able to run it just by running
|
I ran into the same issue. I think you need to run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ! Thank you
I just left a minor comment.
I tested locally both with the auditor enabled and disabled and did not run into problem 🙂
benchmark/smallbank-bench
Outdated
console.log( | ||
'\t--properties PROPERTIES_FILE, --config PROPERTIES_FILE\n' + | ||
'\t\tA configuration file in properties format.\n' + | ||
'\t--num-accounts NUM_ACCOUNTS\n' + | ||
'\t\tThe number of target accounts.\n' + | ||
'\t--num-threads NUM_THREADS\n' + | ||
'\t\tThe number of threads to run.\n' + | ||
'\t--duration DURATION\n' + | ||
'\t\tThe duration of benchmark in seconds\n' + | ||
'\t--ramp-up-time RAMP_UP_TIME\n' + | ||
'\t\tThe ramp up time in seconds.\n' + | ||
'\t--operation OPERATION\n' + | ||
'\t\ttransact_savings, ' + | ||
'deposit_checking, send_payment, write_check, amalgamate', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the default value for each parameter be mentioned in the usage ?
benchmark/smallbank-loader
Outdated
function usage() { | ||
const path = require('path'); | ||
console.log( | ||
'Usage: ' + | ||
`${path.basename(process.argv[1])} ` + | ||
'[--properties PROPERTIES_FILE, --config PROPERTIES_FILE] ' + | ||
'[--num-accounts NUM_ACCOUNTS] ' + | ||
'[--num-threads NUM_THREADS] ' + | ||
'[-h, --help]', | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. Should the default value for each parameter be mentioned in the usage ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I forgot, maybe adding a readme that details the execution order of the 3 programs would be helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looking good. Nice work! I was able to run the benchmark. Just a single comment on the discussion here (#45 (comment)).
JS async function does not run with multiple threads/CPUs. In the case of Caliper, child_process is used. Just for your information. Thanks.
https://github.com/scalar-labs/caliper/blob/ee6f3f2c5d69ad944ca753b6d5bb567849731285/packages/caliper-core/lib/master/orchestrators/worker-orchestrator.js#L548
@jnmt @feeblefakie Please review again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Multi processes work well. It might not be a high priority but it would be happy if we could run loader with multi cores as well. Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Left one suggestion. PTAL when you get a chance.
benchmark/smallbank-bench
Outdated
} | ||
break; | ||
|
||
case '--num-processes': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, we should have discussed the way to do it.
I think just using multiple processes is too efficient since a process is heavy so I think we should mix processes and threads (asynchronous multi-tasking) to make it comparable to the Java version.
One way to do this is that we let users specify concurrency
and make the tool automatically divide the concurrency into multiple processes and "threads".
For example, if 16 concurrency is given on 4-core machine, we can create 4 processes to match with the number cores and create 4 "threads" for each process.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see.
I didn't think about that.
So, a sub-process will be in charge of a few concurrencies.
Unfortunately, we couldn't use worker_threads to implement it otherwise it might be more similar to Java's implementation.
I will revise smallbank-bench and smallbank-loader (according to Jun's feedback) by this idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I know we don't have threads. I meant multitasking with async.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, we should have discussed the way to do it.
I think just using multiple processes is too efficient since a process is heavy so I think we should mix processes and threads (asynchronous multi-tasking) to make it comparable to the Java version.
One way to do this is that we let users specify
concurrency
and make the tool automatically divide the concurrency into multiple processes and "threads".
For example, if 16 concurrency is given on 4-core machine, we can create 4 processes to match with the number cores and create 4 "threads" for each process.What do you think?
@feeblefakie
I revised the implementation of smallbank-bench.
First, I rename the option name back to --num-concurrencies
.
smallbank-bench now divides the requested concurrencies by the number of CPU,
then it forks subprocesses as the same number as CPU.
Each forked subprocess uses async functions with the number of divided concurrencies to run the benchmark.
I also revised smallbank-loader with the child_process
mechanism.
I didn't use fork + async
way for smallbank-loader because I think it doesn't matter that smallbank-loader does works too efficiently, so I used an easier way to revise it.
@jnmt
Jun, thank you for your advice.
I used child_process
to revise smallbank-loader.
Now it can do jobs more efficiently too.
@supl I've played around with it but am facing some issues.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
I left a suggestion.
I'm also facing some issues running it yet.
} | ||
break; | ||
|
||
case '--ramp-up-time': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I specified 0
for this, it still triggers the help. 0
is useful for testing, so it would be great if it is fixed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem.
``` | ||
|
||
``` | ||
./smallbank-bench -h |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, it would be great if the help is shown when nothing is specified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem.
This must be an issue related to the working directory. Thank you for your testing :) |
@feeblefakie |
@supl Thank you for the guidance! I'll share the preliminary benchmarking results in my local environment (that has 4 CPU cores).
Java SDK (1st time):
Java SDK (2nd time):
Node SDK (1st time):
Node SDK (2nd time):
My local environment runs many other processes so it's not a good place for benchmark but |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Nice work! Thank you!
I think we can further work on the following things in another PR:
- Support optional configurations that are consistent with the Java version
- Support PEM files (for only node version)
- Update documentation to specify version requirements
This PR implements the
smallbank
applications as benchmark tools.