Skip to content

Conversation

@eendebakpt
Copy link
Contributor

For instruments with many parameters (100 - 1000 range) the overhead of qcodes parameters becomes a bottleneck in startup time. In this PR we improve performance of is_function:

main: 6.65 μs ± 185 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each)
PR: 668 ns ± 31.3 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)

Testing code:

def f(x):
    return None
arg_count=1
%timeit is_function0(f, arg_count) 

(there are more bottlenecks, but is_fuction is used in creation of every Parameter and is quite heavy)

@eendebakpt eendebakpt requested a review from a team as a code owner November 28, 2025 15:07
@jenshnielsen
Copy link
Collaborator

Thanks @eendebakpt That seems very useful. In the long term I think we should consider completely removing and simplifying the command class from parameter but until then this seems like a nice improvement. I did not look into why the tests doesn't like this as is

@codecov
Copy link

codecov bot commented Dec 1, 2025

Codecov Report

❌ Patch coverage is 89.47368% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.92%. Comparing base (02725b5) to head (fc01d90).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
src/qcodes/utils/function_helpers.py 88.88% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7669      +/-   ##
==========================================
+ Coverage   59.90%   59.92%   +0.01%     
==========================================
  Files         352      352              
  Lines       31810    31825      +15     
==========================================
+ Hits        19055    19070      +15     
  Misses      12755    12755              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@eendebakpt
Copy link
Contributor Author

@microsoft-github-policy-service agree [company="TNO"]

@eendebakpt eendebakpt changed the title Draft: Improve performance of is_function Improve performance of is_function Dec 28, 2025
@eendebakpt
Copy link
Contributor Author

eendebakpt commented Dec 28, 2025

Thanks @eendebakpt That seems very useful. In the long term I think we should consider completely removing and simplifying the command class from parameter but until then this seems like a nice improvement. I did not look into why the tests doesn't like this as is

Tests are passing now. Simplifying the command class would indeed be great!

One more performance improvement would be to skip the iscoroutinefunction check. It is used for anything?

@jenshnielsen

@eendebakpt
Copy link
Contributor Author

@microsoft-github-policy-service agree company=TNO

@jenshnielsen
Copy link
Collaborator

@eendebakpt I don't think it's used much. Perhaps we could change the value for coroutine argument to coroutine: bool | None = None and skip the check if coroutine=None ? Note that I changed the import in #7753 since the function in asyncio was deprecated in python 3.14

@eendebakpt
Copy link
Contributor Author

@eendebakpt I don't think it's used much. Perhaps we could change the value for coroutine argument to coroutine: bool | None = None and skip the check if coroutine=None ? Note that I changed the import in #7753 since the function in asyncio was deprecated in python 3.14

Yes, I had a similar idea. Added to the PR!

Copy link
Collaborator

@jenshnielsen jenshnielsen left a comment

Choose a reason for hiding this comment

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

@eendebakpt Thanks, looks good. Could you run the precommit hooks and this should be good to merge. The other ci issue is resolved on main so should be fixed if you rebase or merge main into this

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