Michael LeGore
11/07/2024, 7:47 PMDataStream using the flink hadoop compatability InputFormats, and we are finding that the reads are incredibly slow (1 record/sec per task slot) I looked at the flamegraph and it looks like the task is spending all its time waiting for locks. To workaround, I created a StreamFormat for the FileSource connector that uses a SequenceFile.Reader directly, but I was wondering if this is a known issue with lock contention and if there are any other workarounds, or if there are plans to have sequence file support in the FileSource api (in 2.0 maybe)?Ken Krugler
11/07/2024, 10:25 PMMichael LeGore
11/07/2024, 11:15 PMExecutionConfig executionConfig = exec.getConfig();
executionConfig.addDefaultKryoSerializer(Grain.class, ProtobufSerializer.class);
String apiGrainsInputFolder = config.getGrains().getSnapshotPath();
LOG.info("Reading grains batch from {}", apiGrainsInputFolder);
JobConf conf = new JobConf();
conf.setStrings("io.serializations", conf.get("io.serializations"),
ResultSerializationV2.class.getName());
HadoopInputFormat<ImmutableBytesWritable, Result> inputFormat =
HadoopInputs.readHadoopFile(
new org.apache.hadoop.mapred.SequenceFileInputFormat<>(),
ImmutableBytesWritable.class,
Result.class,
apiGrainsInputFolder,
conf);
TypeInformation<Tuple2<ImmutableBytesWritable, Result>> typeInfo =
TypeExtractor.getInputFormatTypes(inputFormat);
InputFormatSourceFunction<Tuple2<ImmutableBytesWritable, Result>> function =
new InputFormatSourceFunction<>(inputFormat, typeInfo);
exec.clean(function);
final StreamSource<Tuple2<ImmutableBytesWritable, Result>, ?> sourceOperator =
new StreamSource<>(function);
LOG.info("Current parallelism: {}", exec.getParallelism());
exec.setParallelism(20);
return new DataStreamSource<>(exec, typeInfo, sourceOperator, true,
"api-grains-batch", Boundedness.BOUNDED)
.flatMap(new MapImmutableBytesWritableToGrain())
.assignTimestampsAndWatermarks(WatermarkStrategy.<Grain>forMonotonousTimestamps()
.withTimestampAssigner(TimestampAssignerSupplier.of(
(Grain grain, long t) -> getTimeMillis(grain).get())));
I pulled some code out from DataStream because it seemed like custom InputFormats were never treated as being bounded.