mirror of
https://github.com/WJQSERVER-STUDIO/ghproxy.git
synced 2026-06-13 23:57:37 +08:00
perf(proxy): optimize hot request paths
- Cache route handlers, simplify NoRoute path normalization, and reduce matcher/header allocations - Honor configured transport pool limits in auto mode and add hotpath regression benchmarks/tests
This commit is contained in:
parent
e2719aa761
commit
ba3dcf7624
9 changed files with 437 additions and 51 deletions
|
|
@ -39,10 +39,13 @@ func initHTTPClient(cfg *config.Config) *httpc.Client {
|
|||
switch cfg.Httpc.Mode {
|
||||
case "auto", "":
|
||||
tr = &http.Transport{
|
||||
IdleConnTimeout: 30 * time.Second,
|
||||
WriteBufferSize: 32 * 1024, // 32KB
|
||||
ReadBufferSize: 32 * 1024, // 32KB
|
||||
Protocols: proTolcols,
|
||||
MaxIdleConns: cfg.Httpc.MaxIdleConns,
|
||||
MaxConnsPerHost: cfg.Httpc.MaxConnsPerHost,
|
||||
MaxIdleConnsPerHost: cfg.Httpc.MaxIdleConnsPerHost,
|
||||
IdleConnTimeout: 30 * time.Second,
|
||||
WriteBufferSize: 32 * 1024, // 32KB
|
||||
ReadBufferSize: 32 * 1024, // 32KB
|
||||
Protocols: proTolcols,
|
||||
}
|
||||
case "advanced":
|
||||
tr = &http.Transport{
|
||||
|
|
@ -77,9 +80,12 @@ func initGitHTTPClient(cfg *config.Config) {
|
|||
switch cfg.Httpc.Mode {
|
||||
case "auto", "":
|
||||
gittr = &http.Transport{
|
||||
IdleConnTimeout: 30 * time.Second,
|
||||
WriteBufferSize: 32 * 1024, // 32KB
|
||||
ReadBufferSize: 32 * 1024, // 32KB
|
||||
MaxIdleConns: cfg.Httpc.MaxIdleConns,
|
||||
MaxConnsPerHost: cfg.Httpc.MaxConnsPerHost,
|
||||
MaxIdleConnsPerHost: cfg.Httpc.MaxIdleConnsPerHost,
|
||||
IdleConnTimeout: 30 * time.Second,
|
||||
WriteBufferSize: 32 * 1024, // 32KB
|
||||
ReadBufferSize: 32 * 1024, // 32KB
|
||||
}
|
||||
case "advanced":
|
||||
gittr = &http.Transport{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue