mochengqian commented on code in PR #965:
URL: https://github.com/apache/dubbo-go-pixiu/pull/965#discussion_r3392965045
##########
pkg/filter/llm/proxy/filter.go:
##########
@@ -582,12 +582,11 @@ func newCooldownKey(clusterName string, endpoint
*model.Endpoint) cooldownKey {
}
}
-func endpointCredentialHash(endpoint *model.Endpoint) string {
Review Comment:
意义是减少热路径 allocation。
原589: sum := sha256.Sum256([]byte(endpoint.LLMMeta.APIKey))
原590: return fmt.Sprintf("%x", sum)
这里64 字节 hex string,通常会分配,要是换成[32]byte,可直接作为map key.
原来的 hex string 只是为了让 hash 可比较,但 Go 的 [32]byte 本来就可比较,也能放进 struct map key。所以
hex 编码这一步不就是纯开销了吗。删掉它可以少一次格式化和 heap allocation。
您要是觉得没意义我就把PR关了 @AlexStocks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]