-
Notifications
You must be signed in to change notification settings - Fork 933
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
Project limits: Use InstanceList
#14318
Conversation
fa5e693
to
14d5679
Compare
Had a weird error on the CI, unlikely to be related but I'll at least document it here:
|
14d5679
to
6532546
Compare
"ToAPI" is also used for the database types (db.Instance), and in that context it implies trips to the database rather than just shuffling fields around. Happy to rename as needed. Signed-off-by: Wesley Hershberger <wesley.hershberger@canonical.com>
6532546
to
112e5aa
Compare
|
This at least gets us from `O(n)` queries to `O(1)` (where n is instances). InstanceList does a lot of unnecessary faffing around with profiles that ends up getting thrown out (looks like about 4 queries whose results end up being dropped). Signed-off-by: Wesley Hershberger <wesley.hershberger@canonical.com>
112e5aa
to
6d46fd6
Compare
I've put up a revision here that at least gets us from What do you think of something like this? // lxd/db/projects.go
type ProjectArgs struct {
Project api.Project
Profiles []api.Profile
Instances []api.Instance
}
func (c *ClusterTx) ProjectsList(ctx context.Context, filters ...cluster.ProjectFilter) ([]ProjectArgs, error) I've done a little fiddling here and have about 3/4 an implementation if you'd like me to pursue that further. Otherwise I'll get back to bugs. |
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.
@MggMuggins after the improvements landed in #14315 do you feel this is still worthwhile, are you saying InstanceList is doing unnecessary things all of the time or just in this context?
The changes I've made here go from It's inefficient because |
The use of `InstanceList` I introduced in #14318 causes 3 queries (`GetProfiles`, `GetConfig`, `GetDevices`) to be run twice. This eliminates the duplication. ## TODO - [x] Rename `ProjectsList` -> `GetProjectInstancesAndProfiles` - [ ] Rename `ProjectArgs` -> `ProjectInstances` (`ProjectEntities`? `ProjectInstancesAndProfiles`?, ...?) - [x] Fix snapshots
Follow-up to #14315
This tidies up the queries used for project limits checking; it likely results in improved performance for clusters with many entities.