Skip to content

Commit

Permalink
Merge #92: Log the time it takes to sync the file on disk.
Browse files Browse the repository at this point in the history
Approved-by: DiegoDiverio
Auto-deploy: false
  • Loading branch information
OpsBotPrime committed Jan 19, 2023
2 parents d0bf69e + df79960 commit 16aebfc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion server/src/Persistence.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import qualified Data.Text as Text
import Data.Traversable
import Database.SQLite.Simple (FromRow (..), NamedParam (..), Only (..), execute,
execute_, executeNamed, field, open, query_)
import qualified System.Clock as Clock
import System.Directory (getFileSize, renameFile)
import System.Exit (die)
import System.IO
Expand Down Expand Up @@ -155,7 +156,12 @@ loadFromBackend backend config = runExceptT $ do
return val

syncToBackend :: StorageBackend -> PersistentValue -> IO ()
syncToBackend File pv = syncFile pv
syncToBackend File pv = do
start <- Clock.getTime Clock.Monotonic
syncFile pv
end <- Clock.getTime Clock.Monotonic
let time = Clock.toNanoSecs (Clock.diffTimeSpec end start) `div` 1000000
logMessage pv $ Text.concat ["It took ", Text.pack $ show time, " ms to synchronize Icepeak on disk."]
syncToBackend Sqlite pv = syncSqliteFile pv

-- * SQLite loading and syncing
Expand Down

0 comments on commit 16aebfc

Please sign in to comment.