-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf: cache RepositoryPool.package()
in Provider
#10114
Conversation
Reviewer's Guide by SourceryThis pull request introduces a performance optimization by caching the Sequence diagram showing the optimized package resolution flowsequenceDiagram
participant Provider
participant Cache as Function Cache
participant RepositoryPool
participant Repository
Provider->>Cache: Check cached package
alt Cache hit
Cache-->>Provider: Return cached package
else Cache miss
Provider->>RepositoryPool: package(name, version)
RepositoryPool->>Repository: package(name, version)
Repository-->>RepositoryPool: Return package
RepositoryPool-->>Provider: Return package
Provider->>Cache: Store in cache
end
Class diagram showing the modified package-related classesclassDiagram
class RepositoryPool {
-repositories: list
+package(name: str, version: Version, repository_name: str|None): Package
+repository(name: str): Repository
}
class Provider {
-_pool: RepositoryPool
-_get_package_from_pool: cached_function
+complete_package(dependency: Dependency, package: Package): DependencyPackage
}
class AbstractRepository {
<<abstract>>
+package(name: str, version: Version): Package
}
class Repository {
+package(name: str, version: Version): Package
}
class CachedRepository {
+package(name: str, version: Version): Package
}
class LegacyRepository {
+package(name: str, version: Version): Package
}
AbstractRepository <|-- Repository
Repository <|-- CachedRepository
Repository <|-- LegacyRepository
Provider o-- RepositoryPool
note for Provider "Added caching for _pool.package()"
note for RepositoryPool "Simplified package() method
Removed extras parameter"
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @radoering - I've reviewed your changes - here's some feedback:
Overall Comments:
- Please add tests to verify the caching behavior and ensure removing the extras parameter doesn't cause any regressions.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Pull Request Check List
This should be safe because we do not change the
RepositoryPool
while resolving and the returned package is used read-only.Testing with the pyproject.toml from #9956 (comment):
Summary by Sourcery
Cache the
RepositoryPool.package()
method in theProvider
class to improve performance during dependency resolution.Enhancements:
Tests: