-
Notifications
You must be signed in to change notification settings - Fork 13k
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
[FLINK-35215][core] Fix the bug when Kryo serialize length is 0 #24717
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,14 +73,17 @@ protected int require(int required) throws KryoException { | |
position = 0; | ||
int bytesRead = 0; | ||
int count; | ||
while (bytesRead < required) { | ||
while (true) { | ||
count = fill(buffer, bytesRead, required - bytesRead); | ||
|
||
if (count == -1) { | ||
throw new KryoException(new EOFException("No more bytes left.")); | ||
} | ||
|
||
bytesRead += count; | ||
if (bytesRead == required) { | ||
break; | ||
} | ||
} | ||
limit = required; | ||
return required; | ||
|
@@ -114,18 +117,26 @@ public void readBytes(byte[] bytes, int offset, int count) throws KryoException | |
throw new IllegalArgumentException("bytes cannot be null."); | ||
} | ||
|
||
if (count == 0) { | ||
return; | ||
} | ||
|
||
try { | ||
int bytesRead = 0; | ||
int c; | ||
|
||
while (bytesRead < count) { | ||
while (true) { | ||
c = inputStream.read(bytes, offset + bytesRead, count - bytesRead); | ||
|
||
if (c == -1) { | ||
throw new KryoException(new EOFException("No more bytes left.")); | ||
} | ||
|
||
bytesRead += c; | ||
|
||
if (bytesRead == count) { | ||
Comment on lines
-121
to
+137
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Hi @reswqa , I'm not very sure the reason. But I guess:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! Yes, I don't know the details also, but it's possible that JIT optimizations were affected. |
||
break; | ||
} | ||
} | ||
} catch (IOException ex) { | ||
throw new KryoException(ex); | ||
|
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.
This
if (count == 0) {
is alternative change for FLINK-34954, I ran the demo that provided in FLINK-34954, it works well. So I think the change is fine.Also, I ran the benchmark, the performance of serializerKryo and serializerKryoWithoutRegistration are recovered.
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.
Hi @dannycranmer , this issue is the blocker of Flink 1.20, and you are the reviewer of #24586, would you mind reviewing this PR as well? thanks in advance.
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.
@1996fanrui Can you add the demo from FLINK-34954 as a 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.
Thanks @uce for the reminder!
Let's follow it up at #24837 .