-
Notifications
You must be signed in to change notification settings - Fork 40.4k
Add handler to run execution in separate goroutine #120902
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
Conversation
/cc |
95bf6e7
to
c27b8df
Compare
Looks promising! Thank you! |
c27b8df
to
5336787
Compare
/retest |
57983bc
to
0d6cfcc
Compare
0d6cfcc
to
78f6266
Compare
78f6266
to
870ffba
Compare
87ddb5e
to
77fa66b
Compare
Added unit tests, feature gate and comments. Updated release notes to mention feature gate. |
/retest |
Gentle ping @wojtek-t |
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.
I want to look deeper into tests, but I think it's going the right direction.
877ae3a
to
3004566
Compare
908b627
to
ce80932
Compare
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.
One last comment - other than that LGTM.
@@ -1038,6 +1038,11 @@ func DefaultBuildHandlerChain(apiHandler http.Handler, c *Config) http.Handler { | |||
handler = genericapifilters.WithTracing(handler, c.TracerProvider) | |||
} | |||
handler = genericapifilters.WithLatencyTrackers(handler) | |||
// WithRoutine will execute future handlers in a separate goroutine and serving | |||
// handler in current goroutine to minimize the stack memory usage. | |||
if utilfeature.DefaultFeatureGate.Enabled(genericfeatures.APIServingWithRoutine) { |
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.
Please also add a comment that this has to be put after WithPanicRecovery (as it is now), but to ensure that someone will not change it later.
Also please squash the commits.
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.
Added comment and squashed.
This handler allows running execution prior to actual serving in a separate goroutine when serving requests. Doing so benefits cases in serving long running requests because it allows freeing memory used by the separate goroutine and keeps the serving routines slim. Signed-off-by: Eric Lin <[email protected]>
ce80932
to
7b2698a
Compare
/lgtm |
LGTM label has been added. Git tree hash: 17dba7f46e6a1facbf1cf08c28dbafadcad68362
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: linxiulei, wojtek-t 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 |
This handler allows running execution prior to actual serving in a separate goroutine when serving requests. Doing so benefits cases in serving long running requests because it allows freeing memory used by the separate goroutine and keeps the serving routines slim.
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #120901
Special notes for your reviewer:
Observed 150 MiB memory reduced in stack memory in the test that had 5000 active watch requests. The heap memory stayed roughly the same.
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: