Optimize update_pool_config()
#17969
Open
+98
−70
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Please review this one commit at a time.
The last commit is updating the test (which relies on monkeypatch and a specific implementation). The functions that are monkeypatched are changed which has some other ripple effects.
Purpose:
currently,
update_pool_config()
loads the configs, makes changes to it, then callsupdate_config()
.update_config()
, again, loads the config file under the file lock, updates it, and saves it.The patched version avoid the redundant re-loading of the config by loading it under the lock file directly. It also avoids some unnecessary parsing of the fields.
In my test wallet this brings the loading time from 70 seconds to 45 seconds.
It's still really slow, primarily because of the YAML parsing library we use.
Current Behavior:
update pool config takes 70 seconds
New Behavior:
update pool config takes 45 seconds
profile before:
profile after:
log of timings before
log of timings after