Remove some lock contention when fsync’ing

This commit is contained in:
Kresten Krab Thorup 2014-11-26 13:57:47 +01:00
parent 0fa8ab4a02
commit 1715c29364

View file

@ -142,12 +142,12 @@ do_sync(File, Nursery) ->
case application:get_env(hanoidb, sync_strategy) of case application:get_env(hanoidb, sync_strategy) of
{ok, sync} -> {ok, sync} ->
file:datasync(File), file:datasync(File),
now(); os:timestamp();
{ok, {seconds, N}} -> {ok, {seconds, N}} ->
MicrosSinceLastSync = timer:now_diff(now(), Nursery#nursery.last_sync), MicrosSinceLastSync = timer:now_diff(os:timestamp(), Nursery#nursery.last_sync),
if (MicrosSinceLastSync / 1000000) >= N -> if (MicrosSinceLastSync div 1000000) >= N ->
file:datasync(File), file:datasync(File),
now(); os:timestamp();
true -> true ->
Nursery#nursery.last_sync Nursery#nursery.last_sync
end; end;