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: Speed up bitstring conversions in idex #309

Merged

Conversation

greglucas
Copy link
Collaborator

Change Summary

Overview

Bitstring was allocating many new objects which added significant overhead. We can just use Python's native int conversions and indexing into strings to achieve the same result.

performance script:
python -m cProfile -o orig.prof -m pytest imap_processing/idex/tests

current version
image

new version
image

There are originally over 3M calls to ba2int and over 1M calls to _readlist, versus 228k and 0 in the new version.

@greglucas greglucas added Ins: IDEX Related to the IDEX instrument Level: L0 Level 0 processing labels Jan 6, 2024
Copy link
Collaborator

@bourque bourque left a comment

Choose a reason for hiding this comment

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

The more you know! Thanks Greg. I'm curious what prompted you to discover this?

Bitstring was allocating many new objects which added significant
overhead. We can just use Python's native int conversions and
indexing into strings to achieve the same result.
@greglucas
Copy link
Collaborator Author

The more you know! Thanks Greg. I'm curious what prompted you to discover this?

I was running a lot of tests and didn't understand how we could be so slow... I think there will likely be others here as well, but I've always had my eye on bitstring and cdflib being pure python and slow for our use-cases, so it sort of reaffirmed this to me when running cProfile.

@greglucas greglucas merged commit 64fcb13 into IMAP-Science-Operations-Center:dev Jan 9, 2024
17 checks passed
@greglucas greglucas deleted the idex-speedups branch January 9, 2024 01:26
laspsandoval pushed a commit to laspsandoval/imap_processing that referenced this pull request Apr 2, 2024
…idex-speedups

PERF: Speed up bitstring conversions in idex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ins: IDEX Related to the IDEX instrument Level: L0 Level 0 processing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants