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

Reduce overhead in DataStream.submit_data(). #147

Merged
merged 4 commits into from
Feb 29, 2024

Conversation

ehpor
Copy link
Collaborator

@ehpor ehpor commented Dec 4, 2023

The old implementation performed type checking using Numpy functions, so that required a call from C++ back to Python, letting Python perform dtype operations, converting the result to a Python string, converting that string to a C++ string, then doing a C++ string comparison. The new code performs a C++ string comparison for the type directly using the dtype of the buffer format.

@ehpor ehpor requested a review from ivalaginja December 4, 2023 22:30
@ehpor ehpor self-assigned this Dec 4, 2023
@ehpor ehpor added the enhancement New feature or request label Dec 4, 2023
@ehpor
Copy link
Collaborator Author

ehpor commented Dec 4, 2023

Benchmarks: for 32x32 float32:

Macbook Pro M2 (Python 3.9.18):
develop: 4.93 µs ± 27.6 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each)
this PR: 674 ns ± 11.8 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)

Hicatdeuxbis (Python 3.7.6):
develop: 13.9 µs ± 166 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
this PR: 1.73 µs ± 12.7 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)

Copy link
Collaborator

@ivalaginja ivalaginja left a comment

Choose a reason for hiding this comment

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

What's with the addition of all the np.abs() in the tests?

@ivalaginja
Copy link
Collaborator

Nvm, your commit message explains it.

@ehpor
Copy link
Collaborator Author

ehpor commented Dec 4, 2023

@ivalaginja That's to avoid a warning when casting to unsigned integers from data that is both positive and negative. I presume it was there already, so it's kinda code sneak. It's not critical to this PR.

@ivalaginja
Copy link
Collaborator

Running the same benchmarks like @ehpor (after remembering that I had to recompile catkit2 😬 ), for 32x32 float32 data:

Macbook Pro M1 (Python 3.9.12)
develop: 9.6 µs ± 63 ns (mean ± std. dev. of 7 runs, 100,000 loops each)
tihs PR: 1.4 µs ± 5 ns (mean ± std. dev. of 7 runs, 1,000,000 loops each)

thd2-controller (Python 3.9.12)
develop: 14.5 µs ± 48 ns (mean ± std. dev. of 7 runs, 100,000 loops each)
this PR: 1.7 µs ± 12 ns (mean ± std. dev. of 7 runs, 1,000,000 loops each)

@ehpor
Copy link
Collaborator Author

ehpor commented Dec 5, 2023

Since this is a low-level change, I want to do a full end-to-end test on HiCAT before merging.

Copy link
Collaborator

@ivalaginja ivalaginja left a comment

Choose a reason for hiding this comment

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

Looks good to me.
Hold merging until Emiel gives green light from the HiCAT test.

@ehpor ehpor force-pushed the feature/reduce_overhead_submit_data branch from 5c080c2 to 2fa57b0 Compare February 29, 2024 20:22
@ehpor
Copy link
Collaborator Author

ehpor commented Feb 29, 2024

Benchmarks on HicatDeuxBis:

Develop:
benchmark_datastream_catkit2_PR147_develop

This PR:
benchmark_datastream_catkit2_PR147

@ehpor
Copy link
Collaborator Author

ehpor commented Feb 29, 2024

Confirmed working on hardware.

@ehpor ehpor merged commit 7a3d207 into develop Feb 29, 2024
5 of 6 checks passed
@ehpor ehpor deleted the feature/reduce_overhead_submit_data branch February 29, 2024 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants