Need to binary copy the header

Otherwise the whole binary is kept in memory ... and the SST memory footprint is much bigger.
This commit is contained in:
Martin Sumner 2019-07-19 13:37:27 +01:00
parent da1ecc144a
commit c9c577259e

View file

@ -675,7 +675,7 @@ reader({get_kvrange, StartKey, EndKey, ScanWidth, SegList, LowLastMod},
{_ID, none} -> {_ID, none} ->
Cache; Cache;
{ID, Header} -> {ID, Header} ->
array:set(ID - 1, Header, Cache) array:set(ID - 1, binary:copy(Header), Cache)
end end
end, end,
BlockIdxC0 = lists:foldl(FoldFun, State#state.blockindex_cache, BIC), BlockIdxC0 = lists:foldl(FoldFun, State#state.blockindex_cache, BIC),
@ -1064,7 +1064,9 @@ fetch(LedgerKey, Hash, State, Timings0) ->
{Result, Header} = {Result, Header} =
binaryslot_get(SlotBin, LedgerKey, Hash, PressMethod, IdxModDate), binaryslot_get(SlotBin, LedgerKey, Hash, PressMethod, IdxModDate),
BlockIndexCache = BlockIndexCache =
array:set(SlotID - 1, Header, State#state.blockindex_cache), array:set(SlotID - 1,
binary:copy(Header),
State#state.blockindex_cache),
{_SW3, Timings3} = {_SW3, Timings3} =
update_timings(SW2, Timings2, noncached_block, false), update_timings(SW2, Timings2, noncached_block, false),
{Result, {Result,