From 0cbd28b4bfb15cb7c4ce95b75e2915d6baafc15a Mon Sep 17 00:00:00 2001 From: Karl Nilsson Date: Tue, 17 Dec 2024 14:36:38 +0000 Subject: [PATCH] try random again --- src/ra_log_segment.erl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/ra_log_segment.erl b/src/ra_log_segment.erl index 5dd56a0d..d2a1988d 100644 --- a/src/ra_log_segment.erl +++ b/src/ra_log_segment.erl @@ -116,6 +116,15 @@ open(Filename, Options) -> process_file(true, Mode, Filename, Fd, Options) -> AccessPattern = maps:get(access_pattern, Options, random), + if AccessPattern == random andalso + Mode == read -> + %% this is a guess using the defaults + Offs = maps:get(max_count, Options, ?SEGMENT_MAX_ENTRIES) * ?INDEX_RECORD_SIZE_V2, + _ = file:advise(Fd, Offs, 0, random), + ok; + true -> + ok + end, case read_header(Fd) of {ok, Version, MaxCount} -> MaxPending = maps:get(max_pending, Options, ?SEGMENT_MAX_PENDING),