Skip to content

Commit

Permalink
Improve Proxy Perf
Browse files Browse the repository at this point in the history
  • Loading branch information
QuangTung97 committed Dec 1, 2023
1 parent 156f583 commit 7e31456
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion memproxy/proxy/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ def result(self) -> LeaseGetResponse:
conf.execute()

resp = self.resp

if len(_P) < 4096:
_P.append(self)

return resp


Expand Down Expand Up @@ -208,6 +212,9 @@ def return_func(self) -> DeleteResponse:
return self.resp


_P: List[_LeaseGetState] = []


class ProxyPipeline:
__slots__ = '_conf'

Expand All @@ -217,7 +224,10 @@ def __init__(self, conf: _ClientConfig, sess: Optional[Session]):
self._conf = _PipelineConfig(conf=conf, sess=sess)

def lease_get(self, key: str) -> LeaseGetResult:
state = _LeaseGetState()
try:
state = _P.pop()
except IndexError:
state = _LeaseGetState()

# do init get state
conf = self._conf
Expand Down

0 comments on commit 7e31456

Please sign in to comment.