diff --git a/priv/leveled.schema b/priv/leveled.schema index 3e565e6..7c259dc 100644 --- a/priv/leveled.schema +++ b/priv/leveled.schema @@ -72,7 +72,7 @@ {datatype, integer} ]}. -%% @doc The approximate size (in bytes) when a Journal file should be rolled. +%% @doc The approximate count of objects when a Journal file should be rolled. %% This time measured in object count, a file will be rolled if either the %% object count or the journal size limit is reached. Default 200K. %% Note that on startup an actual maximum size will be chosen which varies by @@ -83,6 +83,14 @@ {datatype, integer} ]}. +%% @doc The level of the ledger to be pre-loaded into the page cache +%% Depending on how much memory is available for the page cache, and how much +%% disk I/O activity can be tolerated at startup - then the level at which the +%% ledger is forced into the page cache can be controlled by configuration. +{mapping, "leveled.ledger_pagecachelevel", "leveled.ledger_pagecachelevel", [ + {default, 4}, + {datatype, integer} +]}. %% @doc The number of journal compactions per vnode per day %% The higher the value, the more compaction runs, and the sooner space is diff --git a/priv/leveled_multi.schema b/priv/leveled_multi.schema index 22857d7..d1cc0d3 100644 --- a/priv/leveled_multi.schema +++ b/priv/leveled_multi.schema @@ -66,7 +66,7 @@ {datatype, integer} ]}. -%% @doc The approximate size (in bytes) when a Journal file should be rolled. +%% @doc The approximate count of objects when a Journal file should be rolled. %% This time measured in object count, a file will be rolled if either the %% object count or the journal size limit is reached. Default 200K. %% Note that on startup an actual maximum size will be chosen which varies by @@ -77,6 +77,16 @@ {datatype, integer} ]}. +%% @doc The level of the ledger to be pre-loaded into the page cache +%% Depending on how much memory is available for the page cache, and how much +%% disk I/O activity can be tolerated at startup - then the level at which the +%% ledger is forced into the page cache can be controlled by configuration. +{mapping, "multi_backend.$name.leveled.ledger_pagecachelevel", "riak_kv.multi_backend", [ + {default, 4}, + {datatype, integer} +]}. + + %% @doc The number of journal compactions per vnode per day %% The higher the value, the more compaction runs, and the sooner space is %% recovered. But each run has a cost diff --git a/src/leveled_bookie.erl b/src/leveled_bookie.erl index b14dfde..3fbf027 100644 --- a/src/leveled_bookie.erl +++ b/src/leveled_bookie.erl @@ -144,6 +144,7 @@ {maxrunlength_compactionpercentage, 70.0}, {reload_strategy, []}, {max_pencillercachesize, ?MAX_PCL_CACHE_SIZE}, + {ledger_preloadpagecache_level, ?SST_PAGECACHELEVEL_LOOKUP}, {compression_method, ?COMPRESSION_METHOD}, {compression_point, ?COMPRESSION_POINT}, {log_level, ?LOG_LEVEL}, @@ -320,6 +321,10 @@ % The minimum size 400 - attempt to set this vlaue lower will be % ignored. As a rule the value should be at least 4 x the Bookie's % cache size + {ledger_preloadpagecache_level, pos_integer()} | + % To which level of the ledger should the ledger contents be + % pre-loaded into the pagecache (using fadvise on creation and + % startup) {compression_method, native|lz4} | % Compression method and point allow Leveled to be switched from % using bif based compression (zlib) to using nif based compression @@ -1183,13 +1188,15 @@ init([Opts]) -> false -> ok end, - + + PageCacheLevel = proplists:get_value(ledger_preloadpagecache_level, Opts), + {HeadOnly, HeadLookup, SSTPageCacheLevel} = case proplists:get_value(head_only, Opts) of false -> - {false, true, ?SST_PAGECACHELEVEL_LOOKUP}; + {false, true, PageCacheLevel}; with_lookup -> - {true, true, ?SST_PAGECACHELEVEL_LOOKUP}; + {true, true, PageCacheLevel}; no_lookup -> {true, false, ?SST_PAGECACHELEVEL_NOLOOKUP} end,