wip, faster putBlock

This commit is contained in:
voidlizard 2025-08-14 12:57:58 +03:00
parent 56d71cb988
commit 59a54fabb8
4 changed files with 6 additions and 2 deletions

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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