cache the serialization of a Key
authorJoey Hess <joeyh@joeyh.name>
Fri, 22 Nov 2019 20:24:04 +0000 (16:24 -0400)
committerJoey Hess <joeyh@joeyh.name>
Fri, 22 Nov 2019 21:49:16 +0000 (17:49 -0400)
commit81d402216d955260fd4744ab73031b4c693d6254
treeca1f150a09fbf46f1966f760e4854cf3da587acc
parente296637737eb409fd55b5fb1b09c959a793b0d09
cache the serialization of a Key

This will speed up the common case where a Key is deserialized from
disk, but is then serialized to build eg, the path to the annex object.

Previously attempted in 4536c93bb2ecf114ab711beac33fa358facd6985
and reverted in 96aba8eff7597898f53bfbab5865ff30a927d355.
The problems mentioned in the latter commit are addressed now:

Read/Show of KeyData is backwards-compatible with Read/Show of Key from before
this change, so Types.Distribution will keep working.

The Eq instance is fixed.

Also, Key has smart constructors, avoiding needing to remember to update
the cached serialization.

Used git-annex benchmark:
  find is 7% faster
  whereis is 3% faster
  get when all files are already present is 5% faster
Generally, the benchmarks are running 0.1 seconds faster per 2000 files,
on a ram disk in my laptop.
53 files changed:
Annex/Content.hs
Annex/Content/LowLevel.hs
Annex/DirHashes.hs
Annex/Export.hs
Annex/Import.hs
Annex/Locations.hs
Annex/Transfer.hs
Annex/VariantFile.hs
Assistant/DeleteRemote.hs
Assistant/Threads/TransferScanner.hs
Assistant/TransferQueue.hs
Assistant/Unused.hs
Assistant/Upgrade.hs
Backend.hs
Backend/Hash.hs
Backend/URL.hs
Backend/WORM.hs
CHANGELOG
Command/AddUrl.hs
Command/Find.hs
Command/FromKey.hs
Command/Fsck.hs
Command/Info.hs
Command/MatchExpression.hs
Command/Migrate.hs
Command/RegisterUrl.hs
Command/SendKey.hs
Command/SetKey.hs
Command/Smudge.hs
Command/TestRemote.hs
Command/TransferInfo.hs
Crypto.hs
Database/Benchmark.hs
Key.hs
Limit.hs
Logs/Transfer.hs
Messages/Progress.hs
Remote/BitTorrent.hs
Remote/External.hs
Remote/External/Types.hs
Remote/Git.hs
Remote/GitLFS.hs
Remote/Glacier.hs
Remote/Helper/Chunked.hs
Remote/Helper/ExportImport.hs
Remote/S3.hs
Remote/Web.hs
Types/Distribution.hs
Types/Key.hs
Types/Transfer.hs
Upgrade/V1.hs
Utility/Hash.hs
templates/dashboard/transfers.hamlet