Uploaded image for project: 'Beam'
  1. Beam
  2. BEAM-10042

Add alternate constructor to improve byte encoding performance in SortValues

Details

    • Improvement
    • Status: Open
    • P3
    • Resolution: Unresolved
    • None
    • None
    • extensions-java-sorter

    Description

      The `SortValues` transform operates on key-groups of `KV<PrimaryKeyT, Iterable<KV<SecondaryKeyT, ValueT>>>`. From those key groups it iterates through each element and uses `CoderUtils.encodeToByteArray` on each SecondaryKeyT-ValueT pair. This operation can be expensive and its parallelism is limited by the # of key groups.

      I'd like to propose adding an alternative to `SortValuesDoFn` that operates on `KV<PrimaryKeyT, Iterable<KV<byte[], byte[]>>>` and can skip the encoding step within the key-group. The user's pipeline may be able to encode the data to bytes in a prior step in a much more parallelized and efficient way (i.e. in a `MapElements` transform). I've seen performance gains in every Dataflow metric from from patching this in my team's pipeline.

      (I would visualize the alternative vs pre-existing constructors to look similar to generic vs specific Avro constructors, where the generic constructor has a static type and specific Avro has a parameterized T.)
       

      What do you think? 

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              clairemcginty Claire McGinty
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 10m
                  10m