From a4d89ad6d16f9d23c49d50736d120b9c4995099e Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Mon, 14 Jan 2019 16:11:04 +0000 Subject: [PATCH] Add log of higher than expected ratio of cache sizes Warn at startup if this ratio is high. Not sure how snapshots will perform if there are a lot of ledger cache sin the list. However, it should still work. basic_SUITE/load_count test intended to demonstrate that a large ratio is still functional --- src/leveled_bookie.erl | 14 ++++++++++++++ src/leveled_log.erl | 3 +++ 2 files changed, 17 insertions(+) diff --git a/src/leveled_bookie.erl b/src/leveled_bookie.erl index c6027a0..7b5c7b7 100644 --- a/src/leveled_bookie.erl +++ b/src/leveled_bookie.erl @@ -1125,6 +1125,20 @@ init([Opts]) -> ConfiguredCacheSize div (100 div ?CACHE_SIZE_JITTER), CacheSize = ConfiguredCacheSize + erlang:phash2(self()) rem CacheJitter, + PCLMaxSize = + PencillerOpts#penciller_options.max_inmemory_tablesize, + CacheRatio = PCLMaxSize div ConfiguredCacheSize, + % It is expected that the maximum size of the penciller + % in-memory store should not be more than about 10 x the size + % of the ledger cache. In this case there will be a larger + % than tested list of ledger_caches in the penciller memory, + % and performance may be unpredictable + case CacheRatio > 32 of + true -> + leveled_log:log("B0020", [PCLMaxSize, ConfiguredCacheSize]); + false -> + ok + end, {HeadOnly, HeadLookup} = case proplists:get_value(head_only, Opts) of diff --git a/src/leveled_log.erl b/src/leveled_log.erl index 7f06ff9..954e3c0 100644 --- a/src/leveled_log.erl +++ b/src/leveled_log.erl @@ -75,6 +75,9 @@ {"B0019", {warn, "Use of book_indexfold with constraint of Bucket ~w with " ++ "no StartKey is deprecated"}}, + {"B0020", + {warn, "Ratio of penciller cache size ~w to bookie's memory " + ++ "cache size ~w is larger than expected"}}, {"R0001", {debug, "Object fold to process batch of ~w objects"}},