tuning tree params

This commit is contained in:
Dmitry Zuikov 2024-02-07 17:13:29 +03:00
parent 656933720b
commit f049f36d42
4 changed files with 15 additions and 5 deletions

View File

@ -111,3 +111,12 @@ defInterBlockDelay :: Timeout 'Seconds
defInterBlockDelay = 0.0085
defHashListChunk :: Integral a => a
defHashListChunk = 1024
{-# INLINE defHashListChunk #-}
defTreeChildNum :: Integral a => a
defTreeChildNum = 256
{-# INLINE defTreeChildNum #-}

View File

@ -21,6 +21,7 @@ import HBS2.Net.Proto.Types
import HBS2.Storage.Operations.Class
import HBS2.Storage.Operations.ByteString
import HBS2.Storage(Storage(..))
import HBS2.Defaults
import Data.ByteArray.Hash qualified as BA
@ -255,7 +256,7 @@ instance ( MonadIO m
let hashes = catMaybes hashes'
-- -- FIXME: handle-hardcode
let pt = toPTree (MaxSize 4096) (MaxNum 256) hashes -- FIXME: settings
let pt = toPTree (MaxSize defHashListChunk) (MaxNum defTreeChildNum) hashes -- FIXME: settings
-- FIXME: this-might-not-be-true
result <- runWriterT $ makeMerkle 0 pt $ \(hx,mt,bss) -> do

View File

@ -41,7 +41,7 @@ instance (MonadIO m, h ~ HbSync, Storage s h ByteString m) => MerkleWriter ByteS
& S.toList_
-- FIXME: handle-hardcode
let pt = toPTree (MaxSize 4096) (MaxNum 256) hashes -- FIXME: settings
let pt = toPTree (MaxSize defHashListChunk) (MaxNum defTreeChildNum) hashes -- FIXME: settings
makeMerkle 0 pt $ \(_,_,bss) -> do
void $ putBlock sto bss

View File

@ -30,7 +30,7 @@ import Streaming qualified as S
import System.IO
pieces :: Integral a => a
pieces = 4096
pieces = defHashListChunk
-- FIXME: to-remove-in-a-sake-of-operations-class
class MonadIO m => SimpleStorageExtra a m where
@ -89,7 +89,7 @@ instance MonadIO m => SimpleStorageExtra (S.Stream (S.Of ByteString) m ()) m whe
instance MonadIO m => SimpleStorageExtra [HashRef] m where
putAsMerkle ss hashes = do
let pt = toPTree (MaxSize pieces) (MaxNum 256) hashes -- FIXME: settings
let pt = toPTree (MaxSize pieces) (MaxNum defTreeChildNum) hashes -- FIXME: settings
root <- makeMerkle 0 pt $ \(_,_,bs) -> void $ putBlock ss bs
@ -105,7 +105,7 @@ instance MonadIO m => SimpleStorageExtra ByteString m where
& S.map (HashRef . hashObject)
& S.toList_
let pt = toPTree (MaxSize pieces) (MaxNum 256) hashes -- FIXME: settings
let pt = toPTree (MaxSize pieces) (MaxNum defTreeChildNum) hashes -- FIXME: settings
root <- makeMerkle 0 pt $ \(_,_,bss) -> void $ putBlock ss bss