very simple strong-cache on model list #4969
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 is based on the same work as #4968 but a much simpler and more agreeable approach: when object_info is hit, use a strong cache to ensure each model list is read exactly once, rather than once per node - ie skip the cache validation within the current call, until the next object_info hit.
Currently only
/object_info
triggers a cache clear, but it can be made to apply to/object_info/{x}
and/models/{x}
as well if desired. (I'd argue that strong caching in those subcalls is desired, as only/object_info
is intended as a 'refresh' - though also a separate dedicated/refresh
route would be preferred imo)For this code I made a nice lil subclass helper doodle to reduce the amount of chaotic global variable pollution in that file a bit.
The practical result is, in the ultra-high-latency test env I set up, time to read
/object_info
using just this cache PR alone reduces from 70 seconds to 23 seconds.The cache hit/miss pattern of a pure default comfy with no custom nodes for
/object_info
is: