Replace copier.Copy with optimized manual deep copy in URL.Clone (#2678)#2798
Closed
Nexusrex18 wants to merge 1 commit intoapache:mainfrom
Closed
Replace copier.Copy with optimized manual deep copy in URL.Clone (#2678)#2798Nexusrex18 wants to merge 1 commit intoapache:mainfrom
Nexusrex18 wants to merge 1 commit intoapache:mainfrom
Conversation
Signed-off-by: Nexusrex18 <lavisnj350@gmail.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes by replacing
copier.Copywith a manual deep copy inURL.Clone(), optimized with pre-allocated maps forparamsandattributes. This reduces memory and CPU overhead, especially for large data volumes.Key changes:
copier.Copywith manual implementation inURL.Clone().github.com/jinzhu/copierimport fromurl.goand dependency fromgo.modviago mod tidy.TestSubURLCopyto verify deep-copy behavior.BenchmarkCloneto test the new implementation.Benchmarks:
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., unexportedtestService) were observed but pre-exist this change and are outside this PR’s scope.Fixes: #2678
Tested with:
go test -v -run TestSubURLCopy: Passedgo test -bench=BenchmarkClone -benchmem: Confirmed performance