From fc206e60d26da97e16823b603a28253e5569024a Mon Sep 17 00:00:00 2001 From: Konstantin Knizhnik Date: Wed, 23 Aug 2023 14:49:22 +0300 Subject: [PATCH] Add lfc_max_mem GUC --- pgxn/neon/file_cache.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pgxn/neon/file_cache.c b/pgxn/neon/file_cache.c index a6aa381975..be2079f73d 100644 --- a/pgxn/neon/file_cache.c +++ b/pgxn/neon/file_cache.c @@ -91,6 +91,7 @@ typedef struct FileCacheControl static HTAB* lfc_hash; static LWLockId lfc_lock; static int lfc_max_size; +static int lfc_max_mem; static int lfc_size_limit; static int lfc_free_space_watermark; static int lfc_free_memory_watermark; @@ -181,6 +182,7 @@ lfc_shmem_request(void) prev_shmem_request_hook(); #endif + lfc_max_size = Min(lfc_max_size, lfc_max_mem); RequestAddinShmemSpace(sizeof(FileCacheControl) + lfc_max_size*MB + CHUNK_SIZE + hash_estimate_size(SIZE_MB_TO_CHUNKS(lfc_max_size)+1, sizeof(FileCacheEntry))); RequestNamedLWLockTranche("lfc_lock", 1); } @@ -324,6 +326,19 @@ lfc_init(void) NULL, NULL); + DefineCustomIntVariable("neon.max_inmem_cache_size", + "Maximal size used by Neon local file cache in memory", + NULL, + &lfc_max_mem, + 128, /* 128Mb */ + 0, + INT_MAX, + PGC_POSTMASTER, + GUC_UNIT_MB, + NULL, + NULL, + NULL); + DefineCustomIntVariable("neon.file_cache_size_limit", "Current limit for size of Neon local file cache", NULL,