Skip to content

Commit

Permalink
SPY-8: Added a limit on how many gets can be optimized
Browse files Browse the repository at this point in the history
We have a limit on the amount of sets that can be optimized so we
should have a limit on how many gets can be optimized as well. This
way people don't run into any issues with optimizing too many get
requests and having the client timeout as a result of the server
being too slow trying to fill all of the requests in the multi-
get.

The max number of gets that can be optimized into a single
request is 4096.

Change-Id: I23c107ca3459e3386270c53f9ce20450d7ee8830
Reviewed-on: http://review.couchbase.org/8599
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Tested-by: Michael Wiederhold <mike@couchbase.com>
  • Loading branch information
Mike Wiederhold authored and Michael Wiederhold committed Aug 8, 2011
1 parent ab28ee3 commit b406daa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Expand Up @@ -17,6 +17,7 @@
*/
public class BinaryMemcachedNodeImpl extends TCPMemcachedNodeImpl {

private final int MAX_GET_OPTIMIZATION_COUNT = 4096;
private final int MAX_SET_OPTIMIZATION_COUNT = 65535;
private final int MAX_SET_OPTIMIZATION_BYTES = 2 * 1024 * 1024;

Expand Down Expand Up @@ -47,7 +48,8 @@ private void optimizeGets() {
(GetOperation)optimizedOp);
optimizedOp=og;

while(writeQ.peek() instanceof GetOperation) {
while(writeQ.peek() instanceof GetOperation
&& og.size() < MAX_GET_OPTIMIZATION_COUNT) {
GetOperation o=(GetOperation) writeQ.remove();
if(!o.isCancelled()) {
og.addOperation(o);
Expand Down
Expand Up @@ -33,4 +33,8 @@ public void addOperation(GetOperation o) {
}
}

public int size() {
return pcb.numKeys();
}

}

0 comments on commit b406daa

Please sign in to comment.