Skip to content
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

gwctl performance improvements #3145

Merged
merged 2 commits into from
Jun 12, 2024

Conversation

gauravkghildiyal
Copy link
Member

What type of PR is this?
/kind feature

What this PR does / why we need it:
Summary of changes (details available in commit logs):

  1. Prioritize fetching resources in bulk rather than individually to reduce API call overhead. (Some simple performance tests with large number of resources indicated this provides the better overall UX)

  2. Fetch events associated with resources on-demand when printing, enhancing responsiveness and minimizing unnecessary API calls (since events are not required in GET output)

Which issue(s) this PR fixes:

Fixes #

Does this PR introduce a user-facing change?:

NONE

/assign @mlavacca

Eg. When we have a set of HTTPRoutes and we want to fetch all Backends
referenced by this HTTPRoute, it's slightly better to fetch all the Backends
with one API call and then filter these out based on which are being referenced.
This is in contrast with fetching each individual backend through a separate API
call that is referenced by the HTTPRoutes. (Even at smaller scales, multiple API
calls starts to seem inefficient)
Events associated with a resource need to be fetch independently for each
resource. This means the number of API calls grows linearly with the number of
resources that we have.
- Pre-fetching events for all resources BEFORE PRINTING ANYTHING gives the
  impression of the CLI being unresponsive.
- Lazily fetching events allows us to print the describe-view for a single
  resource fully before fetching events for the next one, thereby giving the
  user an impression of the CLI making progress.

Also, it makes sense for Events to not be part of the ResourceModel given events
are just tied with a single resource and have no interdependence (so don't need
some pre-calculations)
@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jun 10, 2024
@k8s-ci-robot k8s-ci-robot added area/gwctl size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 10, 2024
Copy link
Member

@mlavacca mlavacca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me, thanks @gauravkghildiyal!

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 12, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gauravkghildiyal, mlavacca

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 51c1919 into kubernetes-sigs:main Jun 12, 2024
8 checks passed
@gauravkghildiyal gauravkghildiyal deleted the gwctl-perf branch June 12, 2024 17:27
BobyMCbobs pushed a commit to BobyMCbobs/kubernetes-sigs-gateway-api that referenced this pull request Jul 10, 2024
* Fetch resources in bulk instead of single API calls as the default.

Eg. When we have a set of HTTPRoutes and we want to fetch all Backends
referenced by this HTTPRoute, it's slightly better to fetch all the Backends
with one API call and then filter these out based on which are being referenced.
This is in contrast with fetching each individual backend through a separate API
call that is referenced by the HTTPRoutes. (Even at smaller scales, multiple API
calls starts to seem inefficient)

* Lazily fetch events instead of making them part of the ResourceModel.

Events associated with a resource need to be fetch independently for each
resource. This means the number of API calls grows linearly with the number of
resources that we have.
- Pre-fetching events for all resources BEFORE PRINTING ANYTHING gives the
  impression of the CLI being unresponsive.
- Lazily fetching events allows us to print the describe-view for a single
  resource fully before fetching events for the next one, thereby giving the
  user an impression of the CLI making progress.

Also, it makes sense for Events to not be part of the ResourceModel given events
are just tied with a single resource and have no interdependence (so don't need
some pre-calculations)
BobyMCbobs pushed a commit to BobyMCbobs/kubernetes-sigs-gateway-api that referenced this pull request Jul 22, 2024
* Fetch resources in bulk instead of single API calls as the default.

Eg. When we have a set of HTTPRoutes and we want to fetch all Backends
referenced by this HTTPRoute, it's slightly better to fetch all the Backends
with one API call and then filter these out based on which are being referenced.
This is in contrast with fetching each individual backend through a separate API
call that is referenced by the HTTPRoutes. (Even at smaller scales, multiple API
calls starts to seem inefficient)

* Lazily fetch events instead of making them part of the ResourceModel.

Events associated with a resource need to be fetch independently for each
resource. This means the number of API calls grows linearly with the number of
resources that we have.
- Pre-fetching events for all resources BEFORE PRINTING ANYTHING gives the
  impression of the CLI being unresponsive.
- Lazily fetching events allows us to print the describe-view for a single
  resource fully before fetching events for the next one, thereby giving the
  user an impression of the CLI making progress.

Also, it makes sense for Events to not be part of the ResourceModel given events
are just tied with a single resource and have no interdependence (so don't need
some pre-calculations)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/gwctl cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants