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

Option for ByteBufferOutput#require to allocate a heap buffer #161

Closed
brianfromoregon opened this issue Jan 2, 2014 · 4 comments
Closed

Comments

@brianfromoregon
Copy link

The user may construct a ByteBufferOutput with a heap buffer and expect future resizes to also create heap buffers, but today it always uses direct buffers for resize. What do you think of exposing an option for user to choose, or perhaps internally making the decision based on the type of buffer used at construction.

@romix
Copy link
Collaborator

romix commented Jan 2, 2014

Thanks for this report. I think it is a good idea. I simply overlooked that I always allocate direct buffers, even if the original one was on heap. I'll fix this part soon and will check the type of buffer used at construction when resizing.

Regarding a dedicated option (e.g. a constructor argument), I'm not sure. If you are going to use on-heap buffers, but want Kryo to allocate them for you, why don't you simply use byte arrays for this purpose? It would be also much faster.

But I'm open for suggestions. If you present a convincing use-case for such an option, I could include it.

@brianfromoregon
Copy link
Author

Nice! Your fix will give user enough flexibility, so another option is not needed imo.

romix added a commit that referenced this issue Jan 2, 2014
@romix romix closed this as completed Jan 2, 2014
@brianfromoregon
Copy link
Author

Sweet. btw if you have any pointers to articles/benchmarks supporting your point about byte[] being faster than heap bytebuffers I'd love to read more about it.

@NathanSweet
Copy link
Member

Interesting trivia, with HotSpot direct ByteBuffers become slower as soon
as you use a single non-direct ByteBuffer (because an interface with only
one implementation is optimized).

On Thu, Jan 2, 2014 at 9:36 PM, Brian Harris [email protected]:

Sweet. btw if you have any pointers to articles/benchmarks supporting your
point about byte[] being faster than heap bytebuffers I'd love to read more
about it.


Reply to this email directly or view it on GitHubhttps://github.com//issues/161#issuecomment-31482413
.

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

No branches or pull requests

3 participants