-
Notifications
You must be signed in to change notification settings - Fork 10
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
bench: add simple benchmark #253
Conversation
@metarhia/jstp-core After playing around with it for a bit I found out that our server doesn't handle highload at all and just drops with OOM, maybe should we file an issue and think for some kinds of measures against this? |
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.
@nechaido Also a few things:
- it tests only ipc, but I think it's better to add 'socket' as first parameter to allow to specify either file or port number (it seems to be relatively easy)
- if it will be possible to specify the file for ipc it should only be a name (file will always be in '/tmp/' folder) and we should also check if file not already exist to not overwrite any user data.
- the bench doesn't seem to end is the server has failed, this should probably be fixed
- the client also failed with the (after connection failure it was not removed from the pool, hence we've got 'undefined whatever' errors)
@lundibundi, it is impossible to overwrite user's data by listening on a socket which is an existing file, |
@belochub Ok, removed that point, it's not necessary to find ways to remove the file if server crashed with OOM, although SIGINT should probably be handled. |
@lundibundi added error and |
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.
So what about allowing to specify either filename or port to be able to test both ipc and net?
benchmark/run.js
Outdated
} | ||
|
||
function terminate() { | ||
console.log(` |
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.
As I see those line-breaks were intentional, but maybe it's better to just use '\n'?
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.
@lundibundi, how is that better?
As I see this, both of this options are completely equal, meaning that it is just a style preference, and we don't have a linter rule for this case, thus it is okay to leave it this way.
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.
Yep, I didn't insist on making it that way.
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.
@lundibundi
IMHO
console.log(`
Benchmark is being terminated due to an error or signal termination
`);
looks better then:
console.log(
'\nBenchmark is being terminated due to an error or signal termination\n'
);
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.
This one is even better in my opinion:
const message =
'\nBenchmark is being terminated due to an error or signal termination\n';
console.log(message);
IMHO
benchmark/worker
Outdated
@@ -0,0 +1,95 @@ | |||
'use strict'; |
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 .js
in filename.
I don't like the idea, because it will only show, potential performance of JSTP over TCP. If we decide to allow user specify transport - we should allow to choose any transport. I'd like to leave this PR this way, and add such a feature in future. |
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. I guess we should still add functionality to bench different transports in the follow up PRs.
benchmark/run.js
Outdated
setTimeout(() => { | ||
if (!serverExited) { | ||
server.kill('SIGKILL'); | ||
console.log('Master processwas not able to close server gracefully'); |
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.
Missing a space here.
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 modulo comments.
benchmark/run.js
Outdated
size: argumentSize, | ||
} = args; | ||
|
||
|
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.
Nit: extra line break.
const workers = new Array(workersAmount); | ||
const workersExited = new Array(workersAmount); | ||
|
||
const results = new Array(workersAmount); |
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 don't care much, but it feels like this line and the previous one should have been swapped.
benchmark/server.js
Outdated
const server = jstp.net.createServer([app]); | ||
server.maxConnections = maxConnections; | ||
|
||
const socket = '/tmp/jstp_benchmark_ipc'; |
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.
This won't work on Windows at all (where named pipes are created inside a special namespace in the VFS), and maybe on some Unix flavors too (it isn't correct to rely on /tmp/
being available, that's what os.tmpdir()
is for). I am okay with landing this as is now, because the benchmark is not exposed to end users, but it should be fixed later. Aside from that, a hardcoded filename is prone to race conditions.
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.
@aqrln, what kind of race conditions?
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.
consider multiple benchmarks run simultaneously
benchmark/worker.js
Outdated
function connect(socket) { | ||
let connected = 0; | ||
const createConnection = (index) => { | ||
jstp.net.connectAndInspect('app', null, ['iface'], socket, |
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.
Nit: I'd put the arguments on a new line.
benchmark/worker.js
Outdated
for (let i = 0; i < connections.length; i++) { | ||
createConnection(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.
Nit: unnecessary empty line.
benchmark/worker.js
Outdated
responseTimesHR[i] = new Array(requests); | ||
} | ||
let responses = 0; | ||
let startTimeHR = new Array(2); |
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.
Can you please remove = new Array(2)
(or assign the variable a null value)?
@belochub ping. |
benchmark/run.js
Outdated
if (!serverExited) { | ||
server.kill('SIGKILL'); | ||
console.log('Master process was not able to close server gracefully'); | ||
fs.unlinkSync('/tmp/jstp_benchmark_ipc'); |
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.
You forgot to change the path here.
benchmark/run.js
Outdated
let workersConnected = 0; | ||
let workersFinished = 0; | ||
|
||
let becnhStartedHR; |
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.
Typo in word "bench" here.
benchmark/run.js
Outdated
setTimeout(() => { | ||
if (!serverExited) { | ||
server.kill('SIGKILL'); | ||
console.log('Master process was not able to close server gracefully'); |
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.
It'll be better to replace console.log
with console.warn
here.
PR-URL: #253 Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> Reviewed-By: Mykola Bilochub <nbelochub@gmail.com>
Landed in 5bf3944. |
PR-URL: #253 Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> Reviewed-By: Mykola Bilochub <nbelochub@gmail.com>
PR-URL: #253 Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> Reviewed-By: Mykola Bilochub <nbelochub@gmail.com>
No description provided.