Jam/Cue: Tuning

This commit is contained in:
Benjamin Summers 2019-07-04 15:40:36 -07:00
parent a7bbc9364c
commit 0d057747cc
2 changed files with 8 additions and 10 deletions

View File

@ -106,9 +106,11 @@ type Bits = Vector Bool
doGet :: Get a -> ByteString -> Either DecodeExn a doGet :: Get a -> ByteString -> Either DecodeExn a
doGet m bs = doGet m bs =
unsafePerformIO $ try $ BS.unsafeUseAsCStringLen bs \(ptr, len) -> do unsafePerformIO $ try $ BS.unsafeUseAsCStringLen bs \(ptr, len) -> do
-- traceM ("cue size: " <> show (length bs `div` 10))
let endPtr = ptr `plusPtr` len let endPtr = ptr `plusPtr` len
tbl <- H.newSized (length bs `div` 10) let sz = max 50
$ min 10_000_000
$ length bs `div` 6
tbl <- H.newSized sz
GetResult _ r <- runGet m endPtr tbl (S (castPtr ptr) 0 0) GetResult _ r <- runGet m endPtr tbl (S (castPtr ptr) 0 0)
pure r pure r

View File

@ -339,11 +339,9 @@ jamWordSz (W# w) = 1 + 2*(W# preW) + (W# atmW)
compress :: FatNoun -> IO (Word, H.CuckooHashTable Word Word) compress :: FatNoun -> IO (Word, H.CuckooHashTable Word Word)
compress top = do compress top = do
-- traceM "<compress>" let sz = max 50
let sz = 10 ^ (floor $ logBase 600 (fromIntegral $ fatSize top)) $ min 10_000_000
$ 2 * (10 ^ (floor $ logBase 600 (fromIntegral $ fatSize top)))
-- traceM ("inp(" <> show (fatSize top) <> ")")
-- traceM ("sz(" <> show sz <> ")")
nodes :: H.BasicHashTable FatNoun Word <- H.newSized sz nodes :: H.BasicHashTable FatNoun Word <- H.newSized sz
backs :: H.CuckooHashTable Word Word <- H.newSized sz backs :: H.CuckooHashTable Word Word <- H.newSized sz
@ -357,7 +355,6 @@ compress top = do
!tSz <- go (pos+2+hSz) t !tSz <- go (pos+2+hSz) t
pure (2+hSz+tSz) pure (2+hSz+tSz)
go :: Word -> FatNoun -> IO Word go :: Word -> FatNoun -> IO Word
go p inp = do go p inp = do
H.lookup nodes inp >>= \case H.lookup nodes inp >>= \case
@ -375,8 +372,7 @@ compress top = do
_ -> noRef _ -> noRef
res <- go 0 top res <- go 0 top
-- traceM "</compress>"
-- print res
pure (res, backs) pure (res, backs)