From 29d5025e19710ee1422e67bb8f91e8d9f342b194 Mon Sep 17 00:00:00 2001 From: voidlizard Date: Tue, 29 Jul 2025 14:40:52 +0300 Subject: [PATCH] wip --- hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/Index.hs | 2 +- hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/Run.hs | 9 ++++----- hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/State.hs | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/Index.hs b/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/Index.hs index 8e92ef9e..19ee37d7 100644 --- a/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/Index.hs +++ b/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/Index.hs @@ -42,7 +42,7 @@ ncqLookupIndex hx (mmaped, nway) = do ncqIndexFile :: MonadUnliftIO m => NCQStorage3 -> DataFile FileKey -> m (Maybe FilePath) -ncqIndexFile n@NCQStorage3{..} fk = runMaybeT do +ncqIndexFile n fk = runMaybeT do let fp = toFileName fk & ncqGetFileName n fki <- ncqGetNewFileKey n IndexFile diff --git a/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/Run.hs b/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/Run.hs index 27d0b55e..4ba3b546 100644 --- a/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/Run.hs +++ b/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/Run.hs @@ -56,7 +56,6 @@ ncqStorageRun3 ncq@NCQStorage3{..} = flip runContT pure do if not stop then STM.retry else pure Nothing maybe1 what none $ \(fk :: FileKey, fh) -> do - notice $ red "CLOSE FILE" <+> pretty fk closeFd fh ncqIndexFile ncq (DataFile fk) loop @@ -66,8 +65,7 @@ ncqStorageRun3 ncq@NCQStorage3{..} = flip runContT pure do let q = ncqWriteOps ! i forever (liftIO $ join $ atomically (readTQueue q)) - - replicateM_ 1 $ spawnActivity $ fix \next -> do + replicateM_ 2 $ spawnActivity $ fix \next -> do (h, answ) <- atomically $ readTQueue ncqReadReq let answer l = atomically (putTMVar answ l) @@ -117,7 +115,9 @@ ncqStorageRun3 ncq@NCQStorage3{..} = flip runContT pure do pure w else do appendTailSection fh >> liftIO (fileSynchronise fh) + ss <- liftIO (PFS.getFdStatus fh) <&> fromIntegral . PFS.fileSize + ncqStateUpdate ncq do ncqStateAddFact (P (PData (DataFile fk) ss)) @@ -172,8 +172,7 @@ ncqStorageRun3 ncq@NCQStorage3{..} = flip runContT pure do let written = sum ws loop $ RunSync (fk, fh, w + written, total' + written, True) - - pure () + wait closer where setAlive = atomically $ writeTVar ncqAlive True diff --git a/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/State.hs b/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/State.hs index 13bfefbd..478670c5 100644 --- a/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/State.hs +++ b/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/State.hs @@ -98,7 +98,7 @@ readStateMay sto key = fmap sortIndexes <$> do flip fix (ncqState0, sexps) $ \next -> \case (acc, []) -> pure acc - (acc, e : ss) -> liftIO (print (pretty e)) >> next (acc <> entryOf e, ss) + (acc, e : ss) -> next (acc <> entryOf e, ss) where