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

Speedup tickstore read date index conversion #1021

Merged
merged 1 commit into from
Feb 1, 2024

Conversation

BaiBaiHi
Copy link
Contributor

@BaiBaiHi BaiBaiHi commented Feb 1, 2024

Speedup of Tickstore read datetime index conversion by ~40x.

Overall runtime improvement is around 3-4x on average, but this can vary depending on the mongo latency.

%timeit  pd.DatetimeIndex(np.concatenate(rtn[INDEX]).astype('datetime64[ms]'), tz='UTC')
1.76 s ± 59.1 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
%timeit pd.to_datetime(np.concatenate(rtn[INDEX]), utc=True, unit='ms')
1min 16s ± 1.74 s per loop (mean ± std. dev. of 7 runs, 1 loop each)

In the current implementation, the datetime conversion takes ~60% of the total runtime:

image

The new implementation drops it down to ~5%

image

Output of both implementations is identical (tested on 22.5 million values).

image

@jamesmunro jamesmunro self-requested a review February 1, 2024 16:33
@jamesmunro
Copy link
Collaborator

Thanks!

@BaiBaiHi BaiBaiHi merged commit e4ee5ea into master Feb 1, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants