-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Performance regression caused by dagnode op property #6493
Comments
After a quick check, it looks like there are about 400 instances of some form of |
If possible, I'd prefer to only access That said, I'm a little confused. |
That's my fault for a lack of precision in opening the issue. #6199 introduced a regression around In the issue I was conflating that with the changes made in #6433 which were about Maybe @IvanIsCoding can comment here about his profiling on the collect_2q_blocks pass to show the overhead from the function call. I agree with @kdk that we probably only want to do that in performance critical parts, but not generally. For example, in the circuit drawers (assuming it's used there, which I think it is) it wouldn't make sense to change anything. |
So in #6199, we deprecated the use of passing a |
I can jump in an say that in my particular case at #6433, The speedup by replacing
My advice is to benchmark and see if the gains in th specific case are worth it. In |
Out of curiosity, I ran the following through
(N.B. Python 3.6 on OSX 10.15 ) At least for this microbenchmark, it seems in general like That said, my preference here would be to either:
That we have a performance concern over convenience code that wraps and re-raises an |
Personally I think the subclass approach makes the most sense. That way we can avoid the property altogether. Having the explicit |
Information
What is the current behavior?
After PR #6199 merged a regression was flagged on our nightly benchmarks for certain transpiler passes where we're accessing a dag node's op frequently. For example:
https://qiskit.github.io/qiskit/#passes.PassBenchmarks.time_cx_cancellation?machine=dedicated-benchmarking-softlayer-baremetal&os=Linux%204.15.0-46-generic&ram=16GB&p-n_qubits=5&p-depth=1024&commits=3c979ebd
As was pointed out in #6433 this is caused by python function call overhead from using
@property
especially compared to a slotted attribute access that was there before..Steps to reproduce the problem
Run a transpiler pass or any dagnode operation that frequently uses
dagnode.op
What is the expected behavior?
No performance regression.
Suggested solutions
Either revert the change or change our internal dagnode usage to use the
_op
attribute on access for performance critical code (which is part of what #6433 does for one pass).The text was updated successfully, but these errors were encountered: