perf(common): avoid unnecessary allocations in URL IsEquals and ToMap
Background
IsEquals() currently converts both URLs to maps via ToMap(), deletes excluded keys, and then compares the maps. This creates avoidable allocations for a comparison-only path. ToMap() itself can also be tightened by pre-sizing the map and avoiding repeated string splits.
Related to #3248.
Scope
Optimize equality and map conversion paths:
- Rework
IsEquals()to compare fields and params directly without materializing two full maps when possible. - Treat excluded params through a small lookup set instead of deleting from copied maps.
- Keep
ToMap()public behavior unchanged, but reduce allocation work where possible. - Avoid repeated parsing of
Location; use a single-pass split strategy while preserving current host/port behavior.
Acceptance criteria
- Existing equality and
ToMap()tests continue to pass. - Add or update benchmarks for
IsEquals()andToMap()with small and larger param sets. - The PR shows
-benchmemoutput demonstrating lower allocations or no regression. go test ./commonpasses.
Hello, may I try to do this?
@ywxzm03 pls do https://github.com/apache/dubbo-go/issues/3391 first to see the performance shift
Kindly ask if there somebody to working for this issue ? If not, I am glad to undertake it!
Kindly ask if there somebody to working for this issue ? If not, I am glad to undertake it!
@ywxzm03 what about you do #3393 and leave #3394 to @JunLa-0 ?
#3393
ok
close via #3488