-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1021: Rewrite LedgerDB in-memory representation r=edsko a=edsko I rewrote the in-memory representation of the ledger DB. I just tested it against the Byron proxy running in profiling mode. With the old version of the Ledger DB, the top of the time profile looks like ``` ledgerDbReapply Ouroboros.Storage.LedgerDB.InMemory src/Ouroboros/Storage/LedgerDB/InMemory.hs:361:1-79 15.2 27.9 copyAndFreeze Data.ByteArray.Methods Data/ByteArray/Methods.hs:(237,1)-(240,21) 6.7 1.6 ledgerDbPush Ouroboros.Storage.LedgerDB.InMemory src/Ouroboros/Storage/LedgerDB/InMemory.hs:(332,1)-(356,11) 6.5 21.3 == Cardano.Chain.Common.KeyHash src/Cardano/Chain/Common/KeyHash.hs:31:16-17 4.3 7.0 ref Ouroboros.Storage.LedgerDB.InMemory src/Ouroboros/Storage/LedgerDB/InMemory.hs:(122,1)-(123,17) 4.2 0.0 ``` With the new version: ``` == Cardano.Chain.Common.KeyHash src/Cardano/Chain/Common/KeyHash.hs:31:16-17 29.5 47.3 copyAndFreeze Data.ByteArray.Methods Data/ByteArray/Methods.hs:(237,1)-(240,21) 3.3 1.9 compare Cardano.Chain.Common.KeyHash src/Cardano/Chain/Common/KeyHash.hs:32:16-18 2.9 6.6 lookup Data.Map.Internal Data/Map/Internal.hs:(561,1)-(567,18) 2.8 3.2 deserialiseIncremental Codec.CBOR.Read src/Codec/CBOR/Read.hs:(165,1)-(167,46) 2.8 1.3 ``` where the Ledger DB has disappeared _entirely_ from the profile. That top entry, a whopping 30% of time and 48% of memory allocation spent in `(==)` from `Cardano.Chain.Common.KeyHash` seems like it might benefit from a closer look also! The heap profile with the existing implementation: ![cardano-byron-proxy](https://user-images.githubusercontent.com/935288/64791691-5e83d280-d578-11e9-84bc-bc27186a1905.png) And with the new implementation: ![cardano-byron-proxy](https://user-images.githubusercontent.com/935288/64791703-63e11d00-d578-11e9-8c00-cb3520bd90cc.png) I updated the tests; the hardest part was modifying the tests to figure out which snapshots we store (that makes sense, that is precisely where the new implementation provides weaker guarantees than the old version), and then ran it over 1,000,000 tests, all of which passed. Co-authored-by: Edsko de Vries <[email protected]>
- Loading branch information
Showing
17 changed files
with
724 additions
and
843 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.