dubbo-go icon indicating copy to clipboard operation
dubbo-go copied to clipboard

perf(common): reduce URL CloneWithFilter and MergeURL params copying

Open Alanxtl opened this issue 5 months ago • 4 comments

Background

URL.CloneWithFilter() and URL.MergeURL() are used in registry, directory, configurator, and invoker update flows. These methods currently perform multiple map copies and repeated locking through public helper methods. That is safe, but it is expensive on hot update paths.

Related to #3248.

Scope

Reduce copying and locking in clone/merge paths:

  • Keep public GetParams() / CopyParams() safety semantics unchanged.
  • Introduce internal helpers for copying or merging url.Values under a single lock where possible.
  • Avoid calling SetParam once per key in CloneWithFilter() when the new URL is still local and not shared.
  • Avoid extra GetParams() copies in MergeURL() when the code only needs to build the merged params map.
  • Preserve multi-value parameter semantics when cloning and merging.

Acceptance criteria

  • Existing behavior is preserved for clone, filtered clone, and merge.
  • Add tests for multi-value params through CloneWithFilter() and MergeURL() if missing.
  • Add or update benchmarks showing allocation reduction for clone and merge cases with -benchmem.
  • go test ./common passes.

Alanxtl avatar Jun 09 '26 08:06 Alanxtl

please assign to me

Vanillaxi avatar Jun 10 '26 08:06 Vanillaxi

please assign to me

SURE

Alanxtl avatar Jun 10 '26 13:06 Alanxtl

Kindly ask if there somebody to working for this issue ? If not, I am glad to undertake it!

JunLa-0 avatar Jun 12 '26 00:06 JunLa-0

close via #3403

Alanxtl avatar Jun 13 '26 05:06 Alanxtl