Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exp: plumbling/hasher, Add ObjectHasher and ImmutableHash #920

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Commits on Nov 10, 2023

  1. plumbing: format/config, Add ErrInvalidObjectFormat

    Signed-off-by: Paulo Gomes <paulo.gomes@suse.com>
    pjbgf committed Nov 10, 2023
    Configuration menu
    Copy the full SHA
    13f3057 View commit details
    Browse the repository at this point in the history
  2. plumbing: hash, Add SHA1 and SHA256 constants

    Signed-off-by: Paulo Gomes <paulo.gomes@suse.com>
    pjbgf committed Nov 10, 2023
    Configuration menu
    Copy the full SHA
    7f458e0 View commit details
    Browse the repository at this point in the history
  3. plumbing: hash, Add ErrUnsupportedHashFunction

    Signed-off-by: Paulo Gomes <paulo.gomes@suse.com>
    pjbgf committed Nov 10, 2023
    Configuration menu
    Copy the full SHA
    764559b View commit details
    Browse the repository at this point in the history
  4. plumbing: hash, Add hash.FromObjectFormat

    The support for SHA256 will require the mapping between ObjectFormat and the
    correct hash.Hash to be used.
    
    Signed-off-by: Paulo Gomes <paulo.gomes@suse.com>
    pjbgf committed Nov 10, 2023
    Configuration menu
    Copy the full SHA
    6d5a79c View commit details
    Browse the repository at this point in the history
  5. exp: Introduces an experimental package

    The new exp package will hold only experimental code, which may eventually
    make its way to other parts of go-git.
    One example of how it would be used is to support the breaking up of
    changes required for things like SHA256. That feature would require
    several packages to be changed, and introducing such changes to plumbing
    in one go would be too disruptive.
    
    The new changes would now be staged in the new package, and as they
    mature they would be either moved into their target destination
    (e.g. plumbing/hash), or removed if no longer needed.
    
    As per caveat on the documentation, this package API may introduce
    breaking changes to its subpackages in minor go-git releases,
    therefore beware when depending on them.
    
    Signed-off-by: Paulo Gomes <paulo.gomes@suse.com>
    pjbgf committed Nov 10, 2023
    Configuration menu
    Copy the full SHA
    c4a9ef1 View commit details
    Browse the repository at this point in the history
  6. exp: plumbling/hasher, Add ObjectHasher and ImmutableHash

    The introduction of both new types are a stepping stone to enable
    SHA256 support concurrently - without the need for a build tag.
    
    ImmutableHash provides a way to represent varied sized hashes (for SHA1
    or SHA256) with a single type, while keeping similar performance of the
    existing plumbing.Hash.
    
    The names were picked in order to provide a clearer distinction on what
    they do. ImmutableHash is the result of a hash operation and can't be
    changed once calculated. ObjectHasher, adds the Git object header before
    a normal hash operation that hash.Hash or plumbing/hash.Hash do.
    
    The performance results shows that SHA1 operations could be slower,
    however for SHA256 it can be over 3 times faster:
    
    ~Hasher/hasher-sha1-100B-16         	            2202226	     574.7 ns/op	 174.00 MB/s     272 B/op     7 allocs/op
    ~Hasher/objecthash-sha1-100B-16     	            1511851	     772.6 ns/op	 129.43 MB/s     272 B/op     9 allocs/op
    ~Hasher/objecthash-sha256-100B-16   	            5057584	     247.4 ns/op	 404.21 MB/s      96 B/op     7 allocs/op
    ~Hasher/hasher-sha1-5000B-16        	              96476	     12523 ns/op	 399.25 MB/s    5536 B/op     7 allocs/op
    ~Hasher/objecthash-sha1-5000B-16    	             105376	     10983 ns/op	 455.27 MB/s     272 B/op     9 allocs/op
    ~Hasher/objecthash-sha256-5000B-16  	             420741	      2828 ns/op	1767.77 MB/s      96 B/op     7 allocs/op
    ~HashFromHex/hasher-parse-sha1-valid-16         	23243548     64.65 ns/op	 618.69 MB/s      48 B/op     1 allocs/op
    ~HashFromHex/objecthash-fromhex-sha1-valid-16   	18120699     79.62 ns/op	 502.36 MB/s      72 B/op     2 allocs/op
    ~HashFromHex/objecthash-fromhex-sha256-valid-16 	 8969871    124.2 ns/op	     515.22 MB/s      96 B/op     2 allocs/op
    
    Signed-off-by: Paulo Gomes <paulo.gomes@suse.com>
    pjbgf committed Nov 10, 2023
    Configuration menu
    Copy the full SHA
    328f9ea View commit details
    Browse the repository at this point in the history