Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PERF-#5017: reset_index shouldn't trigger index materialization if possible #5018

Merged
merged 1 commit into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/release_notes/release_notes-0.16.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Key Features and Updates
* PERF-#4920: Avoid index and cache computations in `take_2d_labels_or_positional` unless they are needed (#4921)
* PERF-#4999: don't call `apply` in virtual partition' `drain_call_queue` if `call_queue` is empty (#4975)
* PERF-#4268: Implement partition-parallel __getitem__ for bool Series masks (#4753)
* PERF-#5017: `reset_index` shouldn't trigger index materialization if possible (#5018)
* PERF-#4963: Use partition `width/length` methods instead of `_compute_axis_labels_and_lengths` if index is already known (#4964)
* PERF-#4940: Optimize categorical dtype check in `concatenate` (#4953)
* Benchmarking enhancements
Expand Down
5 changes: 3 additions & 2 deletions modin/core/storage_formats/pandas/query_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ def reset_index(self, **kwargs):
if len(level) < self.index.nlevels
else pandas.RangeIndex(len(self.index))
)
else:
elif not drop:
uniq_sorted_level = list(range(self.index.nlevels))

if not drop:
Expand Down Expand Up @@ -627,7 +627,8 @@ def reset_index(self, **kwargs):
else:
new_self = self.copy()
new_self.index = (
pandas.RangeIndex(len(new_self.index))
# Cheaper to compute row lengths than index
pandas.RangeIndex(sum(new_self._modin_frame._row_lengths))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really want to make QC know that _modin_frame has _row_lengths? Same question got hung in #4460.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YarShev Why not? The modin is based on this mechanism, in addition, this information can be used to advantage in some functions. I think that we can make these functions public (_row_lengths/_column_widths).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am okay with this (link) but @devin-petersohn, @mvashishtha might have different thoughts on the matter. I would like to make sure we are on the same page.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I support making row_lengths and column_widths public.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good, let's make those public. Please create an issue for that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if new_index is None
else new_index
)
Expand Down