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

Optimize array allocation by JsonStringEncoder #712

Closed
cowtowncoder opened this issue Aug 18, 2021 · 1 comment
Closed

Optimize array allocation by JsonStringEncoder #712

cowtowncoder opened this issue Aug 18, 2021 · 1 comment
Milestone

Comments

@cowtowncoder
Copy link
Member

Looks like encoding methods in JsonStringEncoder were simplified in 2.10 to reduce likelihood of strange concurrency challenges (basically removing use of ThreadLocal). This was deemed not to be particularly performance/memory sensitive since methods are only used from one place, SerializedString.

One aspect that seems sub-optimal is the eager allocation of initial char[] / byte[] output buffer: 120 chars / 200 bytes.
Since the values most likely encoded are names, which tend to be a bit shorter, this is bit wasteful.
It may or may not be an actual concern for Jackson but seems like something easy enough to fix.

A simple change would be to shrink default lengths to something like 30 / 60 (for example), but given that we have information on actual input String length, we should be able to do better and calculate buffer that is likely sufficient.

cowtowncoder added a commit that referenced this issue Aug 19, 2021
@cowtowncoder cowtowncoder added this to the 2.13.0 milestone Aug 19, 2021
@cowtowncoder
Copy link
Member Author

Improved this properly for 2.13; 2.11/2.12 just get lower starting lengths (which should likely reduce overhead anyway), if new patch releases are made.

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

No branches or pull requests

1 participant