mirror of https://github.com/voidlizard/hbs2
wip wtf
This commit is contained in:
parent
e08f68fbaf
commit
77ee8410cc
|
@ -598,16 +598,16 @@ ncqStorageRun2 ncq@NCQStorage2{..} = flip runContT pure do
|
||||||
Nothing -> none
|
Nothing -> none
|
||||||
Just e -> answer (Just (InMemory (ncqEntryData e))) >> next
|
Just e -> answer (Just (InMemory (ncqEntryData e))) >> next
|
||||||
|
|
||||||
useVersion ncq $ const do
|
-- useVersion ncq $ const do
|
||||||
|
|
||||||
tracked <- readTVarIO ncqTrackedFiles
|
tracked <- readTVarIO ncqTrackedFiles
|
||||||
|
|
||||||
for_ tracked $ \(TrackedFile{..}) -> do
|
for_ tracked $ \(TrackedFile{..}) -> do
|
||||||
readTVarIO tfCached >>= \case
|
readTVarIO tfCached >>= \case
|
||||||
|
Just ce -> lookupCached tfKey ce
|
||||||
|
Nothing -> ncqLoadTrackedFile ncq TrackedFile{..} >>= \case
|
||||||
|
Nothing -> err $ "unable to load index" <+> pretty tfKey
|
||||||
Just ce -> lookupCached tfKey ce
|
Just ce -> lookupCached tfKey ce
|
||||||
Nothing -> ncqLoadTrackedFile ncq TrackedFile{..} >>= \case
|
|
||||||
Nothing -> err $ "unable to load index" <+> pretty tfKey
|
|
||||||
Just ce -> lookupCached tfKey ce
|
|
||||||
|
|
||||||
next
|
next
|
||||||
|
|
||||||
|
|
|
@ -954,52 +954,40 @@ testNCQ2Lookup1 syn TestEnv{..} = do
|
||||||
|
|
||||||
(h, answ) <- atomically $ readTQueue readQ
|
(h, answ) <- atomically $ readTQueue readQ
|
||||||
|
|
||||||
f1 <- ncqLookupEntry sto h <&> isJust
|
ncqLookupEntry sto h >>= \case
|
||||||
|
Nothing -> none
|
||||||
|
Just e -> atomically (putTMVar answ (Just (InMemory (ncqEntryData e)))) >> next
|
||||||
|
|
||||||
when f1 do
|
ffs <- readTVarIO $ (N2.ncqTrackedFiles sto)
|
||||||
atomically (putTMVar answ True) >> next
|
|
||||||
|
|
||||||
ffs <- liftIO $ N2.ncqListTrackedFiles sto
|
for_ ffs $ \TrackedFile{..} -> do
|
||||||
|
readTVarIO tfCached >>= \case
|
||||||
|
|
||||||
for_ ffs $ \(f, ce, te) -> do
|
|
||||||
|
|
||||||
-- when (isNotPending ce) do
|
|
||||||
case ce of
|
|
||||||
Just (PendingEntry{}) -> none
|
Just (PendingEntry{}) -> none
|
||||||
|
|
||||||
Just (CachedEntry{..}) -> do
|
Just (CachedEntry{..}) -> do
|
||||||
found <- ncqLookupIndex h (cachedMmapedIdx, cachedNway) <&> isJust
|
ncqLookupIndex h (cachedMmapedIdx, cachedNway) >>= \case
|
||||||
|
Nothing -> none
|
||||||
when found do
|
Just (o,s) -> atomically (putTMVar answ (Just (N2.InFossil tfKey cachedMmapedData o s))) >> next
|
||||||
atomically (putTMVar answ True) >> next
|
|
||||||
|
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
|
|
||||||
tnow <- getTimeCoarse >>= newTVarIO
|
ncqLoadTrackedFile sto TrackedFile{..} >>= \case
|
||||||
|
Nothing -> err "FUCK" >> next
|
||||||
|
Just PendingEntry -> next
|
||||||
|
Just CachedEntry{..} -> do
|
||||||
|
ncqLookupIndex h (cachedMmapedIdx, cachedNway) >>= \case
|
||||||
|
Nothing -> none
|
||||||
|
Just (o,s) -> atomically (putTMVar answ (Just (N2.InFossil tfKey cachedMmapedData o s))) >> next
|
||||||
|
|
||||||
let indexFile = N2.ncqGetFileName sto (toFileName (IndexFile f))
|
atomically (putTMVar answ Nothing) >> next
|
||||||
let dataFile = N2.ncqGetFileName sto (toFileName (DataFile f))
|
|
||||||
|
|
||||||
what@(idxBs, idxNway) <- nwayHashMMapReadOnly indexFile `orDie` "mmap fucked"
|
|
||||||
datBs <- mmapFileByteString dataFile Nothing
|
|
||||||
|
|
||||||
let ce = CachedEntry idxBs datBs idxNway tnow
|
|
||||||
|
|
||||||
atomically $ writeTVar te (Just ce)
|
|
||||||
|
|
||||||
found <- ncqLookupIndex h what <&> isJust
|
|
||||||
|
|
||||||
when found do
|
|
||||||
atomically (putTMVar answ True) >> next
|
|
||||||
|
|
||||||
atomically (putTMVar answ False) >> next
|
|
||||||
|
|
||||||
liftIO $ pooledForConcurrentlyN_ nt hs $ \h -> do
|
liftIO $ pooledForConcurrentlyN_ nt hs $ \h -> do
|
||||||
answ <- newEmptyTMVarIO
|
answ <- newEmptyTMVarIO
|
||||||
atomically $ writeTQueue readQ (h, answ)
|
atomically $ writeTQueue readQ (h, answ)
|
||||||
found <- atomically $ takeTMVar answ
|
found <- atomically $ takeTMVar answ
|
||||||
|
|
||||||
when found do
|
when (isJust found) do
|
||||||
atomically $ modifyTVar' tfound succ
|
atomically $ modifyTVar' tfound succ
|
||||||
|
|
||||||
t1 <- getTimeCoarse
|
t1 <- getTimeCoarse
|
||||||
|
|
Loading…
Reference in New Issue