[feat] Add lru_cache
to import_utils
calls that did not previously have it
#1584
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.
Fixes #1576
Adding @cache to the functions in
import_utils
results in a constant time for LORA loading, regardless of the length of python path. Have verified this using a python path with 50,000 directories - previously the lora load time was 259 seconds, now it's down to a constant time of 1.3 seconds 👍🏻With some flamegraphs to prove! Before:
![profile](https://private-user-images.githubusercontent.com/54301847/316355412-99d42c8f-b9f8-4259-a5df-3f067823c860.svg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzMDIyNTYsIm5iZiI6MTczOTMwMTk1NiwicGF0aCI6Ii81NDMwMTg0Ny8zMTYzNTU0MTItOTlkNDJjOGYtYjlmOC00MjU5LWE1ZGYtM2YwNjc4MjNjODYwLnN2Zz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjExVDE5MjU1NlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTBlZjk0YjlkNmRmOTUwMDBlYTc5MmQyN2ZkNTI4ODZhOGQ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