diff --git a/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal.hs b/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal.hs index 534b4f22..e54a0a02 100644 --- a/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal.hs +++ b/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal.hs @@ -46,6 +46,8 @@ ncqStorageOpen fp upd = do let shardNum = fromIntegral cap let wopNum = 2 + let !ncqReadThreads = wopNum * 4 + ncqWriteQ <- newTVarIO mempty ncqMemTable <- V.fromList <$> replicateM shardNum (newTVarIO mempty) ncqMMapCachedIdx <- newTVarIO HPSQ.empty 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 155e6f88..54e7b7c5 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,7 @@ ncqStorageRun ncq@NCQStorage{..} = flip runContT pure do let q = ncqWriteOps ! i forever (liftIO $ join $ atomically (readTQueue q)) - replicateM_ 2 $ spawnActivity $ forever $ flip runContT pure $ callCC \exit -> do + replicateM_ ncqReadThreads $ spawnActivity $ forever $ flip runContT pure $ callCC \exit -> do (h, answ) <- atomically $ readTQueue ncqReadReq let answer l = atomically (putTMVar answ l) diff --git a/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/Types.hs b/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/Types.hs index 5f92d374..b25d8720 100644 --- a/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/Types.hs +++ b/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/Types.hs @@ -85,6 +85,7 @@ data NCQStorage = , ncqMaxLog :: Int , ncqMaxCachedIndex :: Int , ncqMaxCachedData :: Int + , ncqReadThreads :: Int , ncqIdleThrsh :: Double , ncqMMapCachedIdx :: TVar (HashPSQ FileKey CachePrio CachedIndex) , ncqMMapCachedData :: TVar (HashPSQ FileKey CachePrio CachedData) diff --git a/hbs2-tests/test/NCQ3.hs b/hbs2-tests/test/NCQ3.hs index a7c71cb6..55a670e7 100644 --- a/hbs2-tests/test/NCQ3.hs +++ b/hbs2-tests/test/NCQ3.hs @@ -606,8 +606,9 @@ ncq3Tests = do chu <- S.toList_ (readChunkedBS lbs (256*1024)) hashes <- forConcurrently chu $ \chunk -> do - -- ncqPutBS ncq (Just B) Nothing (LBS.toStrict chunk) ncqTossBlock ncq chunk >>= orThrowUser "can't save" + -- ncqPutBlock ncq chunk + -- ncqPutBS ncq (Just B) Nothing (LBS.toStrict chunk none