libsv / go-bt

The go-to Bitcoin Transaction (BT) Go library.
https://pkg.go.dev/mod/github.com/libsv/go-bt
ISC License
67 stars 26 forks source link

Malloc and performance optimisations for Clone TX and toBytesHelper #150

Closed icellan closed 1 year ago

icellan commented 1 year ago

Malloc is expensive and this pull request removes all mallocs from toBytesHelper used by ToBytes() and ToExtendedBytes(). This makes it much faster to get the bytes of a transaction when you are doing millions of transactions per second.

I also optimized Clone() of tx, which is used in various places, for instance when validating signatures.

codecov-commenter commented 1 year ago

Codecov Report

Patch coverage: 94.44% and project coverage change: +0.02 :tada:

Comparison is base (79b6991) 80.61% compared to head (1999018) 80.64%.

:exclamation: Current head 1999018 differs from pull request most recent head 8281ffe. Consider uploading reports for the commit 8281ffe to get more accurate results

:mega: This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #150 +/- ## ========================================== + Coverage 80.61% 80.64% +0.02% ========================================== Files 38 38 Lines 4112 4179 +67 ========================================== + Hits 3315 3370 +55 - Misses 546 559 +13 + Partials 251 250 -1 ``` | [Impacted Files](https://codecov.io/gh/libsv/go-bt/pull/150?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=libsv) | Coverage Δ | | |---|---|---| | [tx.go](https://codecov.io/gh/libsv/go-bt/pull/150?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=libsv#diff-dHguZ28=) | `76.45% <90.19%> (+0.37%)` | :arrow_up: | | [input.go](https://codecov.io/gh/libsv/go-bt/pull/150?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=libsv#diff-aW5wdXQuZ28=) | `82.30% <100.00%> (+2.70%)` | :arrow_up: | | [output.go](https://codecov.io/gh/libsv/go-bt/pull/150?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=libsv#diff-b3V0cHV0Lmdv) | `90.00% <100.00%> (+3.04%)` | :arrow_up: | ... and [1 file with indirect coverage changes](https://codecov.io/gh/libsv/go-bt/pull/150/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=libsv) Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=libsv). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=libsv)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

mergify[bot] commented 1 year ago

This pull request looks stale. Feel free to reopen it if you think it's a mistake.