Repository: modin-project/modin

Issue:
Optimize `_simple_shuffle` function in case when lengths of self and others objects are equal
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. What kind of performance improvements would you like to see with this new API?



Discussion:
Hi @anmyachev, can you expand a little on what the issue here is?
This is apparently outdated since `_simple_shuffle` function is not used anywhere.

I will create PR for remove the unused code.

Resolving patch:
diff --git a/modin/core/dataframe/pandas/dataframe/dataframe.py b/modin/core/dataframe/pandas/dataframe/dataframe.py
--- a/modin/core/dataframe/pandas/dataframe/dataframe.py
+++ b/modin/core/dataframe/pandas/dataframe/dataframe.py
@@ -1949,38 +1949,6 @@ def get_axis_lengths(partitions, axis):
         )
         return reindexed_frames[0], reindexed_frames[1:], joined_index
 
-    def _simple_shuffle(self, axis, other):
-        """
-        Shuffle `other` rows or columns to match partitioning of `self`.
-
-        Parameters
-        ----------
-        axis : {0, 1}
-            Axis to shuffle over.
-        other : PandasFrame
-            Modin DataFrame to match to `self` partitioning.
-
-        Returns
-        -------
-        PandasFrame
-            Shuffled version of `other`.
-
-        Notes
-        -----
-        This should only be called when `other.axes[axis]` and `self.axes[axis]`
-        are identical.
-        """
-        assert self.axes[axis].equals(
-            other.axes[axis]
-        ), "`_simple_shuffle` should only be used if axis is identical"
-        if axis == 0:
-            lengths = self._row_lengths
-        else:
-            lengths = self._column_widths
-        return other._partition_mgr_cls.simple_shuffle(
-            axis, other._partitions, lambda x: x, lengths
-        )
-
     def binary_op(self, op, right_frame, join_type="outer"):
         """
         Perform an operation that requires joining with another Modin DataFrame.
diff --git a/modin/core/dataframe/pandas/partitioning/partition_manager.py b/modin/core/dataframe/pandas/partitioning/partition_manager.py
--- a/modin/core/dataframe/pandas/partitioning/partition_manager.py
+++ b/modin/core/dataframe/pandas/partitioning/partition_manager.py
@@ -552,47 +552,6 @@ def map_axis_partitions(
             enumerate_partitions=enumerate_partitions,
         )
 
-    @classmethod
-    @wait_computations_if_benchmark_mode
-    def simple_shuffle(cls, axis, partitions, map_func, lengths):
-        """
-        Shuffle data so lengths of partitions match given `lengths` via calling `map_func`.
-
-        Parameters
-        ----------
-        axis : {0, 1}
-            Axis to perform the map across (0 - index, 1 - columns).
-        partitions : NumPy 2D array
-            Partitions of Modin Frame.
-        map_func : callable
-            Function to apply.
-        lengths : list(int)
-            List of lengths to shuffle the object.
-
-        Returns
-        -------
-        NumPy array
-            An array of new partitions for a Modin Frame.
-        """
-        preprocessed_map_func = cls.preprocess_func(map_func)
-        partitions = cls.axis_partition(partitions, axis)
-        # For mapping across the entire axis, we don't maintain partitioning because we
-        # may want to line to partitioning up with another BlockPartitions object. Since
-        # we don't need to maintain the partitioning, this gives us the opportunity to
-        # load-balance the data as well.
-        result_blocks = np.array(
-            [
-                part.apply(
-                    preprocessed_map_func, _lengths=lengths, manual_partition=True
-                )
-                for part in partitions
-            ]
-        )
-        # If we are mapping over columns, they are returned to use the same as
-        # rows, so we need to transpose the returned 2D NumPy array to return
-        # the structure to the correct order.
-        return result_blocks.T if not axis else result_blocks
-
     @classmethod
     def concat(cls, axis, left_parts, right_parts):
         """


Test patch: