From 1715c29364f546b696204d5a0e414d86bfeb234e Mon Sep 17 00:00:00 2001 From: Kresten Krab Thorup Date: Wed, 26 Nov 2014 13:57:47 +0100 Subject: [PATCH] =?UTF-8?q?Remove=20some=20lock=20contention=20when=20fsyn?= =?UTF-8?q?c=E2=80=99ing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hanoidb_nursery.erl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hanoidb_nursery.erl b/src/hanoidb_nursery.erl index 11b1b6a..90e5a85 100644 --- a/src/hanoidb_nursery.erl +++ b/src/hanoidb_nursery.erl @@ -142,12 +142,12 @@ do_sync(File, Nursery) -> case application:get_env(hanoidb, sync_strategy) of {ok, sync} -> file:datasync(File), - now(); + os:timestamp(); {ok, {seconds, N}} -> - MicrosSinceLastSync = timer:now_diff(now(), Nursery#nursery.last_sync), - if (MicrosSinceLastSync / 1000000) >= N -> + MicrosSinceLastSync = timer:now_diff(os:timestamp(), Nursery#nursery.last_sync), + if (MicrosSinceLastSync div 1000000) >= N -> file:datasync(File), - now(); + os:timestamp(); true -> Nursery#nursery.last_sync end;