Absolute index bulk put/get byte operations on ByteBuffer
Martin Thompson
mjpt777 at gmail.com
Wed Sep 12 12:07:42 UTC 2018
On Tue, 11 Sep 2018 at 05:13, Stuart Marks <stuart.marks at oracle.com> wrote:
> Yes, I think it's reasonable to consider fixing some immediate needs
> instead of
> waiting for Panama. I'm confident there are some improvements we can make
> in the
> near term, and we can manage coordination with Panama.
>
> I don't think you need to worry about Unsafe going away before there is a
> suitable replacement.
>
> On that note, what kinds of issues have you run into trying to migrate
> away from
> Unsafe? There's the absolute indexing, and there's also the 2GB limit as
> Alan
> mentioned. I'm certain there are others.
>
> What I'd like to avoid is a situation where we add, say, absolute indexing
> to
> buffers, and then have the response be "thanks, that helps a little, but
> it
> really doesn't solve the problem without X, Y, and Z." I'd like to know
> more
> about X, Y, and Z.
>
Thanks Stuart,
This is a good question. Yes in addition to what you mentioned there my be
other things. I've had a quick scan and major things can be covered by Var
Handles. However we still have limited production experience with Var
Handles due to the lack of adoption of Java 9 and 10 as yet.
The common thing I can find is Unsafe.setMemory which is mostly used for
zero'ing out a buffer. Doing this via the existing API is a bit nasty
requiring a loop.
People often assume Unsafe is use to update buffers to avoid bounds checks
and avoid the indirection. This is a minor reason. The main reason is to
avoid allocation and the ability to use buffers in a concurrent fashion.
Any future design should keep this in mind.
Regards,
Martin...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20180912/982b817c/attachment.html>
More information about the nio-dev
mailing list