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

Improve Code.toBytes() performance #281

Open
OlegMazurov opened this issue Aug 29, 2024 · 1 comment
Open

Improve Code.toBytes() performance #281

OlegMazurov opened this issue Aug 29, 2024 · 1 comment
Labels
Performance Issues related to performance concerns.

Comments

@OlegMazurov
Copy link

Problem

Code.toBytes() creates an instance of ByteArrayOutputStream() which in turn creates default byte[32] in its constructor.
Every time the current capacity is exhausted the underlying array is doubled in size and copied over, which has visible performance impact. That could be avoided by properly sizing the instance at creation.

Solution

Either a better default size could be used universally (256? 512?) or the actual size of item could be computed and passed to ByteArrayOutputStream(int). Performance effect of either solution should be evaluated.

Alternatives

No response

@OlegMazurov OlegMazurov added the Performance Issues related to performance concerns. label Aug 29, 2024
@jasperpotts
Copy link
Member

I wonder if doing a measureRecord() is worth performance cost wise🧐 it then we would know exact size to allocate byte[] then?

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

No branches or pull requests

2 participants