Repository navigation
Use broadcast variables in IcebergSource - #569
Conversation
|
Can we use Spark's internal SerializableConfiguration to avoid the Kryo problem? |
|
@rdblue, Hadoop conf is hidden in |
|
Yes, I think that this is something we will want to add a special case for. If the FileIO is a Hadoop FileIO, then hijack it. |
|
Will it be worth the complexity assuming we will have a custom Kryo registrator anyway? |
|
I'm not confident that we will want to have a custom Kryo registrator. Requiring users to register extra classes makes it significantly harder because Iceberg doesn't work out of the box. We might just build some collection wrappers that can handle this. I think the SerializableByteBufferMap is working just fine, so maybe we can customize like that. |
|
Applying the proxy pattern looks promising, let me try that. |
|
Wait, |
|
Yes, but it also appears that Kryo handles maps by serializing the map type and the entries, then calling put to reconstruct the map. We can possibly use this to build a proxy class. |
|
This looks good to me. Is the remaining concern that it uses Iceberg's SerializableConfiguration that isn't correctly handled by Kryo? |
|
Yes, I've decided to wait until we arrive to a solution in #549 and then update this PR accordingly. I'd want to avoid hijacking depending on |
|
@rdblue, it just occurred to me that |
|
@aokolnychyi, I think it should be fine to rely on it. It's a little ugly, but better than needing special registration for Kryo. |
|
Then we can do smth like below.
Still ugly and won't work for arbitrary |
|
Here's a slightly cleaner way. I updated public class HadoopFileIO implements FileIO {
private final Supplier<Configuration> hadoopConf;
public HadoopFileIO(Configuration hadoopConf) {
this(new SerializableConfiguration(hadoopConf)::get);
}
public HadoopFileIO(Supplier<Configuration> hadoopConf) {
this.hadoopConf = hadoopConf;
}
public Configuration conf() {
return hadoopConf.get();
}
...
}Then we just need to pass Spark's if (table.io() instanceof HadoopFileIO) {
this.fileIo = new HadoopFileIO(new SerializableConfiguration(((HadoopFileIO) table.io()).conf())::value);
} else {
this.fileIo = table.io();
}Here's a branch: rdblue@84aa3ba It shouldn't be too difficult to add the broadcast to that. |
a493a66 to
853a821
Compare
|
@rdblue, I like the idea and it can work if we make |
853a821 to
a339277
Compare
|
This one is ready for another review round. |
|
+1 |
This PR fixes #553.
In some Spark jobs, we see a substantial scheduler delay, which happens in
TaskSetManagerwhen Spark serializes IcebergReadTask. The latter contains a reference toFileIO(which can contain a full Hadoop conf).The current idea is to broadcast
EncryptionManagerandFileIOinIcebergSource. ThenReaderandReadTaskcan store references to the broadcasted values and fetch actual ones increatePartitionReaderwhile creatingTaskDataReader.All broadcasted values are automatically registered for clean-up in
SparkContext$broadcast.Note! Using this approach with Kryo requires providing a custom registrator to instruct Spark to apply Java serialization for
SerializableConfiguration. We should extend #549 for this.