-
Notifications
You must be signed in to change notification settings - Fork 80
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
Share PyArrow table data with the server through ByteBuffer #4936
Share PyArrow table data with the server through ByteBuffer #4936
Conversation
d8a2df2
to
6f79d5e
Compare
6f79d5e
to
e654b2b
Compare
e654b2b
to
787de1b
Compare
...nsions/barrage/src/main/java/io/deephaven/extensions/barrage/util/ArrowToTableConverter.java
Show resolved
Hide resolved
@@ -70,7 +69,7 @@ private static BarrageProtoUtil.MessageInfo parseArrowIpcMessage(final byte[] ip | |||
} | |||
|
|||
@ScriptApi | |||
public synchronized void setSchema(final byte[] ipcMessage) { | |||
public synchronized void setSchema(final ByteBuffer ipcMessage) { |
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.
So, I think we need to add a big warning here and link to jpy-consortium/jpy#126; no strong references to this buffer can exist by the end of this method. I think we need to extend this warning into the implementation of parseSchema as well - it can't hold any references to Schema header
(since that has references to the byte buffer).
@@ -192,7 +198,7 @@ protected BarrageMessage createBarrageMessage(BarrageProtoUtil.MessageInfo mi, i | |||
return msg; | |||
} | |||
|
|||
private BarrageProtoUtil.MessageInfo getMessageInfo(byte[] ipcMessage) { | |||
private BarrageProtoUtil.MessageInfo getMessageInfo(ByteBuffer ipcMessage) { |
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.
Flatbuffer almost certainly retains references to ByteBuffer. We need to be very careful that nothing retains this flatbuffer object. I think we need to add a big warning in io.deephaven.extensions.barrage.util.ArrowToTableConverter#createBarrageMessage
that nothing can retain reference to BarrageProtoUtil.MessageInfo mi
...nsions/barrage/src/main/java/io/deephaven/extensions/barrage/util/ArrowToTableConverter.java
Show resolved
Hide resolved
...nsions/barrage/src/main/java/io/deephaven/extensions/barrage/util/ArrowToTableConverter.java
Show resolved
Hide resolved
I think we need to carefully audit all of the parsing logic here to make sure no ByteBuffer / Flatbuffer object is retained. It's not obvious to me without digging in further to the implementations, which is why trying to use |
066a148
to
7a4bb1e
Compare
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.
OK with me if all of @devinrsmith 's suggestions have been addressed. My comments are optional.
...nsions/barrage/src/main/java/io/deephaven/extensions/barrage/util/ArrowToTableConverter.java
Outdated
Show resolved
Hide resolved
...nsions/barrage/src/main/java/io/deephaven/extensions/barrage/util/ArrowToTableConverter.java
Outdated
Show resolved
Hide resolved
...nsions/barrage/src/main/java/io/deephaven/extensions/barrage/util/ArrowToTableConverter.java
Outdated
Show resolved
Hide resolved
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.
I dug in a bit. All of the flatbuffer usages that could reference the byte buffer (such as for strings) perform copies. (In particular the internal flatbuffer __string
method copies during decoding). The extractChunkFromInputStream
implementations similarly will copy via new String(buf, offset, length)
invocations. Similarly any arrays extract a copy from the contiguous body payload rather than an effective slice.
AFAICT this change looks safe.
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.
Please add warning comment inside of parseSchema and createBarrageMessage as well.
...nsions/barrage/src/main/java/io/deephaven/extensions/barrage/util/ArrowToTableConverter.java
Outdated
Show resolved
Hide resolved
...nsions/barrage/src/main/java/io/deephaven/extensions/barrage/util/ArrowToTableConverter.java
Outdated
Show resolved
Hide resolved
5d7fe30
Fixes #4935
Fixes #3709
depends on jpy-consortium/jpy#112
depends on #5022