Nexusrex18 opened a new pull request, #2799:
URL: https://github.com/apache/dubbo-go/pull/2799
Fixes by replacing `copier.Copy` with a manual deep copy in `URL.Clone()`,
optimized with pre-allocated maps for `params` and `attributes`. This reduces
memory and CPU overhead, especially for large data volumes.
Key changes:
- Replaced `copier.Copy` with manual implementation in `URL.Clone()`.
- Removed `github.com/jinzhu/copier` import from `url.go` and dependency
from `go.mod` via `go mod tidy`.
- Added `TestSubURLCopy` to verify deep-copy behavior.
- Updated `BenchmarkClone` to test the new implementation.
Benchmarks:
- 100 params/attributes:
- Old (copier): 51 µs/op, 23.74 KB/op, 222 allocs/op
- New (manual): 26 µs/op, 14.12 KB/op, 112 allocs/op
- 1,000 params/attributes:
- Old (copier): 428 µs/op, 228 KB/op, 1,142 allocs/op
- New (manual): 270 µs/op, 197 KB/op, 1,010 allocs/op
The new implementation is faster (~1.6x at 1,000 entries, ~2x at 100), uses
less memory (~14% at 1,000, ~40% at 100), and reduces allocations (~12% at
1,000, ~50% at 100).
Note: Unrelated test failures in `rpc_service_test.go` (e.g., unexported
`testService`) were observed but pre-exist this change and are outside this
PR’s scope.
Fixes: #2678
Tested with:
- `go test -v -run TestSubURLCopy`: Passed
- `go test -bench=BenchmarkClone -benchmem`: Confirmed performance
--
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]