Skip to content

Conversation

hzxuzhonghu
Copy link
Member

@hzxuzhonghu hzxuzhonghu commented Mar 15, 2022

Please provide a description of this PR:

remove using copy structure for simple type.

@hzxuzhonghu hzxuzhonghu requested review from a team as code owners March 15, 2022 07:01
@istio-policy-bot istio-policy-bot added the release-notes-none Indicates a PR that does not require release notes. label Mar 15, 2022
@istio-testing istio-testing added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 15, 2022
@istio-testing istio-testing merged commit 68fa907 into istio:master Mar 15, 2022
@@ -825,25 +825,29 @@ func GetServiceAccounts(svc *Service, ports []int, discovery ServiceDiscovery) [
}

// DeepCopy creates a clone of Service.
// TODO : See if there is any efficient alternative to this function - copystructure can not be used as is because
// Service has sync.RWMutex that can not be copied.
func (s *Service) DeepCopy() *Service {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder if for our DeepCopy implementations we should add Fuzz tests comparing them to copystructure or something. Then we can ensure our performance optimizations are also correct

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

@hzxuzhonghu hzxuzhonghu deleted the opt-deepcopy branch March 16, 2022 01:26
aryan16 pushed a commit to aryan16/istio that referenced this pull request Mar 28, 2022
* optimize service deepcopy

* benchmark

* update

* fix lint
airbnb-gerrit pushed a commit to airbnb/istio that referenced this pull request Sep 13, 2022
DeepCopy using reflection is super slow, and a big chunk of init push
context time is doing deep copy. This is already improved a lot by
this PR: istio#37932 (init push context
time drop from 1m30s to 40s). ServiceAttribute DeepCopy is still
taking more than 10% cpu time, so improving this function can further
reduce the init push context time and hence our propagation delay.

Benchmark results:
(before)
goos: darwin
goarch: amd64
pkg: istio.io/istio/pilot/pkg/model
cpu: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
BenchmarkServiceDeepCopy
BenchmarkServiceDeepCopy-16    	  132760	      8190 ns/op
PASS

(after)
goos: darwin
goarch: amd64
pkg: istio.io/istio/pilot/pkg/model
cpu: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
BenchmarkServiceDeepCopy
BenchmarkServiceDeepCopy-16    	 1213035	      1019 ns/op
PASS

Change-Id: Ied3e81d252ccf226bbb8d1d56eb88bff7c146af4
Reviewed-on: https://gerrit.musta.ch/c/public/istio/+/3700
Reviewed-by: Douglas Jordan <douglas.jordan@airbnb.com>
Reviewed-by: Weibo He <weibo.he@airbnb.com>
istio-testing pushed a commit that referenced this pull request Sep 14, 2022
* istio: improve deep copy for service attributes

DeepCopy using reflection is super slow, and a big chunk of init push
context time is doing deep copy. This is already improved a lot by
this PR: #37932 (init push context
time drop from 1m30s to 40s). ServiceAttribute DeepCopy is still
taking more than 10% cpu time, so improving this function can further
reduce the init push context time and hence our propagation delay.

Benchmark results:
(before)
goos: darwin
goarch: amd64
pkg: istio.io/istio/pilot/pkg/model
cpu: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
BenchmarkServiceDeepCopy
BenchmarkServiceDeepCopy-16    	  132760	      8190 ns/op
PASS

(after)
goos: darwin
goarch: amd64
pkg: istio.io/istio/pilot/pkg/model
cpu: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
BenchmarkServiceDeepCopy
BenchmarkServiceDeepCopy-16    	 1213035	      1019 ns/op
PASS

Change-Id: Ied3e81d252ccf226bbb8d1d56eb88bff7c146af4
Reviewed-on: https://gerrit.musta.ch/c/public/istio/+/3700
Reviewed-by: Douglas Jordan <douglas.jordan@airbnb.com>
Reviewed-by: Weibo He <weibo.he@airbnb.com>

* istio: fix lint

AddressMap contains a mutex which govet complains if we return a
copy, ignoring the vet error (behavior is the same as before).

Change-Id: If0274e6e1412eb50586ea609a07c302557297ad8
Reviewed-on: https://gerrit.musta.ch/c/public/istio/+/3706
Reviewed-by: Weibo He <weibo.he@airbnb.com>
istio-testing pushed a commit to istio-testing/istio that referenced this pull request Jan 4, 2023
DeepCopy using reflection is super slow, and a big chunk of init push
context time is doing deep copy. This is already improved a lot by
this PR: istio#37932 (init push context
time drop from 1m30s to 40s). ServiceAttribute DeepCopy is still
taking more than 10% cpu time, so improving this function can further
reduce the init push context time and hence our propagation delay.

Benchmark results:
(before)
goos: darwin
goarch: amd64
pkg: istio.io/istio/pilot/pkg/model
cpu: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
BenchmarkServiceDeepCopy
BenchmarkServiceDeepCopy-16    	  132760	      8190 ns/op
PASS

(after)
goos: darwin
goarch: amd64
pkg: istio.io/istio/pilot/pkg/model
cpu: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
BenchmarkServiceDeepCopy
BenchmarkServiceDeepCopy-16    	 1213035	      1019 ns/op
PASS

Change-Id: Ied3e81d252ccf226bbb8d1d56eb88bff7c146af4
Reviewed-on: https://gerrit.musta.ch/c/public/istio/+/3700
Reviewed-by: Douglas Jordan <douglas.jordan@airbnb.com>
Reviewed-by: Weibo He <weibo.he@airbnb.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-notes-none Indicates a PR that does not require release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants