Hi Flink Community :wave: my team is working on a ...
# troubleshooting
m
Hi Flink Community 👋 my team is working on a project where we are reading Hadoop sequence files into a
DataStream
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)?
k
Can you share the code you’re using to read? 1 record/sec seems very wrong…
m
Copy code
ExecutionConfig 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.