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 92.30769% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 59.78%. Comparing base (b7ca673) to head (6dee3ec).

Files with missing lines Patch % Lines
src/qcodes/utils/function_helpers.py 92.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7669      +/-   ##
==========================================
+ Coverage   59.77%   59.78%   +0.01%     
==========================================
  Files         352      352              
  Lines       31683    31695      +12     
==========================================
+ Hits        18937    18949      +12     
  Misses      12746    12746              

☔ 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

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?

@eendebakpt
Copy link
Contributor Author

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

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