Skip to content

Instantly share code, notes, and snippets.

/**
* Will read up expected bulkdata bytes from the input stream. Routine will
* also read in the last two bytes and will check that they are indeed CRLF.
*
* @param in the stream to read from.
* @param length expected bulk data length (NOT including the trailing CRLF).
* @return a byte[] of length.
* @throws IOException
* @throws IllegalArgumentException if could not read the bulk data
*/
package org.jredis;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import org.jredis.protocol.ResponseStatus;
private void runJRedisPipeline(ConnectionSpec spec, int reqCnt) {
JRedisFuture pipeline = new JRedisPipeline(spec);
try {
String key = "pipeCounter";
Future<Boolean> futureBool = pipeline.del(key);
futureBool.get();
int cnt = 0;
Future<Long> futureLong = null;
while(cnt < reqCnt){
futureLong = pipeline.incr(key);
Comparative runs using the redis-benchmark as a reference point (but its apples and oranges).
Using a single thread to continuously pipeline 10000 commands and then wait for completion of the last request. Repeat and keep running average.
Using jvm flags: -server -Xms512m -Xmx1536m
using connection spec: SocketProperty.SO_RCVBUF, 1024*256
Snippets of redis-benchmark output interspersed with JRedisPipeline stats. Pipeline response times for fire and forget are obviously better.
====== SET ======
.SUFFIXES: .go .6
OBJS=mc_constants.6 byte_manipulation.6 mc_storage.6 mc_conn_handler.6 gocache.6
PACKAGES=.
gocache: $(OBJS)
6l -o gocache $(OBJS)
clean:
rm -f $(OBJS) gocache
/*
* Copyright 2009 Joubin Houshyar
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
Last login: Sat Dec 5 11:14:52 on ttys000
Salaam!
alphazero[1]:~$ netstat
Active Internet connections
Proto Recv-Q Send-Q Local Address Foreign Address (state)
tcp4 7 0 localhost.6379 localhost.61176 ESTABLISHED
tcp4 0 0 localhost.61176 localhost.6379 ESTABLISHED
tcp4 14 0 192.168.1.104.57335 mcfeely.cs.umd.e.ftp CLOSE_WAIT
tcp4 0 0 localhost.51307 localhost.6379 TIME_WAIT
tcp4 0 0 localhost.51306 localhost.6379 TIME_WAIT
connect and ping in each iteration : 10000 iterations in 4328 msec @ 2310.536133 ops/sec
connect and ping in each iteration : 10000 iterations in 39270 msec @ 254.647308 ops/sec
connect and ping in each iteration : 10000 iterations in 3067 msec @ 3260.515137 ops/sec
connect and ping in each iteration : 10000 iterations in 38116 msec @ 262.357025 ops/sec
connect and ping in each iteration : 10000 iterations in 38197 msec @ 261.800690 ops/sec
connect and ping in each iteration : 10000 iterations in 3252 msec @ 3075.030762 ops/sec
connect and ping in each iteration : 10000 iterations in 38168 msec @ 261.999573 ops/sec
connect and ping in each iteration : 10000 iterations in 3086 msec @ 3240.440674 ops/sec
connect and ping in each iteration : 10000 iterations in 38111 msec @ 262.391449 ops/sec
connect and ping in each iteration : 10000 iterations in 38218 msec @ 261.656830 ops/sec
connect then ping in each iteration: 10000 iterations in 1068 msec @ 9363.295898 ops/sec
connect then ping in each iteration: 10000 iterations in 853 msec @ 11723.329102 ops/sec
connect then ping in each iteration: 10000 iterations in 753 msec @ 13280.212891 ops/sec
connect then ping in each iteration: 10000 iterations in 749 msec @ 13351.134766 ops/sec
connect then ping in each iteration: 10000 iterations in 749 msec @ 13351.134766 ops/sec
connect then ping in each iteration: 10000 iterations in 741 msec @ 13495.276367 ops/sec
connect then ping in each iteration: 10000 iterations in 742 msec @ 13477.088867 ops/sec
connect then ping in each iteration: 10000 iterations in 739 msec @ 13531.798828 ops/sec
connect then ping in each iteration: 10000 iterations in 738 msec @ 13550.135742 ops/sec
connect then ping in each iteration: 10000 iterations in 740 msec @ 13513.513672 ops/sec
/*
* Copyright 2009 Joubin Houshyar
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software