Skip to content

feat: add pprof endpoint for router#1057

Merged
volcano-sh-bot merged 1 commit into
volcano-sh:mainfrom
StLeoX:feat/router-pprof
May 18, 2026
Merged

feat: add pprof endpoint for router#1057
volcano-sh-bot merged 1 commit into
volcano-sh:mainfrom
StLeoX:feat/router-pprof

Conversation

@StLeoX
Copy link
Copy Markdown
Contributor

@StLeoX StLeoX commented May 15, 2026

/kind enhancement

closed #1056

Signed-off-by: Leo Xie <stleox@qq.com>
Copilot AI review requested due to automatic review settings May 15, 2026 03:59
@volcano-sh-bot volcano-sh-bot added the kind/enhancement New feature or request label May 15, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds pprof endpoints to the debug server for performance profiling. Feedback suggests including missing standard endpoints like cmdline, symbol, and trace to ensure full functionality with debugging tools, and using gin.WrapH for more idiomatic handler wrapping.

Comment on lines +138 to +144
pprofGroup.GET("/", gin.WrapF(pprof.Index))
pprofGroup.GET("/profile", gin.WrapF(pprof.Profile))
pprofGroup.GET("/goroutine", gin.WrapF(pprof.Handler("goroutine").ServeHTTP))
pprofGroup.GET("/heap", gin.WrapF(pprof.Handler("heap").ServeHTTP))
pprofGroup.GET("/allocs", gin.WrapF(pprof.Handler("allocs").ServeHTTP))
pprofGroup.GET("/block", gin.WrapF(pprof.Handler("block").ServeHTTP))
pprofGroup.GET("/mutex", gin.WrapF(pprof.Handler("mutex").ServeHTTP))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The current pprof implementation is missing several standard endpoints required for full functionality with debugging tools. Specifically, cmdline, symbol, trace, and threadcreate are missing. The symbol endpoint is critical for the pprof tool to resolve addresses to function names and must support both GET and POST methods. Additionally, using gin.WrapH is more idiomatic when wrapping an http.Handler returned by pprof.Handler.

Suggested change
pprofGroup.GET("/", gin.WrapF(pprof.Index))
pprofGroup.GET("/profile", gin.WrapF(pprof.Profile))
pprofGroup.GET("/goroutine", gin.WrapF(pprof.Handler("goroutine").ServeHTTP))
pprofGroup.GET("/heap", gin.WrapF(pprof.Handler("heap").ServeHTTP))
pprofGroup.GET("/allocs", gin.WrapF(pprof.Handler("allocs").ServeHTTP))
pprofGroup.GET("/block", gin.WrapF(pprof.Handler("block").ServeHTTP))
pprofGroup.GET("/mutex", gin.WrapF(pprof.Handler("mutex").ServeHTTP))
pprofGroup.GET("/", gin.WrapF(pprof.Index))
pprofGroup.GET("/cmdline", gin.WrapF(pprof.Cmdline))
pprofGroup.GET("/profile", gin.WrapF(pprof.Profile))
pprofGroup.POST("/symbol", gin.WrapF(pprof.Symbol))
pprofGroup.GET("/symbol", gin.WrapF(pprof.Symbol))
pprofGroup.GET("/trace", gin.WrapF(pprof.Trace))
pprofGroup.GET("/allocs", gin.WrapH(pprof.Handler("allocs")))
pprofGroup.GET("/block", gin.WrapH(pprof.Handler("block")))
pprofGroup.GET("/goroutine", gin.WrapH(pprof.Handler("goroutine")))
pprofGroup.GET("/heap", gin.WrapH(pprof.Handler("heap")))
pprofGroup.GET("/mutex", gin.WrapH(pprof.Handler("mutex")))
pprofGroup.GET("/threadcreate", gin.WrapH(pprof.Handler("threadcreate")))

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds runtime profiling support to the router’s localhost-only debug server, addressing the request to expose pprof diagnostics alongside existing debug/metrics capabilities.

Changes:

  • Imports Go’s net/http/pprof package.
  • Registers pprof endpoints on the router debug server under /debug/pprof.
  • Keeps profiling on the existing localhost-bound debug server.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +139 to +144
pprofGroup.GET("/profile", gin.WrapF(pprof.Profile))
pprofGroup.GET("/goroutine", gin.WrapF(pprof.Handler("goroutine").ServeHTTP))
pprofGroup.GET("/heap", gin.WrapF(pprof.Handler("heap").ServeHTTP))
pprofGroup.GET("/allocs", gin.WrapF(pprof.Handler("allocs").ServeHTTP))
pprofGroup.GET("/block", gin.WrapF(pprof.Handler("block").ServeHTTP))
pprofGroup.GET("/mutex", gin.WrapF(pprof.Handler("mutex").ServeHTTP))
@FAUST-BENCHOU
Copy link
Copy Markdown
Contributor

/lgtm

@volcano-sh-bot
Copy link
Copy Markdown
Contributor

@FAUST-BENCHOU: changing LGTM is restricted to collaborators

Details

In response to this:

/lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link
Copy Markdown
Member

@hzxuzhonghu hzxuzhonghu left a comment

Choose a reason for hiding this comment

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

/lgtm

@volcano-sh-bot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hzxuzhonghu

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

The pull request process is described here

Details 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

@volcano-sh-bot volcano-sh-bot merged commit 203d6b7 into volcano-sh:main May 18, 2026
20 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add profiling support for router in addition to metrics

5 participants