aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/node/performance
diff options
context:
space:
mode:
Diffstat (limited to 'src/node/performance')
-rw-r--r--src/node/performance/benchmark_client.js16
-rw-r--r--src/node/performance/benchmark_client_express.js35
-rw-r--r--src/node/performance/benchmark_server.js25
-rw-r--r--src/node/performance/benchmark_server_express.js12
-rw-r--r--src/node/performance/generic_service.js11
-rw-r--r--src/node/performance/worker.js4
-rw-r--r--src/node/performance/worker_service_impl.js23
7 files changed, 96 insertions, 30 deletions
diff --git a/src/node/performance/benchmark_client.js b/src/node/performance/benchmark_client.js
index 5ef5260a96..e7c426b2ff 100644
--- a/src/node/performance/benchmark_client.js
+++ b/src/node/performance/benchmark_client.js
@@ -88,7 +88,10 @@ function timeDiffToNanos(time_diff) {
*/
function BenchmarkClient(server_targets, channels, histogram_params,
security_params) {
- var options = {};
+ var options = {
+ "grpc.max_receive_message_length": -1,
+ "grpc.max_send_message_length": -1
+ };
var creds;
if (security_params) {
var ca_path;
@@ -180,6 +183,8 @@ BenchmarkClient.prototype.startClosedLoop = function(
self.last_wall_time = process.hrtime();
+ self.last_usage = process.cpuUsage();
+
var makeCall;
var argument;
@@ -270,6 +275,8 @@ BenchmarkClient.prototype.startPoisson = function(
self.last_wall_time = process.hrtime();
+ self.last_usage = process.cpuUsage();
+
var makeCall;
var argument;
@@ -354,9 +361,11 @@ BenchmarkClient.prototype.startPoisson = function(
*/
BenchmarkClient.prototype.mark = function(reset) {
var wall_time_diff = process.hrtime(this.last_wall_time);
+ var usage_diff = process.cpuUsage(this.last_usage);
var histogram = this.histogram;
if (reset) {
this.last_wall_time = process.hrtime();
+ this.last_usage = process.cpuUsage();
this.histogram = new Histogram(histogram.resolution,
histogram.max_possible);
}
@@ -371,9 +380,8 @@ BenchmarkClient.prototype.mark = function(reset) {
count: histogram.getCount()
},
time_elapsed: wall_time_diff[0] + wall_time_diff[1] / 1e9,
- // Not sure how to measure these values
- time_user: 0,
- time_system: 0
+ time_user: usage_diff.user / 1000000,
+ time_system: usage_diff.system / 1000000
};
};
diff --git a/src/node/performance/benchmark_client_express.js b/src/node/performance/benchmark_client_express.js
index 675eb5f288..157bf1b6de 100644
--- a/src/node/performance/benchmark_client_express.js
+++ b/src/node/performance/benchmark_client_express.js
@@ -93,9 +93,8 @@ function BenchmarkClient(server_targets, channels, histogram_params,
for (var i = 0; i < channels; i++) {
var host_port;
- host_port = server_targets[i % server_targets.length].split(':')
+ host_port = server_targets[i % server_targets.length].split(':');
var new_options = _.assign({hostname: host_port[0], port: +host_port[1]}, options);
- new_options.agent = new protocol.Agent(new_options);
this.client_options[i] = new_options;
}
@@ -137,6 +136,7 @@ BenchmarkClient.prototype.startClosedLoop = function(
}
self.last_wall_time = process.hrtime();
+ self.last_usage = process.cpuUsage();
var argument = {
response_size: resp_size,
@@ -149,6 +149,17 @@ BenchmarkClient.prototype.startClosedLoop = function(
if (self.running) {
self.pending_calls++;
var start_time = process.hrtime();
+ function finishCall(success) {
+ if (success) {
+ var time_diff = process.hrtime(start_time);
+ self.histogram.add(timeDiffToNanos(time_diff));
+ }
+ makeCall(client_options);
+ self.pending_calls--;
+ if ((!self.running) && self.pending_calls == 0) {
+ self.emit('finished');
+ }
+ }
var req = self.request(client_options, function(res) {
var res_data = '';
res.on('data', function(data) {
@@ -156,18 +167,16 @@ BenchmarkClient.prototype.startClosedLoop = function(
});
res.on('end', function() {
JSON.parse(res_data);
- var time_diff = process.hrtime(start_time);
- self.histogram.add(timeDiffToNanos(time_diff));
- makeCall(client_options);
- self.pending_calls--;
- if ((!self.running) && self.pending_calls == 0) {
- self.emit('finished');
- }
+ finishCall(true);
});
});
req.write(JSON.stringify(argument));
req.end();
req.on('error', function(error) {
+ if (error.code === 'ECONNRESET' || error.code === 'ETIMEDOUT') {
+ finishCall(false);
+ return;
+ }
self.emit('error', new Error('Client error: ' + error.message));
self.running = false;
});
@@ -198,6 +207,7 @@ BenchmarkClient.prototype.startPoisson = function(
}
self.last_wall_time = process.hrtime();
+ self.last_usage = process.cpuUsage();
var argument = {
response_size: resp_size,
@@ -255,9 +265,11 @@ BenchmarkClient.prototype.startPoisson = function(
*/
BenchmarkClient.prototype.mark = function(reset) {
var wall_time_diff = process.hrtime(this.last_wall_time);
+ var usage_diff = process.cpuUsage(this.last_usage);
var histogram = this.histogram;
if (reset) {
this.last_wall_time = process.hrtime();
+ this.last_usage = process.cpuUsage();
this.histogram = new Histogram(histogram.resolution,
histogram.max_possible);
}
@@ -272,9 +284,8 @@ BenchmarkClient.prototype.mark = function(reset) {
count: histogram.getCount()
},
time_elapsed: wall_time_diff[0] + wall_time_diff[1] / 1e9,
- // Not sure how to measure these values
- time_user: 0,
- time_system: 0
+ time_user: usage_diff.user / 1000000,
+ time_system: usage_diff.system / 1000000
};
};
diff --git a/src/node/performance/benchmark_server.js b/src/node/performance/benchmark_server.js
index 6abde2e17a..a4d5ee1c26 100644
--- a/src/node/performance/benchmark_server.js
+++ b/src/node/performance/benchmark_server.js
@@ -88,6 +88,13 @@ function streamingCall(call) {
});
}
+function makeUnaryGenericCall(response_size) {
+ var response = zeroBuffer(response_size);
+ return function unaryGenericCall(call, callback) {
+ callback(null, response);
+ };
+}
+
function makeStreamingGenericCall(response_size) {
var response = zeroBuffer(response_size);
return function streamingGenericCall(call) {
@@ -125,14 +132,20 @@ function BenchmarkServer(host, port, tls, generic, response_size) {
server_creds = grpc.ServerCredentials.createInsecure();
}
- var server = new grpc.Server();
+ var options = {
+ "grpc.max_receive_message_length": -1,
+ "grpc.max_send_message_length": -1
+ };
+
+ var server = new grpc.Server(options);
this.port = server.bind(host + ':' + port, server_creds);
if (generic) {
server.addService(genericService, {
+ unaryCall: makeUnaryGenericCall(response_size),
streamingCall: makeStreamingGenericCall(response_size)
});
} else {
- server.addProtoService(serviceProto.BenchmarkService.service, {
+ server.addService(serviceProto.BenchmarkService.service, {
unaryCall: unaryCall,
streamingCall: streamingCall
});
@@ -148,6 +161,7 @@ util.inherits(BenchmarkServer, EventEmitter);
BenchmarkServer.prototype.start = function() {
this.server.start();
this.last_wall_time = process.hrtime();
+ this.last_usage = process.cpuUsage();
this.emit('started');
};
@@ -167,14 +181,15 @@ BenchmarkServer.prototype.getPort = function() {
*/
BenchmarkServer.prototype.mark = function(reset) {
var wall_time_diff = process.hrtime(this.last_wall_time);
+ var usage_diff = process.cpuUsage(this.last_usage);
if (reset) {
this.last_wall_time = process.hrtime();
+ this.last_usage = process.cpuUsage();
}
return {
time_elapsed: wall_time_diff[0] + wall_time_diff[1] / 1e9,
- // Not sure how to measure these values
- time_user: 0,
- time_system: 0
+ time_user: usage_diff.user / 1000000,
+ time_system: usage_diff.system / 1000000
};
};
diff --git a/src/node/performance/benchmark_server_express.js b/src/node/performance/benchmark_server_express.js
index 065bcf660b..fab4f5307c 100644
--- a/src/node/performance/benchmark_server_express.js
+++ b/src/node/performance/benchmark_server_express.js
@@ -46,7 +46,7 @@ var EventEmitter = require('events');
var util = require('util');
var express = require('express');
-var bodyParser = require('body-parser')
+var bodyParser = require('body-parser');
function unaryCall(req, res) {
var reqObj = req.body;
@@ -56,7 +56,7 @@ function unaryCall(req, res) {
function BenchmarkServer(host, port, tls, generic, response_size) {
var app = express();
- app.use(bodyParser.json())
+ app.use(bodyParser.json());
app.put('/serviceProto.BenchmarkService.service/unaryCall', unaryCall);
this.input_host = host;
this.input_port = port;
@@ -81,6 +81,7 @@ BenchmarkServer.prototype.start = function() {
var self = this;
this.server.listen(this.input_port, this.input_hostname, function() {
self.last_wall_time = process.hrtime();
+ self.last_usage = process.cpuUsage();
self.emit('started');
});
};
@@ -91,14 +92,15 @@ BenchmarkServer.prototype.getPort = function() {
BenchmarkServer.prototype.mark = function(reset) {
var wall_time_diff = process.hrtime(this.last_wall_time);
+ var usage_diff = process.cpuUsage(this.last_usage);
if (reset) {
this.last_wall_time = process.hrtime();
+ this.last_usage = process.cpuUsage();
}
return {
time_elapsed: wall_time_diff[0] + wall_time_diff[1] / 1e9,
- // Not sure how to measure these values
- time_user: 0,
- time_system: 0
+ time_user: usage_diff.user / 1000000,
+ time_system: usage_diff.system / 1000000
};
};
diff --git a/src/node/performance/generic_service.js b/src/node/performance/generic_service.js
index ce09cc4336..c936ac30bc 100644
--- a/src/node/performance/generic_service.js
+++ b/src/node/performance/generic_service.js
@@ -34,8 +34,17 @@
var _ = require('lodash');
module.exports = {
+ 'unaryCall' : {
+ path: '/grpc.testing.BenchmarkService/UnaryCall',
+ requestStream: false,
+ responseStream: false,
+ requestSerialize: _.identity,
+ requestDeserialize: _.identity,
+ responseSerialize: _.identity,
+ responseDeserialize: _.identity
+ },
'streamingCall' : {
- path: '/grpc.testing/BenchmarkService',
+ path: '/grpc.testing.BenchmarkService/StreamingCall',
requestStream: true,
responseStream: true,
requestSerialize: _.identity,
diff --git a/src/node/performance/worker.js b/src/node/performance/worker.js
index 030bf7d7ba..90a9b7d59c 100644
--- a/src/node/performance/worker.js
+++ b/src/node/performance/worker.js
@@ -44,8 +44,8 @@ var serviceProto = grpc.load({
function runServer(port, benchmark_impl) {
var server_creds = grpc.ServerCredentials.createInsecure();
var server = new grpc.Server();
- server.addProtoService(serviceProto.WorkerService.service,
- new WorkerServiceImpl(benchmark_impl, server));
+ server.addService(serviceProto.WorkerService.service,
+ new WorkerServiceImpl(benchmark_impl, server));
var address = '0.0.0.0:' + port;
server.bind(address, server_creds);
server.start();
diff --git a/src/node/performance/worker_service_impl.js b/src/node/performance/worker_service_impl.js
index 38888a7219..fa864f9925 100644
--- a/src/node/performance/worker_service_impl.js
+++ b/src/node/performance/worker_service_impl.js
@@ -89,6 +89,7 @@ module.exports = function WorkerServiceImpl(benchmark_impl, server) {
default:
call.emit('error', new Error('Unsupported PayloadConfig type' +
setup.payload_config.payload));
+ return;
}
switch (setup.load_params.load) {
case 'closed_loop':
@@ -103,6 +104,7 @@ module.exports = function WorkerServiceImpl(benchmark_impl, server) {
default:
call.emit('error', new Error('Unsupported LoadParams type' +
setup.load_params.load));
+ return;
}
stats = client.mark();
call.write({
@@ -137,8 +139,27 @@ module.exports = function WorkerServiceImpl(benchmark_impl, server) {
switch (request.argtype) {
case 'setup':
console.log('ServerConfig %j', request.setup);
+ var setup = request.setup;
+ var resp_size, generic;
+ if (setup.payload_config) {
+ switch (setup.payload_config.payload) {
+ case 'bytebuf_params':
+ resp_size = setup.payload_config.bytebuf_params.resp_size;
+ generic = true;
+ break;
+ case 'simple_params':
+ resp_size = setup.payload_config.simple_params.resp_size;
+ generic = false;
+ break;
+ default:
+ call.emit('error', new Error('Unsupported PayloadConfig type' +
+ setup.payload_config.payload));
+ return;
+ }
+ }
server = new BenchmarkServer('[::]', request.setup.port,
- request.setup.security_params);
+ request.setup.security_params,
+ generic, resp_size);
server.on('started', function() {
stats = server.mark();
call.write({