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: Stop recomputing both indices for user-defined and dict-like axis-wide applies #4445

Open
mvashishtha opened this issue May 7, 2022 · 1 comment · May be fixed by #4460
Open

PERF: Stop recomputing both indices for user-defined and dict-like axis-wide applies #4445

mvashishtha opened this issue May 7, 2022 · 1 comment · May be fixed by #4460
Labels
P2 Minor bugs or low-priority feature requests Performance 🚀 Performance related issues and pull requests.

Comments

@mvashishtha
Copy link
Collaborator

Describe the problem

We recompute both column and row indices for column-wise and row-wise applies of user-defined callables and dict-like functions. Here for dict applies and here for callable applies, we specify neither new_index nor new_columns so we end up recomputing both axes, so we always block on both the first row of partitions and the first column of partitions. You can observe this unnecessary blocking here:

import modin.pandas as pd
import numpy as np
import time
from modin.config import MinPartitionSize

num_columns = MinPartitionSize.get() + 1

# 3 rows where each row has the numbers from 0 through num_columns 
# exclusive in sequential order
# so the entire frame has a single row of two partitions,
# where the first has num_columns - 1 columns and the second has one.
df = pd.DataFrame(np.tile(np.arange(num_columns), (3, 1)))

# This takes hours for the the column containing 32,
# but should return much faster for the other columns.
def col_func(col):
    if col[0] == num_columns - 1:
        time.sleep(10000)
    return col * 2

# This blocks on the last column to recompute
# the column index, so it blocks 10000 seconds.
# instead, it should finish immediately while the last 
# apply completes asynchronously.
print('starting apply...')
result = df.apply(col_func)
@mvashishtha mvashishtha self-assigned this May 7, 2022
@mvashishtha mvashishtha added the Performance 🚀 Performance related issues and pull requests. label May 7, 2022
mvashishtha pushed a commit to mvashishtha/modin that referenced this issue May 25, 2022
…applies.

Signed-off-by: mvashishtha <mahesh@ponder.io>
@vnlitvinov
Copy link
Collaborator

I think #4726 could help here.

@vnlitvinov vnlitvinov added the P2 Minor bugs or low-priority feature requests label Sep 6, 2022
@mvashishtha mvashishtha removed their assignment May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 Minor bugs or low-priority feature requests Performance 🚀 Performance related issues and pull requests.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants