-
Notifications
You must be signed in to change notification settings - Fork 319
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
Significant performance improvements to AddResult / GetParameter #4446
Conversation
9d76b73
to
8ddeda1
Compare
Codecov Report
@@ Coverage Diff @@
## master #4446 +/- ##
==========================================
- Coverage 68.23% 68.21% -0.03%
==========================================
Files 339 339
Lines 31801 31778 -23
==========================================
- Hits 21700 21676 -24
- Misses 10101 10102 +1 |
Thanks @fblanchetNaN and @mgunyho I will need a bit of time to look at this so please bear with me |
8af5eef
to
3d7b0fd
Compare
@fblanchetNaN and @mgunyho thanks for the contribution. @astafan8 And I finally had a chance to look at it today. We agreed that this looks good and we would like to merge most of it. We are not completely confident in the logic for scalar complex numbers so we would prefer if we can merge the other optimizations but leave that one for a subsequent pr. |
Thanks for the response! We agree that the complex scalar logic looks a bit convoluted, even though it is just following the numpy format standard. We can take it out from this PR and discuss it further separately, although for us this is actually the more significant change because it really affects the loading times in some of our experiments. I can remove the changes related to complex stuff and force-push if that sounds good. I guess we anyway need to rebase to fix the conflicts. |
3d7b0fd
to
7270bca
Compare
The branch is now updated excluding the changes related to complex numbers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also add a newsfragment (read about them here https://qcodes.github.io/Qcodes/community/contributing.html?highlight=newsfragment#pull-requests )?
no worries :) both are fine, feel free to do what's most convenient for you, the comments will be preserved anyways. |
008b641
to
ec9bd8c
Compare
ec9bd8c
to
b476b79
Compare
The branch is now updated including the required changes, all checks have passed. I have marked the conversations as resolved after replying/accepting them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bors merge
Saving and loading data from the SQL database rely on
_adapt_xxx
and_convert_xxx
methods. However, currently they are using manynumpy
functions (np.isnan
,np.isinf
,np.save
,np.load
) that are slow when dealing with arrays containing single values. This PR makes the following changes that significantly improve data loading and saving performance:float
: Replacenumpy
functions bymath
functions, usemath.isinfinite
instead of combiningisnan
andisinf
;complex
: Do not save complex single values asnumpy
arrays of one value. It saves both time and space if we avoid reading and writing the relatively largenumpy
header. This changes the representation of the data in the database, but it's fully backwards compatible (and tested);array
: Use directly functions fromnp.lib.format
, it skips some work ofnp.save
andnp.load
;b0b6528 rewrites adapters and converters avoiding
numpy
functions and significantly improves performance (around x3 when loading regular numeric data and up to x70 for complex data).20c58d7 is a minor improvement (~10% when loading complex or numeric data), it avoids unpacking
sqlite3.Row
tolist
when it's unnecessary (those functions can reorder the columns however, it's most of the time unnecessary because the SQL queries are properly sorted).3d7b0fd follows the previous one: as the SQL queries are properly sorted, the named tuple feature of
sqlite3.Row
(row[column_name]
) becomes superfluous.459b342 is up-to-date benchmarks. (Note that the benchmarks are not run in CI.)
Commit b0b6528 is the most important one, the two other modifications give pretty minor improvements compared to the number of changes to the codebase. If you feel that it's not worth changing so much for such a small gain, they can be left out.
(we worked on these preformance improvements together with @mgunyho)
closes #1238 (?)