From 478c5b6db0b1e61bf0b5d47f14e5b0da414d090f Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Tue, 16 Jul 2019 10:25:49 +0100 Subject: [PATCH] Load ledger in reverse order Now that the SST files will fadvise on load (to force load into the page cache). The load should take place in reverse order, so that if th eledger is > page_cache, it is the higher levels that will end up in the cache at the expense of the lower levels. --- src/leveled_pmanifest.erl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/leveled_pmanifest.erl b/src/leveled_pmanifest.erl index 84c02e3..a1cce11 100644 --- a/src/leveled_pmanifest.erl +++ b/src/leveled_pmanifest.erl @@ -152,6 +152,11 @@ copy_manifest(Manifest) -> %% manifest. The PidFun should be able to return the Pid of a file process %% (having started one). The SQNFun will return the max sequence number %% of that file, if passed the Pid that owns it. +%% +%% The manifest is started from the basement first, and then the higher levels +%% as the page cache will be loaded with each file, and it would be +%% preferable to have the higher levels in the cache if memory is insufficient +%% to load each level load_manifest(Manifest, LoadFun, SQNFun) -> UpdateLevelFun = fun(LevelIdx, {AccMaxSQN, AccMan, AccFL}) -> @@ -171,7 +176,7 @@ load_manifest(Manifest, LoadFun, SQNFun) -> end, lists:foldl(UpdateLevelFun, {0, Manifest, []}, - lists:seq(0, Manifest#manifest.basement)). + lists:reverse(lists:seq(0, Manifest#manifest.basement))). -spec close_manifest(manifest(), fun()) -> ok. %% @doc