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

CLN: Update Cython data pointers for rolling apply #34930

Merged

Conversation

mroeschke
Copy link
Member

Performance looks pretty comparable between master and this PR

N = 10 ** 3
arr = 100 * np.random.random(N)
roll = pd.DataFrame(arr).rolling(10)
%timeit roll.apply(lambda x: np.sum(x) + 5, raw=True)

4.48 ms ± 14.8 µs per loop (mean ± std. dev. of 7 runs, 100 loops each) <--PR
4.34 ms ± 29.6 µs per loop (mean ± std. dev. of 7 runs, 100 loops each) <--master

@mroeschke mroeschke added Clean Window rolling, ewma, expanding labels Jun 22, 2020
@TomAugspurger
Copy link
Contributor

cc @WillAyd & @jbrockmendel since I think you have some experience here.

It's good to see that performance is comparable.

@WillAyd
Copy link
Member

WillAyd commented Jun 22, 2020

This looks great! I assume memory impact is roughly the same? Also do you know if this will work in reductions.pyx as well?

@jbrockmendel
Copy link
Member

LGTM.

Also do you know if this will work in reductions.pyx as well?

My understanding is that these are pretty different usages. #34009 addresses one of the usages in reductions.pyx; local attempts to address the other usages are proving more troublesome.

@mroeschke
Copy link
Member Author

I assume memory impact is roughly the same?

My ASVs are botched, but memit shows comparable memusage. Looks like this pointer dance was to avoid copying data, and I think the slicing in this PR should be operating on views.

N = 10 ** 3
arr = 100 * np.random.random(N)
roll = pd.DataFrame(arr).rolling(10)
%memit roll.apply(lambda x: np.sum(x) + 5, raw=True)

peak memory: 74.94 MiB, increment: 0.00 MiB <--PR

peak memory: 74.72 MiB, increment: 0.53 MiB <--master

@mroeschke mroeschke added this to the 1.1 milestone Jun 22, 2020
Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

lgtm

@TomAugspurger
Copy link
Contributor

Alrighty, thanks!

@TomAugspurger TomAugspurger merged commit 7d6377d into pandas-dev:master Jun 23, 2020
@mroeschke mroeschke deleted the rolling_apply_remove_pointer branch June 23, 2020 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Window rolling, ewma, expanding
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants