Skip to content
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

Closed
wants to merge 1 commit into from
Closed

bench: add simple benchmark #253

wants to merge 1 commit into from

Conversation

nechaido
Copy link
Member

No description provided.

@lundibundi
Copy link
Member

@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?

Copy link
Member

@lundibundi lundibundi left a 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 attached error (after connection failure it was not removed from the pool, hence we've got 'undefined whatever' errors)

@belochub
Copy link
Member

@lundibundi, it is impossible to overwrite user's data by listening on a socket which is an existing file, listen just won't permit the creation of the socket in that case.
Also, benchmark always removes socket file if it finishes correctly, and there is no way you can remove the file after crashing with OOM error, so it does not solve this problem. We can probably add a listener removing the file to SIGINT event, it will help in cases when the benchmark is stopped manually.

@lundibundi
Copy link
Member

@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.

@nechaido
Copy link
Member Author

@lundibundi added error and SIGINT handling.
Could not connect to the server: Error: connect EAGAIN /tmp/jstp_benchmark_ipc is a jstp error, which will be fixed by @belochub.
As for now - do not open to many connections per a client, 10 seems to be ok.

@lundibundi
Copy link
Member

Adding OOM error screenshots just for reference.

  • For ipc connectinon:
    deepinscreenshot_20170719172807
  • For net socket:
    deepinscreenshot_select-area_20170719172307

Copy link
Member

@lundibundi lundibundi left a 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(`
Copy link
Member

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'?

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member Author

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'
);

Copy link
Member

@lundibundi lundibundi Jul 20, 2017

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';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No .js in filename.

@nechaido
Copy link
Member Author

nechaido commented Jul 20, 2017

@lundibundi

So what about allowing to specify either filename or port to be able to test both ipc and net?

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.

@nechaido
Copy link
Member Author

nechaido commented Jul 20, 2017

@belochub @aqrln ping.

Copy link
Member

@lundibundi lundibundi left a 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');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a space here.

@nechaido
Copy link
Member Author

@belochub @aqrln ping.

Copy link
Member

@aqrln aqrln left a 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;


Copy link
Member

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);
Copy link
Member

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.

const server = jstp.net.createServer([app]);
server.maxConnections = maxConnections;

const socket = '/tmp/jstp_benchmark_ipc';
Copy link
Member

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.

Copy link
Member

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?

Copy link
Member

@aqrln aqrln Jul 27, 2017

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

function connect(socket) {
let connected = 0;
const createConnection = (index) => {
jstp.net.connectAndInspect('app', null, ['iface'], socket,
Copy link
Member

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.

for (let i = 0; i < connections.length; i++) {
createConnection(i);
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: unnecessary empty line.

responseTimesHR[i] = new Array(requests);
}
let responses = 0;
let startTimeHR = new Array(2);
Copy link
Member

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)?

@nechaido
Copy link
Member Author

@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');
Copy link
Member

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;
Copy link
Member

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');
Copy link
Member

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.

belochub pushed a commit that referenced this pull request Jul 29, 2017
PR-URL: #253
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
Reviewed-By: Mykola Bilochub <nbelochub@gmail.com>
@belochub
Copy link
Member

Landed in 5bf3944.

@belochub belochub closed this Jul 29, 2017
@belochub belochub deleted the benchmark branch July 29, 2017 15:42
belochub pushed a commit that referenced this pull request Jan 22, 2018
PR-URL: #253
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
Reviewed-By: Mykola Bilochub <nbelochub@gmail.com>
belochub pushed a commit that referenced this pull request Jan 22, 2018
PR-URL: #253
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
Reviewed-By: Mykola Bilochub <nbelochub@gmail.com>
@belochub belochub mentioned this pull request Jan 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants