From 9d8fc7b984b6bcab71d8a77ce0c23b983f1f876e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B5=D0=BE=D0=BD=D0=B8=D0=B4=20=D0=AE=D1=80=D1=8C?= =?UTF-8?q?=D0=B5=D0=B2=20=28Leonid=20Yuriev=29?= Date: Thu, 3 Mar 2022 19:53:00 +0300 Subject: [PATCH] mdbx: minor mix result caching inside the `get_reasonable_db_maxsize()`. Change-Id: I9763ebb323d4f66e702e07f708e269e2479880ac --- src/core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core.c b/src/core.c index 73534e7a..1b245a3f 100644 --- a/src/core.c +++ b/src/core.c @@ -11275,10 +11275,12 @@ __cold static intptr_t get_reasonable_db_maxsize(intptr_t *cached_result) { intptr_t pagesize, total_ram_pages; if (unlikely(mdbx_get_sysraminfo(&pagesize, &total_ram_pages, nullptr) != MDBX_SUCCESS)) - return MAX_MAPSIZE32 /* the 32-bit limit is good enough for fallback */; + return *cached_result = MAX_MAPSIZE32 /* the 32-bit limit is good enough + for fallback */ + ; if (unlikely((size_t)total_ram_pages * 2 > MAX_MAPSIZE / (size_t)pagesize)) - return MAX_MAPSIZE; + return *cached_result = MAX_MAPSIZE; assert(MAX_MAPSIZE >= (size_t)(total_ram_pages * pagesize * 2)); /* Suggesting should not be more than golden ratio of the size of RAM. */