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:
wjqserver 2026-04-12 03:22:05 +08:00
parent e2719aa761
commit ba3dcf7624
9 changed files with 437 additions and 51 deletions

View file

@ -99,12 +99,24 @@ func TestMatcher_Compatibility(t *testing.T) {
config: cfgWithAuth,
expectedUser: "owner", expectedRepo: "repo", expectedMatcher: "raw",
},
{
name: "Malformed Raw Path (missing branch)",
rawPath: "https://raw.githubusercontent.com/owner/repo",
config: cfgWithAuth,
expectError: true, expectedErrCode: 400,
},
{
name: "Gist Path",
rawPath: "https://gist.github.com/user/abcdef1234567890",
config: cfgWithAuth,
expectedUser: "user", expectedRepo: "", expectedMatcher: "gist",
},
{
name: "Gist Path (user only)",
rawPath: "https://gist.github.com/user",
config: cfgWithAuth,
expectedUser: "user", expectedRepo: "", expectedMatcher: "gist",
},
{
name: "Gist UserContent Path",
rawPath: "https://gist.githubusercontent.com/user/abcdef1234567890",
@ -135,6 +147,18 @@ func TestMatcher_Compatibility(t *testing.T) {
config: cfgApiForceAllowed, // Auth disabled, but force allowed
expectedUser: "owner", expectedRepo: "repo", expectedMatcher: "api",
},
{
name: "API Repos Path (missing repo)",
rawPath: "https://api.github.com/repos/owner",
config: cfgWithAuth,
expectedUser: "", expectedRepo: "", expectedMatcher: "api",
},
{
name: "API Users Path (exact user)",
rawPath: "https://api.github.com/users/someuser",
config: cfgWithAuth,
expectedUser: "someuser", expectedRepo: "", expectedMatcher: "api",
},
{
name: "Malformed GH Path (no repo)",
rawPath: "https://github.com/owner/",