-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
HBASE-22802 Avoid temp ByteBuffer allocation in FileIOEngine#read #467
Conversation
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Skimmed. Looks great to me. Get someone closer in to review I'd say. Nice work.
@@ -429,7 +429,9 @@ private void cacheBlockWithWaitInternal(BlockCacheKey cacheKey, Cacheable cached | |||
if (!cacheEnabled) { | |||
return; | |||
} | |||
LOG.trace("Caching key={}, item={}", cacheKey, cachedItem); | |||
if (LOG.isTraceEnabled()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need this if LOG.isTraceEnabled when using this logging form with the '{}' (Internally it does this test).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct
🎊 +1 overall
This message was automatically generated. |
@@ -475,6 +486,32 @@ public static int channelRead(ReadableByteChannel channel, ByteBuffer buf) throw | |||
return (nBytes > 0) ? nBytes : ret; | |||
} | |||
|
|||
public static int fileRead(FileChannel channel, ByteBuffer buf, long offset) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we could make some abstraction between the existed channelRead(...) and the newly introduced fileRead (...) ? Similar with the ByteBufferArray#read & ByteBufferArray#write.. Please take a look.
break; | ||
} | ||
} finally { | ||
buf.limit(originalLimit); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only reset the limit ? should we also reset the position ?
@@ -1086,6 +1087,48 @@ public int read(ReadableByteChannel channel) throws IOException { | |||
return total; | |||
} | |||
|
|||
@Override | |||
public int read(FileChannel channel, long offset) throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should also make the abstraction between MultiByteBuff#read and MultiByteBuff#write ? As said above.
@@ -429,7 +429,9 @@ private void cacheBlockWithWaitInternal(BlockCacheKey cacheKey, Cacheable cached | |||
if (!cacheEnabled) { | |||
return; | |||
} | |||
LOG.trace("Caching key={}, item={}", cacheKey, cachedItem); | |||
if (LOG.isTraceEnabled()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct
@@ -502,8 +504,10 @@ public Cacheable getBlock(BlockCacheKey key, boolean caching, boolean repeat, | |||
// block will use the refCnt of bucketEntry, which means if two HFileBlock mapping to | |||
// the same BucketEntry, then all of the three will share the same refCnt. | |||
Cacheable cachedBlock = ioEngine.read(bucketEntry); | |||
// RPC start to reference, so retain here. | |||
cachedBlock.retain(); | |||
if (ioEngine.usesSharedMemory()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One big concern here: now for exclusive memory IOEngine, the refCnt value of all bucketEntry will be 1, means the reference from BucketCache, no RPC reference. Then I think the BucketCache's eviction policy would always evict those blocks despite that the RPC is still using the block, not say the memory leak issue , but the eviction policy is evicting those RPC referring blocks (violate the LRU ? )....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The eviction policy will compare BucketEntry with it’s accessCounter, so this will not violate the LRU?
return wrapAsCacheable(ByteBuff.wrap(buffers, this.refCnt)); | ||
} | ||
|
||
Cacheable wrapAsCacheable(ByteBuff buf) throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good thing, make the wrapAsCacheable into two methods. the SharedIOEngine use the former one, and the ExclusiveIOEngine use the later one. Good.
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
…sabled table (apache#465) Signed-off-by: Stack <stack@apache.org>
…ck chore (apache#466) Signed-off-by: Guanghao Zhang <zghao@apache.org>
apache#469) Signed-off-by: Duo Zhang <zhangduo@apache.org>
Signed-off-by: Wellington Chevreuil <wchevreuil@apache.org>
…pache#390) Signed-off-by: Andrew Purtell <apurtell@apache.org>
Signed-off-by: stack <stack@apache.org>
Signed-off-by: stack <stack@apache.org>
Signed-off-by: stack <stack@apache.org> Signed-off-by: Jan Hentschel <jan.hentschel@ultratendency.com>
Signed-off-by: stack <stack@apache.org>
Signed-off-by: stack <stack@apache.org>
Signed-off-by: Duo Zhang <zhangduo@apache.org>
💔 -1 overall
This message was automatically generated. |
sorry, do the wrong rebase, close this pr first |
No description provided.