Skip to content

Commit 2a657bf

Browse files
TD5facebook-github-bot
authored andcommitted
Avoid file server for more IO operations
Summary: By default, IO operations are serialised through the file server, which can add significant overhead. We can bypass this using the `raw` option or the `prim_file` module, depending on context. `wa_raft` already uses this in many places, but here we enable it in a few more to further boost performance. Reviewed By: hsun324 Differential Revision: D78900618 fbshipit-source-id: 597baa97a66bb803f4f41f307d6e9ca2a011c507
1 parent 49fb39a commit 2a657bf

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/wa_raft_storage.erl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ handle_delayed_reads(#state{queues = Queues, module = Module, handle = Handle, p
730730
-spec handle_create_snapshot(SnapshotName :: string(), Storage :: #state{}) -> {ok, wa_raft_log:log_pos()} | {error, Reason :: term()}.
731731
handle_create_snapshot(SnapshotName, #state{name = Name, path = Path, module = Module, handle = Handle, position = Position} = State) ->
732732
SnapshotPath = filename:join(Path, SnapshotName),
733-
case filelib:is_dir(SnapshotPath) of
733+
case filelib:is_dir(SnapshotPath, prim_file) of
734734
true ->
735735
?RAFT_LOG_NOTICE("Storage[~0p] skips recreating existing snapshot ~0p.", [Name, SnapshotName]),
736736
{ok, Position};
@@ -746,7 +746,7 @@ handle_create_snapshot(SnapshotName, #state{name = Name, path = Path, module = M
746746
-spec handle_create_witness_snapshot(SnapshotName :: string(), Storage :: #state{}) -> {ok, wa_raft_log:log_pos()} | {error, Reason :: term()}.
747747
handle_create_witness_snapshot(SnapshotName, #state{name = Name, path = Path, module = Module, handle = Handle, position = Position} = State) ->
748748
SnapshotPath = filename:join(Path, SnapshotName),
749-
case filelib:is_dir(SnapshotPath) of
749+
case filelib:is_dir(SnapshotPath, prim_file) of
750750
true ->
751751
?RAFT_LOG_NOTICE("Storage[~0p] skips recreating existing witness snapshot ~0p.", [Name, SnapshotName]),
752752
{ok, Position};
@@ -800,7 +800,7 @@ cleanup_snapshots(#state{path = Path}) ->
800800
%% Private functions
801801
-spec list_snapshots(Path :: string()) -> [{wa_raft_log:log_pos(), file:filename()}].
802802
list_snapshots(Path) ->
803-
SnapshotNames = filelib:wildcard(?SNAPSHOT_PREFIX ++ ".*", Path),
803+
SnapshotNames = filelib:wildcard(?SNAPSHOT_PREFIX ++ ".*", Path, prim_file),
804804
Snapshots = lists:filtermap(fun decode_snapshot_name/1, SnapshotNames),
805805
lists:keysort(1, Snapshots).
806806

0 commit comments

Comments
 (0)