Skip to content

Speedup tickstore read date index conversion#1021

Merged
BaiBaiHi merged 1 commit intomasterfrom
speedup-tickstore-read
Feb 1, 2024
Merged

Speedup tickstore read date index conversion#1021
BaiBaiHi merged 1 commit intomasterfrom
speedup-tickstore-read

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

Thanks!

@BaiBaiHi BaiBaiHi merged commit e4ee5ea into master Feb 1, 2024
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