Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

lukecotter
Copy link
Contributor

@lukecotter lukecotter commented Aug 5, 2025

performance improvement for hashBlob

50k Promises (Promise.all)

before (ms) after (ms)
Buffer 3822.918 1872.766
string 4072.27 2300

Buffer = 104.13% faster
string = 77.06% faster

50k Promises sequential

before (ms) after (ms)
Buffer 2821.764 1811.034
string 2509.682 1790

Buffer = 55.81 % faster
string = 40.21 % faster

The numbers show variation in the tests, but the trend is in the right direction!

  • hashObject return a Uint8Array, no need to create another.
  • hashBlob skip wrapping object in Buffer if it is already a Uint8Array
  • GitObject.wrap : Create only 1 buffer instead of 3

@lukecotter lukecotter changed the title perf: improve hashblob performance up to 100% perf: improve hashblob performance up to 100% faster Aug 5, 2025
Copy link
Member

@jcubic jcubic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@jcubic jcubic merged commit a8551a8 into isomorphic-git:main Aug 6, 2025
10 of 14 checks passed
@isomorphic-git-bot
Copy link
Member

🎉 This PR is included in version 1.32.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lukecotter lukecotter deleted the perf-hashblob branch August 6, 2025 23:25
@lukecotter
Copy link
Contributor Author

@jcubic

I was thinking about this and I think the change in hashBlob should probably have been this to be safer.


if (typeof object === 'string') {
      object = Buffer.from(object, 'utf8')
    } else if (!(object instanceof Uint8Array)) {
      object = Buffer.from(object)
    }

That is close to the original and will support more types but still skip wrapping for Buffer and Uint8Array. Given that the only types that should be provided are string and uint8array or subclasses it's probably not a big deal.

@jcubic
Copy link
Member

jcubic commented Aug 7, 2025

If you think this is better, you will need to create another PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants