-
Notifications
You must be signed in to change notification settings - Fork 46
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
Elimination of all ByteBuffer Usage (for Java 8) #132
Comments
* removing the use of Bytebuffers to access native memory to improve performance Co-authored-by: Ramy Fakhoury <[email protected]>
…Rebase. (#156) * MM_NEXT_STEP_01 squashed commits: Removing ValueUtils interface, making it an implementation. Creating triangle of Slices. * Elimination of all ByteBuffer Usage (for Java 8) #132 (#151) * removing the use of Bytebuffers to access native memory to improve performance Co-authored-by: Ramy Fakhoury <[email protected]> * MM_NEXT_STEP_01 squashed commits: Removing ValueUtils interface, making it an implementation. Creating triangle of Slices. Co-authored-by: Ramy Fakhoury <[email protected]> Co-authored-by: Ramy Fakhoury <[email protected]>
It doesn't seem that the doc comments on the relevant code are changed in sync with the changes. For instance, |
Hi @dynaxis , Thanks for your comment. Here is the comment/documentation about
Indeed, a new How would you suggest to rephrase the documentation so it is more clear? |
Hi @sanastas, The doc comment is a little bit misleading in the following points, IMHO:
So my suggestion for a better wording is as follows: public interface OakUnsafeDirectBuffer {
/**
* Returns a ByteBuffer wrapping the underlying memory segment backing this buffer.
*
* Since a new ByteBuffer instance is returned on each invocation of this method, it's absolutely safe
* to modify the state of the ByteBuffer including its byte order, position, and limit.
*
* Note that the buffer mode of the returned ByteBuffer might be read-only,
* depending on whether this buffer has been casted from OakScopedReadBuffer or OakScopedWriteBuffer.
*
* @return a ByteBuffer wrapping the underlying memory segment
*/
ByteBuffer getByteBuffer(); UPDATE: I also found that the In my opinion, |
Hi @dynaxis , Thank you for your reply. Your suggestion makes sense. Although I would stress that this buffers brings you no protection from possible concurrent update of the same underlying memory from different
As for read-only buffer, while creating the buffer inside @dynaxis , as the change is quite easy, would you be able to provide a PR, so I will review and merge to master? So you will join our small but powerful contributors community? :) |
Dear @sanastas, I agree with your additions to the doc comment, though I might suggest a bit of rewording. Also it's good to issue a PR myself. Anyway, I'll prepare a PR soon and come back. |
Thank you very much @dynaxis , do as you think is the best way! Very much appreciated! |
@dynaxis , thank you so much! Review done. Code looks good, just one comment left! |
Base all of the off-heap memory management on unsafe allocation and access, without ByteBuffer intermediate layer (in addition to existing memory management). The reason for the change is the possibility to gain better throughput without spending CPU cycles and memory on ByteBuffer internals.
That means a new memory manager to be based on using addresses instead of ByteBuffers and allocating the address from unsafe:
Unsafe().allocateMemory(size);
That requires a significant code writing: new (alternative) Block, BlockPool, MemoryAllocator, MemoryManager etc.
For more explanations feel free to add questions in this issue.
The text was updated successfully, but these errors were encountered: