convert Key to ShortByteString
This adds the overhead of a copy when serializing and deserializing keys. I have not benchmarked much, but runtimes seem barely changed at all by that. When a lot of keys are in memory, it improves memory use. And, it prevents keys sometimes getting PINNED in memory and failing to GC, which is a problem ByteString has sometimes. In particular, git-annex sync from a borg special remote had that problem and this improved its memory use by a large amount. Sponsored-by: Shae Erisson on Patreon
This commit is contained in:
parent
012b71e471
commit
19e78816f0
15 changed files with 65 additions and 36 deletions
|
@ -18,6 +18,7 @@ import qualified Types.Remote as Remote
|
|||
import Messages
|
||||
|
||||
import Data.Maybe
|
||||
import qualified Data.ByteString.Short as S (fromShort, toShort)
|
||||
|
||||
-- From a sha pointing to the content of a file to the key
|
||||
-- to use to export it. When the file is annexed, it's the annexed key.
|
||||
|
@ -39,7 +40,7 @@ exportKey sha = mk <$> catKey sha
|
|||
-- only checksum the content.
|
||||
gitShaKey :: Git.Sha -> Key
|
||||
gitShaKey (Git.Ref s) = mkKey $ \kd -> kd
|
||||
{ keyName = s
|
||||
{ keyName = S.toShort s
|
||||
, keyVariety = OtherKey "GIT"
|
||||
}
|
||||
|
||||
|
@ -47,7 +48,7 @@ gitShaKey (Git.Ref s) = mkKey $ \kd -> kd
|
|||
keyGitSha :: Key -> Maybe Git.Sha
|
||||
keyGitSha k
|
||||
| fromKey keyVariety k == OtherKey "GIT" =
|
||||
Just (Git.Ref (fromKey keyName k))
|
||||
Just (Git.Ref (S.fromShort (fromKey keyName k)))
|
||||
| otherwise = Nothing
|
||||
|
||||
-- Is a key storing a git sha, and not used for an annexed file?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue