redis 0.10.2 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.npmignore +8 -2
- package/README.md +12 -22
- package/connection_breaker.js +80 -0
- package/index.js +109 -30
- package/lib/commands.js +9 -1
- package/package.json +1 -1
- package/benches/buffer_bench.js +0 -89
- package/benches/hiredis_parser.js +0 -38
- package/benches/re_sub_test.js +0 -14
- package/benches/reconnect_test.js +0 -29
- package/benches/stress/codec.js +0 -16
- package/benches/stress/pubsub/pub.js +0 -38
- package/benches/stress/pubsub/run +0 -10
- package/benches/stress/pubsub/server.js +0 -23
- package/benches/stress/rpushblpop/pub.js +0 -49
- package/benches/stress/rpushblpop/run +0 -6
- package/benches/stress/rpushblpop/server.js +0 -30
- package/benches/stress/speed/00 +0 -13
- package/benches/stress/speed/plot +0 -13
- package/benches/stress/speed/size-rate.png +0 -0
- package/benches/stress/speed/speed.js +0 -84
- package/benches/sub_quit_test.js +0 -18
- package/changelog.md +0 -316
- package/diff_multi_bench_output.js +0 -90
- package/examples/auth.js +0 -5
- package/examples/backpressure_drain.js +0 -33
- package/examples/eval.js +0 -14
- package/examples/extend.js +0 -24
- package/examples/file.js +0 -32
- package/examples/mget.js +0 -5
- package/examples/monitor.js +0 -10
- package/examples/multi.js +0 -46
- package/examples/multi2.js +0 -29
- package/examples/psubscribe.js +0 -33
- package/examples/pub_sub.js +0 -41
- package/examples/simple.js +0 -24
- package/examples/sort.js +0 -17
- package/examples/subqueries.js +0 -15
- package/examples/subquery.js +0 -19
- package/examples/unix_socket.js +0 -29
- package/examples/web_server.js +0 -31
- package/generate_commands.js +0 -39
- package/multi_bench.js +0 -222
- package/test-unref.js +0 -12
- package/test.js +0 -2257
package/multi_bench.js
DELETED
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
var redis = require("./index"),
|
|
2
|
-
metrics = require("metrics"),
|
|
3
|
-
num_clients = parseInt(process.argv[2], 10) || 5,
|
|
4
|
-
num_requests = 20000,
|
|
5
|
-
tests = [],
|
|
6
|
-
versions_logged = false,
|
|
7
|
-
client_options = {
|
|
8
|
-
return_buffers: false
|
|
9
|
-
},
|
|
10
|
-
small_str, large_str, small_buf, large_buf;
|
|
11
|
-
|
|
12
|
-
redis.debug_mode = false;
|
|
13
|
-
|
|
14
|
-
function lpad(input, len, chr) {
|
|
15
|
-
var str = input.toString();
|
|
16
|
-
chr = chr || " ";
|
|
17
|
-
|
|
18
|
-
while (str.length < len) {
|
|
19
|
-
str = chr + str;
|
|
20
|
-
}
|
|
21
|
-
return str;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
metrics.Histogram.prototype.print_line = function () {
|
|
25
|
-
var obj = this.printObj();
|
|
26
|
-
|
|
27
|
-
return lpad(obj.min, 4) + "/" + lpad(obj.max, 4) + "/" + lpad(obj.mean.toFixed(2), 7) + "/" + lpad(obj.p95.toFixed(2), 7);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
function Test(args) {
|
|
31
|
-
this.args = args;
|
|
32
|
-
|
|
33
|
-
this.callback = null;
|
|
34
|
-
this.clients = [];
|
|
35
|
-
this.clients_ready = 0;
|
|
36
|
-
this.commands_sent = 0;
|
|
37
|
-
this.commands_completed = 0;
|
|
38
|
-
this.max_pipeline = this.args.pipeline || num_requests;
|
|
39
|
-
this.client_options = args.client_options || client_options;
|
|
40
|
-
|
|
41
|
-
this.connect_latency = new metrics.Histogram();
|
|
42
|
-
this.ready_latency = new metrics.Histogram();
|
|
43
|
-
this.command_latency = new metrics.Histogram();
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
Test.prototype.run = function (callback) {
|
|
47
|
-
var i;
|
|
48
|
-
|
|
49
|
-
this.callback = callback;
|
|
50
|
-
|
|
51
|
-
for (i = 0; i < num_clients ; i++) {
|
|
52
|
-
this.new_client(i);
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
Test.prototype.new_client = function (id) {
|
|
57
|
-
var self = this, new_client;
|
|
58
|
-
|
|
59
|
-
new_client = redis.createClient(6379, "127.0.0.1", this.client_options);
|
|
60
|
-
new_client.create_time = Date.now();
|
|
61
|
-
|
|
62
|
-
new_client.on("connect", function () {
|
|
63
|
-
self.connect_latency.update(Date.now() - new_client.create_time);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
new_client.on("ready", function () {
|
|
67
|
-
if (! versions_logged) {
|
|
68
|
-
console.log("Client count: " + num_clients + ", node version: " + process.versions.node + ", server version: " +
|
|
69
|
-
new_client.server_info.redis_version + ", parser: " + new_client.reply_parser.name);
|
|
70
|
-
versions_logged = true;
|
|
71
|
-
}
|
|
72
|
-
self.ready_latency.update(Date.now() - new_client.create_time);
|
|
73
|
-
self.clients_ready++;
|
|
74
|
-
if (self.clients_ready === self.clients.length) {
|
|
75
|
-
self.on_clients_ready();
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
self.clients[id] = new_client;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
Test.prototype.on_clients_ready = function () {
|
|
83
|
-
process.stdout.write(lpad(this.args.descr, 13) + ", " + lpad(this.args.pipeline, 5) + "/" + this.clients_ready + " ");
|
|
84
|
-
this.test_start = Date.now();
|
|
85
|
-
|
|
86
|
-
this.fill_pipeline();
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
Test.prototype.fill_pipeline = function () {
|
|
90
|
-
var pipeline = this.commands_sent - this.commands_completed;
|
|
91
|
-
|
|
92
|
-
while (this.commands_sent < num_requests && pipeline < this.max_pipeline) {
|
|
93
|
-
this.commands_sent++;
|
|
94
|
-
pipeline++;
|
|
95
|
-
this.send_next();
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (this.commands_completed === num_requests) {
|
|
99
|
-
this.print_stats();
|
|
100
|
-
this.stop_clients();
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
Test.prototype.stop_clients = function () {
|
|
105
|
-
var self = this;
|
|
106
|
-
|
|
107
|
-
this.clients.forEach(function (client, pos) {
|
|
108
|
-
if (pos === self.clients.length - 1) {
|
|
109
|
-
client.quit(function (err, res) {
|
|
110
|
-
self.callback();
|
|
111
|
-
});
|
|
112
|
-
} else {
|
|
113
|
-
client.quit();
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
Test.prototype.send_next = function () {
|
|
119
|
-
var self = this,
|
|
120
|
-
cur_client = this.commands_sent % this.clients.length,
|
|
121
|
-
start = Date.now();
|
|
122
|
-
|
|
123
|
-
this.clients[cur_client][this.args.command](this.args.args, function (err, res) {
|
|
124
|
-
if (err) {
|
|
125
|
-
throw err;
|
|
126
|
-
}
|
|
127
|
-
self.commands_completed++;
|
|
128
|
-
self.command_latency.update(Date.now() - start);
|
|
129
|
-
self.fill_pipeline();
|
|
130
|
-
});
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
Test.prototype.print_stats = function () {
|
|
134
|
-
var duration = Date.now() - this.test_start;
|
|
135
|
-
|
|
136
|
-
console.log("min/max/avg/p95: " + this.command_latency.print_line() + " " + lpad(duration, 6) + "ms total, " +
|
|
137
|
-
lpad((num_requests / (duration / 1000)).toFixed(2), 8) + " ops/sec");
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
small_str = "1234";
|
|
141
|
-
small_buf = new Buffer(small_str);
|
|
142
|
-
large_str = (new Array(4097).join("-"));
|
|
143
|
-
large_buf = new Buffer(large_str);
|
|
144
|
-
|
|
145
|
-
tests.push(new Test({descr: "PING", command: "ping", args: [], pipeline: 1}));
|
|
146
|
-
tests.push(new Test({descr: "PING", command: "ping", args: [], pipeline: 50}));
|
|
147
|
-
tests.push(new Test({descr: "PING", command: "ping", args: [], pipeline: 200}));
|
|
148
|
-
tests.push(new Test({descr: "PING", command: "ping", args: [], pipeline: 20000}));
|
|
149
|
-
|
|
150
|
-
tests.push(new Test({descr: "SET small str", command: "set", args: ["foo_rand000000000000", small_str], pipeline: 1}));
|
|
151
|
-
tests.push(new Test({descr: "SET small str", command: "set", args: ["foo_rand000000000000", small_str], pipeline: 50}));
|
|
152
|
-
tests.push(new Test({descr: "SET small str", command: "set", args: ["foo_rand000000000000", small_str], pipeline: 200}));
|
|
153
|
-
tests.push(new Test({descr: "SET small str", command: "set", args: ["foo_rand000000000000", small_str], pipeline: 20000}));
|
|
154
|
-
|
|
155
|
-
tests.push(new Test({descr: "SET small buf", command: "set", args: ["foo_rand000000000000", small_buf], pipeline: 1}));
|
|
156
|
-
tests.push(new Test({descr: "SET small buf", command: "set", args: ["foo_rand000000000000", small_buf], pipeline: 50}));
|
|
157
|
-
tests.push(new Test({descr: "SET small buf", command: "set", args: ["foo_rand000000000000", small_buf], pipeline: 200}));
|
|
158
|
-
tests.push(new Test({descr: "SET small buf", command: "set", args: ["foo_rand000000000000", small_buf], pipeline: 20000}));
|
|
159
|
-
|
|
160
|
-
tests.push(new Test({descr: "GET small str", command: "get", args: ["foo_rand000000000000"], pipeline: 1}));
|
|
161
|
-
tests.push(new Test({descr: "GET small str", command: "get", args: ["foo_rand000000000000"], pipeline: 50}));
|
|
162
|
-
tests.push(new Test({descr: "GET small str", command: "get", args: ["foo_rand000000000000"], pipeline: 200}));
|
|
163
|
-
tests.push(new Test({descr: "GET small str", command: "get", args: ["foo_rand000000000000"], pipeline: 20000}));
|
|
164
|
-
|
|
165
|
-
tests.push(new Test({descr: "GET small buf", command: "get", args: ["foo_rand000000000000"], pipeline: 1, client_opts: { return_buffers: true} }));
|
|
166
|
-
tests.push(new Test({descr: "GET small buf", command: "get", args: ["foo_rand000000000000"], pipeline: 50, client_opts: { return_buffers: true} }));
|
|
167
|
-
tests.push(new Test({descr: "GET small buf", command: "get", args: ["foo_rand000000000000"], pipeline: 200, client_opts: { return_buffers: true} }));
|
|
168
|
-
tests.push(new Test({descr: "GET small buf", command: "get", args: ["foo_rand000000000000"], pipeline: 20000, client_opts: { return_buffers: true} }));
|
|
169
|
-
|
|
170
|
-
tests.push(new Test({descr: "SET large str", command: "set", args: ["foo_rand000000000001", large_str], pipeline: 1}));
|
|
171
|
-
tests.push(new Test({descr: "SET large str", command: "set", args: ["foo_rand000000000001", large_str], pipeline: 50}));
|
|
172
|
-
tests.push(new Test({descr: "SET large str", command: "set", args: ["foo_rand000000000001", large_str], pipeline: 200}));
|
|
173
|
-
tests.push(new Test({descr: "SET large str", command: "set", args: ["foo_rand000000000001", large_str], pipeline: 20000}));
|
|
174
|
-
|
|
175
|
-
tests.push(new Test({descr: "SET large buf", command: "set", args: ["foo_rand000000000001", large_buf], pipeline: 1}));
|
|
176
|
-
tests.push(new Test({descr: "SET large buf", command: "set", args: ["foo_rand000000000001", large_buf], pipeline: 50}));
|
|
177
|
-
tests.push(new Test({descr: "SET large buf", command: "set", args: ["foo_rand000000000001", large_buf], pipeline: 200}));
|
|
178
|
-
tests.push(new Test({descr: "SET large buf", command: "set", args: ["foo_rand000000000001", large_buf], pipeline: 20000}));
|
|
179
|
-
|
|
180
|
-
tests.push(new Test({descr: "GET large str", command: "get", args: ["foo_rand000000000001"], pipeline: 1}));
|
|
181
|
-
tests.push(new Test({descr: "GET large str", command: "get", args: ["foo_rand000000000001"], pipeline: 50}));
|
|
182
|
-
tests.push(new Test({descr: "GET large str", command: "get", args: ["foo_rand000000000001"], pipeline: 200}));
|
|
183
|
-
tests.push(new Test({descr: "GET large str", command: "get", args: ["foo_rand000000000001"], pipeline: 20000}));
|
|
184
|
-
|
|
185
|
-
tests.push(new Test({descr: "GET large buf", command: "get", args: ["foo_rand000000000001"], pipeline: 1, client_opts: { return_buffers: true} }));
|
|
186
|
-
tests.push(new Test({descr: "GET large buf", command: "get", args: ["foo_rand000000000001"], pipeline: 50, client_opts: { return_buffers: true} }));
|
|
187
|
-
tests.push(new Test({descr: "GET large buf", command: "get", args: ["foo_rand000000000001"], pipeline: 200, client_opts: { return_buffers: true} }));
|
|
188
|
-
tests.push(new Test({descr: "GET large buf", command: "get", args: ["foo_rand000000000001"], pipeline: 20000, client_opts: { return_buffers: true} }));
|
|
189
|
-
|
|
190
|
-
tests.push(new Test({descr: "INCR", command: "incr", args: ["counter_rand000000000000"], pipeline: 1}));
|
|
191
|
-
tests.push(new Test({descr: "INCR", command: "incr", args: ["counter_rand000000000000"], pipeline: 50}));
|
|
192
|
-
tests.push(new Test({descr: "INCR", command: "incr", args: ["counter_rand000000000000"], pipeline: 200}));
|
|
193
|
-
tests.push(new Test({descr: "INCR", command: "incr", args: ["counter_rand000000000000"], pipeline: 20000}));
|
|
194
|
-
|
|
195
|
-
tests.push(new Test({descr: "LPUSH", command: "lpush", args: ["mylist", small_str], pipeline: 1}));
|
|
196
|
-
tests.push(new Test({descr: "LPUSH", command: "lpush", args: ["mylist", small_str], pipeline: 50}));
|
|
197
|
-
tests.push(new Test({descr: "LPUSH", command: "lpush", args: ["mylist", small_str], pipeline: 200}));
|
|
198
|
-
tests.push(new Test({descr: "LPUSH", command: "lpush", args: ["mylist", small_str], pipeline: 20000}));
|
|
199
|
-
|
|
200
|
-
tests.push(new Test({descr: "LRANGE 10", command: "lrange", args: ["mylist", "0", "9"], pipeline: 1}));
|
|
201
|
-
tests.push(new Test({descr: "LRANGE 10", command: "lrange", args: ["mylist", "0", "9"], pipeline: 50}));
|
|
202
|
-
tests.push(new Test({descr: "LRANGE 10", command: "lrange", args: ["mylist", "0", "9"], pipeline: 200}));
|
|
203
|
-
tests.push(new Test({descr: "LRANGE 10", command: "lrange", args: ["mylist", "0", "9"], pipeline: 20000}));
|
|
204
|
-
|
|
205
|
-
tests.push(new Test({descr: "LRANGE 100", command: "lrange", args: ["mylist", "0", "99"], pipeline: 1}));
|
|
206
|
-
tests.push(new Test({descr: "LRANGE 100", command: "lrange", args: ["mylist", "0", "99"], pipeline: 50}));
|
|
207
|
-
tests.push(new Test({descr: "LRANGE 100", command: "lrange", args: ["mylist", "0", "99"], pipeline: 200}));
|
|
208
|
-
tests.push(new Test({descr: "LRANGE 100", command: "lrange", args: ["mylist", "0", "99"], pipeline: 20000}));
|
|
209
|
-
|
|
210
|
-
function next() {
|
|
211
|
-
var test = tests.shift();
|
|
212
|
-
if (test) {
|
|
213
|
-
test.run(function () {
|
|
214
|
-
next();
|
|
215
|
-
});
|
|
216
|
-
} else {
|
|
217
|
-
console.log("End of tests.");
|
|
218
|
-
process.exit(0);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
next();
|
package/test-unref.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
var redis = require("./")
|
|
2
|
-
//redis.debug_mode = true
|
|
3
|
-
var PORT = process.argv[2] || 6379;
|
|
4
|
-
var HOST = process.argv[3] || '127.0.0.1';
|
|
5
|
-
|
|
6
|
-
var c = redis.createClient(PORT, HOST)
|
|
7
|
-
c.unref()
|
|
8
|
-
c.info(function (err, reply) {
|
|
9
|
-
if (err) process.exit(-1)
|
|
10
|
-
if (!reply.length) process.exit(-1)
|
|
11
|
-
process.stdout.write(reply.length.toString())
|
|
12
|
-
})
|