From 02431421578aa06c9a7ca4ce838b7093a5ef7ca0 Mon Sep 17 00:00:00 2001 From: s0nicboOm Date: Thu, 31 Aug 2023 13:36:46 -0700 Subject: [PATCH 1/2] feat: add cachesize for inference cache Signed-off-by: s0nicboOm --- numalogic/udfs/inference.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/numalogic/udfs/inference.py b/numalogic/udfs/inference.py index ad3b8399..afb44cd6 100644 --- a/numalogic/udfs/inference.py +++ b/numalogic/udfs/inference.py @@ -21,6 +21,7 @@ # TODO: move to config LOCAL_CACHE_TTL = int(os.getenv("LOCAL_CACHE_TTL", "3600")) +LOCAL_CACHE_SIZE = int(os.getenv("LOCAL_CACHE_SIZE", "10000")) class InferenceUDF(NumalogicUDF): @@ -35,7 +36,7 @@ class InferenceUDF(NumalogicUDF): def __init__(self, r_client: redis_client_t, pl_conf: Optional[PipelineConf] = None): super().__init__(is_async=False) self.model_registry = RedisRegistry( - client=r_client, cache_registry=LocalLRUCache(ttl=LOCAL_CACHE_TTL) + client=r_client, cache_registry=LocalLRUCache(ttl=LOCAL_CACHE_TTL, cachesize=LOCAL_CACHE_SIZE) ) self.pl_conf = pl_conf or PipelineConf() From d7df6510448453fe26e6c08fe57a0b1dd142ebd5 Mon Sep 17 00:00:00 2001 From: s0nicboOm Date: Thu, 31 Aug 2023 13:38:45 -0700 Subject: [PATCH 2/2] feat: add cachesize for inference cache Signed-off-by: s0nicboOm --- numalogic/udfs/inference.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/numalogic/udfs/inference.py b/numalogic/udfs/inference.py index afb44cd6..c34bab18 100644 --- a/numalogic/udfs/inference.py +++ b/numalogic/udfs/inference.py @@ -36,7 +36,8 @@ class InferenceUDF(NumalogicUDF): def __init__(self, r_client: redis_client_t, pl_conf: Optional[PipelineConf] = None): super().__init__(is_async=False) self.model_registry = RedisRegistry( - client=r_client, cache_registry=LocalLRUCache(ttl=LOCAL_CACHE_TTL, cachesize=LOCAL_CACHE_SIZE) + client=r_client, + cache_registry=LocalLRUCache(ttl=LOCAL_CACHE_TTL, cachesize=LOCAL_CACHE_SIZE), ) self.pl_conf = pl_conf or PipelineConf()