gaoyunhaii commented on a change in pull request #7368: [FLINK-10742][network]
Let Netty use Flink's buffers directly in credit-based mode
URL: https://github.com/apache/flink/pull/7368#discussion_r386105137
##########
File path:
flink-runtime/src/test/java/org/apache/flink/runtime/io/network/netty/NettyMessageClientSideSerializationTest.java
##########
@@ -183,15 +192,18 @@ private void testEncodeDecodeBuffer(boolean
testReadOnlyBuffer, boolean testComp
}
NettyMessage.BufferResponse expected = new
NettyMessage.BufferResponse(
- testBuffer, random.nextInt(), new InputChannelID(),
random.nextInt());
- NettyMessage.BufferResponse actual = encodeAndDecode(expected);
+ testBuffer, random.nextInt(),
inputChannel.getInputChannelId(), random.nextInt());
+ NettyMessage.BufferResponse actual = encodeAndDecode(expected,
channel);
// Netty 4.1 is not copying the messages, but retaining slices
of them. BufferResponse actual is in this case
// holding a reference to the buffer. Buffer will be recycled
only once "actual" will be released.
- assertFalse(buffer.isRecycled());
- assertFalse(testBuffer.isRecycled());
+ assertTrue(buffer.isRecycled());
Review comment:
This is because previously the decoder simply create a readonly slice of the
received data and transfer it to the client handler, and the client handler is
responsible for copying the data into the `NetworkBuffer`. However, with the
change the decoder will apply a new `NetworkBuffer` and copy the received data
into `NetworkBuffer` directly.
Another point is that in this case, we always write a complete message into
`EmbeddedChannel` and the channel will not repartition the message. Thus during
the encoding and decoding, no accumulation will happen. This is also not always
true for real case.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services