Use lru_cache on costly validation function. #291
Merged
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.
This gave me a 24% speedup when downloading a folder with 30,000 small files using
aws s3 cp
withpreferred_transfer_client=crt
on a 100Gbps machine. It speeds up theclassic
transfer client as well.When profiling this workload,
_validate_subscriber_methods()
had a big presence in the flame graph. Commenting out the validate function gave a huge speedup. But the validation is useful, so we didn't want to remove it. Using lru_cache provides the same speedup for the 30,000 file workload. It runs 6 times (once per subscriber class) instead of 180,000 times (6 times per file).