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

Clean up _BatchSizeEstimator in element-batching transform.

Details

    • Bug
    • Status: Resolved
    • P3
    • Resolution: Fixed
    • None
    • 2.8.0
    • sdk-py-core
    • None

    Description

      Beam Python 3 conversion exposed non-trivial performance-sensitive logic in element-batching transform. Let's take a look at util.py#L271.

      Due to Python 2 language semantics, the result of x2 / x1 will depend on the type of the keys - whether they are integers or floats.

      The keys of key-value pairs contained in self._data are added as integers here, however, when we 'thin' the collected entries here, the keys will become floats. Surprisingly, using either integer or float division consistently in the comparator negatively affects the performance of a custom pipeline I was using to benchmark these changes. The performance impact likely comes from changes in the logic that depends on how division is evaluated, not from the performance of division operation itself.

      In terms of Python 3 conversion the best course of action that avoids regression seems to be to preserve the existing Python 2 behavior using old_div from past.utils.division, in the medium term we should clean up the logic. We may want to add a targeted microbenchmark to evaluate performance of this code, and maybe cythonize the code, since it seems to be performance-sensitive.

      Attachments

        Activity

          People

            robertwb Robert Bradshaw
            tvalentyn Valentyn Tymofieiev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

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

                Slack

                  Issue deployment