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

txscript: allow script builder capacity to be specified #1954

Merged
merged 1 commit into from
Feb 28, 2023

Conversation

guggero
Copy link
Collaborator

@guggero guggero commented Feb 27, 2023

The default script builder allocates 500 bytes of memory for each script. That is quite large for most applications and therefore wastes a lot of memory when only small scripts are created. To avoid breaking backward compatibility, we add a new functional option to the NewScriptBuilder function that allows the user to specify the initial allocation size.

cc @Roasbeef, @Crypt-iQ.

The default script builder allocates 500 bytes of memory for each
script. That is quite large for most applications and therefore wastes a
lot of memory when only small scripts are created.
To avoid breaking backward compatibility, we add a new functional option
to the NewScriptBuilder function that allows the user to specify the
initial allocation size.
@coveralls
Copy link

Pull Request Test Coverage Report for Build 4281966818

  • 15 of 15 (100.0%) changed or added relevant lines in 1 file are covered.
  • 38 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.05%) to 55.222%

Files with Coverage Reduction New Missed Lines %
connmgr/connmanager.go 2 86.62%
wire/msgaddrv2.go 16 51.72%
wire/netaddressv2.go 20 74.45%
Totals Coverage Status
Change from base Build 4163994991: -0.05%
Covered Lines: 26619
Relevant Lines: 48204

💛 - Coveralls

Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

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

LGTM 🦖

txscript/scriptbuilder_test.go Show resolved Hide resolved
Copy link
Collaborator

@Crypt-iQ Crypt-iQ left a comment

Choose a reason for hiding this comment

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

nice optimization 🔬

@guggero guggero merged commit 3833196 into btcsuite:master Feb 28, 2023
@guggero guggero deleted the script-builder-alloc branch February 28, 2023 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants