From 8da69dc38e172a617bd49bb9ac999de5f7432f9f Mon Sep 17 00:00:00 2001 From: voidlizard Date: Fri, 11 Jul 2025 13:51:22 +0300 Subject: [PATCH] parallel lookup attempt; does not work. ncqLocateMt --- hbs2-storage-ncq/lib/HBS2/Storage/NCQ2.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hbs2-storage-ncq/lib/HBS2/Storage/NCQ2.hs b/hbs2-storage-ncq/lib/HBS2/Storage/NCQ2.hs index 782cbefc..c6387745 100644 --- a/hbs2-storage-ncq/lib/HBS2/Storage/NCQ2.hs +++ b/hbs2-storage-ncq/lib/HBS2/Storage/NCQ2.hs @@ -272,12 +272,15 @@ ncqEntrySize = \case InFossil _ _ size -> fromIntegral size InMemory bs -> fromIntegral (BS.length bs) + ncqLocate2 :: MonadUnliftIO m => NCQStorage2 -> HashRef -> m (Maybe Location) ncqLocate2 ncq@NCQStorage2{..} href = flip runContT pure $ callCC \exit -> do now <- getTimeCoarse lift (ncqLookupEntry ncq href) >>= maybe none (exit . Just . InMemory . coerce) + atomically $ modifyTVar' ncqWrites succ + tracked <- readTVarIO ncqTrackedFiles <&> HPSQ.toList for_ tracked $ \(fk, prio, mCached) -> case mCached of @@ -318,6 +321,7 @@ ncqLocate2 ncq@NCQStorage2{..} href = flip runContT pure $ callCC \exit -> do pure ( fromIntegral $ N.word64 (BS.take 8 entryBs) , fromIntegral $ N.word32 (BS.take 4 (BS.drop 8 entryBs)) ) + {-# INLINE lookupEntry #-} ncqAlterEntrySTM :: NCQStorage2 -> HashRef -> (Maybe NCQEntry -> Maybe NCQEntry) -> STM () ncqAlterEntrySTM ncq h alterFn = do