mirror of https://github.com/voidlizard/hbs2
wip
This commit is contained in:
parent
1a36018aa5
commit
ac629634c0
|
@ -31,8 +31,8 @@ import HBS2.Net.Proto.Notify
|
||||||
import HBS2.Peer.Proto.Mailbox
|
import HBS2.Peer.Proto.Mailbox
|
||||||
import HBS2.OrDie
|
import HBS2.OrDie
|
||||||
import HBS2.Storage.Simple
|
import HBS2.Storage.Simple
|
||||||
-- import HBS2.Storage.NCQ3
|
import HBS2.Storage.NCQ3
|
||||||
import HBS2.Storage.NCQ
|
-- import HBS2.Storage.NCQ
|
||||||
import HBS2.Storage.Operations.Missed
|
import HBS2.Storage.Operations.Missed
|
||||||
import HBS2.Data.Detect
|
import HBS2.Data.Detect
|
||||||
|
|
||||||
|
@ -822,13 +822,13 @@ runPeer opts = respawnOnError opts $ flip runContT pure do
|
||||||
|
|
||||||
-- error "STOP"
|
-- error "STOP"
|
||||||
|
|
||||||
-- let ncqPath = coerce pref </> "ncq3"
|
let ncqPath = coerce pref </> "ncq3"
|
||||||
let ncqPath = coerce pref </> "ncq"
|
-- let ncqPath = coerce pref </> "ncq"
|
||||||
|
|
||||||
debug $ "storage prefix:" <+> pretty ncqPath
|
debug $ "storage prefix:" <+> pretty ncqPath
|
||||||
|
|
||||||
-- s <- ContT $ ncqWithStorage ncqPath
|
-- s <- ContT $ ncqWithStorage ncqPath
|
||||||
s <- lift $ ncqStorageOpen ncqPath
|
s <- lift $ ncqStorageOpen ncqPath id
|
||||||
|
|
||||||
-- simpleStorageInit @HbSync (Just pref)
|
-- simpleStorageInit @HbSync (Just pref)
|
||||||
let blk = liftIO . hasBlock s
|
let blk = liftIO . hasBlock s
|
||||||
|
@ -1380,7 +1380,7 @@ runPeer opts = respawnOnError opts $ flip runContT pure do
|
||||||
, monkeys
|
, monkeys
|
||||||
]
|
]
|
||||||
|
|
||||||
-- liftIO $ ncqStorageStop s
|
liftIO $ ncqStorageStop s
|
||||||
pause @'Seconds 1
|
pause @'Seconds 1
|
||||||
|
|
||||||
-- we want to clean up all resources
|
-- we want to clean up all resources
|
||||||
|
@ -1399,7 +1399,7 @@ checkMigration prefix = flip runContT pure $ callCC \exit -> do
|
||||||
already <- Sy.doesDirectoryExist migration
|
already <- Sy.doesDirectoryExist migration
|
||||||
|
|
||||||
when (L.null blocks && not already) do
|
when (L.null blocks && not already) do
|
||||||
-- checkNCQ1
|
checkNCQ1
|
||||||
exit ()
|
exit ()
|
||||||
|
|
||||||
let reason = if already then
|
let reason = if already then
|
||||||
|
@ -1417,14 +1417,15 @@ checkMigration prefix = flip runContT pure $ callCC \exit -> do
|
||||||
|
|
||||||
|
|
||||||
where
|
where
|
||||||
-- checkNCQ1 = do
|
checkNCQ1 :: ContT () m ()
|
||||||
-- let ncq1Dir = prefix </> "ncq"
|
checkNCQ1 = do
|
||||||
-- ncq1Here <- Sy.doesDirectoryExist ncq1Dir
|
let ncq1Dir = prefix </> "ncq"
|
||||||
-- when ncq1Here do
|
ncq1Here <- Sy.doesDirectoryExist ncq1Dir
|
||||||
-- notice $ yellow "found NCQv1 storage"
|
when ncq1Here do
|
||||||
-- notice $ red "Run" <+> "hbs2-peer migrate" <+> pretty prefix
|
notice $ yellow "found NCQv1 storage"
|
||||||
-- <> line
|
notice $ red "Run" <+> "hbs2-peer migrate" <+> pretty prefix
|
||||||
-- <> "to migrate the storage to a new version"
|
<> line
|
||||||
-- notice $ "You may also: backup" <+> pretty ncq1Dir <+> "or move it or remove permanently"
|
<> "to migrate the storage to a new version"
|
||||||
-- liftIO exitFailure
|
notice $ "You may also: backup" <+> pretty ncq1Dir <+> "or move it or remove permanently"
|
||||||
|
liftIO exitFailure
|
||||||
|
|
||||||
|
|
|
@ -204,7 +204,7 @@ ncqTryLoadState :: forall m. MonadUnliftIO m
|
||||||
=> NCQStorage
|
=> NCQStorage
|
||||||
-> m ()
|
-> m ()
|
||||||
|
|
||||||
ncqTryLoadState me@NCQStorage{..} = do
|
ncqTryLoadState me@NCQStorage{..} = withSem ncqServiceSem do
|
||||||
|
|
||||||
stateFiles <- ncqListFilesBy me ( List.isPrefixOf "s-" )
|
stateFiles <- ncqListFilesBy me ( List.isPrefixOf "s-" )
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ ncqStorageRun ncq@NCQStorage{..} = withSem ncqRunSem $ flip runContT pure do
|
||||||
-- debug $ "NOT FOUND SHIT" <+> pretty h
|
-- debug $ "NOT FOUND SHIT" <+> pretty h
|
||||||
answer Nothing >> exit ()
|
answer Nothing >> exit ()
|
||||||
|
|
||||||
spawnActivity measureWPS
|
-- spawnActivity measureWPS
|
||||||
|
|
||||||
spawnActivity (ncqStateUpdateLoop ncq)
|
spawnActivity (ncqStateUpdateLoop ncq)
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ ncqStorageRun ncq@NCQStorage{..} = withSem ncqRunSem $ flip runContT pure do
|
||||||
ncqSweepFiles ncq
|
ncqSweepFiles ncq
|
||||||
next lsB
|
next lsB
|
||||||
|
|
||||||
spawnActivity $ postponed 10 $ compactLoop 10 30 do
|
spawnActivity $ postponed 20 $ compactLoop 10 30 do
|
||||||
ncqIndexCompactStep ncq
|
ncqIndexCompactStep ncq
|
||||||
|
|
||||||
spawnActivity $ postponed 20 $ compactLoop 10 60 do
|
spawnActivity $ postponed 20 $ compactLoop 10 60 do
|
||||||
|
@ -234,6 +234,7 @@ ncqStorageRun ncq@NCQStorage{..} = withSem ncqRunSem $ flip runContT pure do
|
||||||
link a
|
link a
|
||||||
pure a
|
pure a
|
||||||
|
|
||||||
|
measureWPS :: m ()
|
||||||
measureWPS = void $ flip fix Nothing \loop -> \case
|
measureWPS = void $ flip fix Nothing \loop -> \case
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
w <- readTVarIO ncqWrites
|
w <- readTVarIO ncqWrites
|
||||||
|
|
|
@ -331,6 +331,12 @@ ncq3Tests = do
|
||||||
|
|
||||||
race (pause @'Seconds (realToFrac seconds) >> ncqStorageStop sto) $ forever do
|
race (pause @'Seconds (realToFrac seconds) >> ncqStorageStop sto) $ forever do
|
||||||
n <- liftIO $ uniformRM (1, 256*1024) g
|
n <- liftIO $ uniformRM (1, 256*1024) g
|
||||||
|
|
||||||
|
p <- liftIO $ uniformRM (0.00, 1.00) g
|
||||||
|
|
||||||
|
when (p < 0.11 ) do
|
||||||
|
none
|
||||||
|
|
||||||
s <- liftIO $ genRandomBS g n
|
s <- liftIO $ genRandomBS g n
|
||||||
h <- ncqPutBS sto (Just B) Nothing s
|
h <- ncqPutBS sto (Just B) Nothing s
|
||||||
liftIO $ appendFile writtenLog (show (pretty h <+> pretty n <> line))
|
liftIO $ appendFile writtenLog (show (pretty h <+> pretty n <> line))
|
||||||
|
@ -347,11 +353,11 @@ ncq3Tests = do
|
||||||
|
|
||||||
self <- liftIO getExecutablePath
|
self <- liftIO getExecutablePath
|
||||||
|
|
||||||
|
replicateM_ 5 do
|
||||||
|
|
||||||
flip runContT pure do
|
flip runContT pure do
|
||||||
|
|
||||||
p <- liftIO $ uniformM @Word32 g
|
let path = path0
|
||||||
|
|
||||||
let path = path0 </> show p
|
|
||||||
|
|
||||||
p <- ContT $ withProcessWait (proc self ["debug off"
|
p <- ContT $ withProcessWait (proc self ["debug off"
|
||||||
, "and"
|
, "and"
|
||||||
|
|
|
@ -77,6 +77,10 @@ import Streaming.Prelude qualified as S
|
||||||
|
|
||||||
{-HLINT ignore "Functor law"-}
|
{-HLINT ignore "Functor law"-}
|
||||||
|
|
||||||
|
data AbortException = AbortException
|
||||||
|
deriving stock (Show, Typeable)
|
||||||
|
|
||||||
|
instance Exception AbortException
|
||||||
|
|
||||||
data EnduranceFSM =
|
data EnduranceFSM =
|
||||||
EnduranceIdle
|
EnduranceIdle
|
||||||
|
@ -89,6 +93,7 @@ data EnduranceFSM =
|
||||||
| EnduranceDelRef
|
| EnduranceDelRef
|
||||||
| EnduranceStorm
|
| EnduranceStorm
|
||||||
| EnduranceCalm
|
| EnduranceCalm
|
||||||
|
| EnduranceAbort
|
||||||
| EnduranceStop
|
| EnduranceStop
|
||||||
|
|
||||||
buildCDF :: [(s, Double)] -> (V.Vector s, U.Vector Double)
|
buildCDF :: [(s, Double)] -> (V.Vector s, U.Vector Double)
|
||||||
|
@ -274,6 +279,7 @@ ncq3EnduranceTestInProc = do
|
||||||
wMaxBlk <- int <$> lookupValueDef (mkInt 262144) "w:blk"
|
wMaxBlk <- int <$> lookupValueDef (mkInt 262144) "w:blk"
|
||||||
wStormMin <- dbl <$> lookupValueDef (mkDouble 1.00) "w:stormmin"
|
wStormMin <- dbl <$> lookupValueDef (mkDouble 1.00) "w:stormmin"
|
||||||
wStormMax <- dbl <$> lookupValueDef (mkDouble 60.00) "w:stormmax"
|
wStormMax <- dbl <$> lookupValueDef (mkDouble 60.00) "w:stormmax"
|
||||||
|
wAbort <- dbl <$> lookupValueDef (mkDouble 0.001) "w:abort"
|
||||||
|
|
||||||
runTest \TestEnv{..} -> do
|
runTest \TestEnv{..} -> do
|
||||||
g <- liftIO $ MWC.createSystemRandom
|
g <- liftIO $ MWC.createSystemRandom
|
||||||
|
@ -302,11 +308,12 @@ ncq3EnduranceTestInProc = do
|
||||||
, (EnduranceDelRef, wDelRef)
|
, (EnduranceDelRef, wDelRef)
|
||||||
, (EnduranceStorm, wStorm)
|
, (EnduranceStorm, wStorm)
|
||||||
, (EnduranceCalm, wCalm)
|
, (EnduranceCalm, wCalm)
|
||||||
|
, (EnduranceAbort, wAbort)
|
||||||
]
|
]
|
||||||
|
|
||||||
let dist = buildCDF actions -- ← подготовили один раз
|
let dist = buildCDF actions -- ← подготовили один раз
|
||||||
|
|
||||||
fix \recover -> handle (\(e :: IOException) -> err (viaShow e) >> pause @'Seconds 1 >> recover) do
|
fix \recover -> handleAny (\e -> err (viaShow e) >> pause @'Seconds 1 >> recover) do
|
||||||
|
|
||||||
flip runContT pure do
|
flip runContT pure do
|
||||||
|
|
||||||
|
@ -437,6 +444,11 @@ ncq3EnduranceTestInProc = do
|
||||||
pause @'Seconds (realToFrac n)
|
pause @'Seconds (realToFrac n)
|
||||||
getNextState >>= loop
|
getNextState >>= loop
|
||||||
|
|
||||||
|
EnduranceAbort -> do
|
||||||
|
debug $ red "EnduranceAbort"
|
||||||
|
pause @'Seconds 0.01
|
||||||
|
throwIO AbortException
|
||||||
|
|
||||||
EnduranceStorm -> do
|
EnduranceStorm -> do
|
||||||
now <- getTimeCoarse
|
now <- getTimeCoarse
|
||||||
relaxTill <- readTVarIO trelaxTill
|
relaxTill <- readTVarIO trelaxTill
|
||||||
|
|
Loading…
Reference in New Issue