Removed duplicate call to GetDescriptorScriptPubKeyMan and Instead of checking linearly I have used find method so time complexity reduced significantly for GetDescriptorScriptPubKeyMan after this fix improved performance of importdescriptor part refs #32013.
Steps to reproduce in testnet environment
Input size: 2 million address in the wallet
Step1: call importaddresdescriptor rpc method observe the time it has taken.
With the provided fix: Do the same steps again observe the time it has taken.
There is a huge improvement in the performance. (previously it may take 5 to 6 seconds now it will take 1 seconds or less)
main changes i’ve made during this pr:
- remove duplicate call to GetDescriptorScriptPubKeyMan method
- And inside GetDescriptorScriptPubKeyMan method previously we checking each address linearly so each time it is calling HasWallet method which has aquired lock.
- Now i’ve modified this logic call find method on the map (O(logn)) time it is taking, so only once we calling HasWallet method.
Note: Smaller inputs in the wallet you may not see the issue but huge wallet size it will definitely impact the performance.