Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On a trivial benchmark (commiting a view with a lot of new key/values), this series of patch introduce a 20-times speed-up (from around 60 seconds to around 3 seconds).
After some profiling, it looks like most of the time was spent on
memcpy
andto_hex
. To remove unrequired copy/conversion, this series of patch abstract the signature ofHash.digest
fromCstruct.t -> t
to'a Type.t -> 'a -> t
.Our trivial benchmark is based on
irmin-mem
andIrmin.Contents.Cstruct
. Half of the speed-up comes from the serialisation of leafs (no encoding to hexadecimal anymore). The rest of the speed is gained from the 'hashing' of nodes (no intermediate JSON representation).Further optimisation seems doable, but these simple one looks like the only one that requires some change in the functor signatures.
Note: for program where readability is more a matter than performances, it is still possible to dump hexadecimal on disk rather than raw bytes. This only requires an alternative implementation of
Irmin.Contents.Cstruct
.