Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[patch] Test/internal/tcp #501

Merged
merged 53 commits into from
Jul 17, 2020
Merged

[patch] Test/internal/tcp #501

merged 53 commits into from
Jul 17, 2020

Conversation

kevindiu
Copy link
Contributor

@kevindiu kevindiu commented Jun 22, 2020

Author review required!!!!
Maybe performance test required before merging.

Description:

Sorry for this PR become so huge :(

This PR includes the following changes:

  • enhancement: fetch DNS cache in round robin order instead of random order (which may cause performance problem since it is not balanced)
  • enhancement: do not lookup DNS when the address passed to cachedDialer() is IP address
  • bug fix: DNS cache expire hook not executed
  • bug fix: dialerKeepAlive did not set properly
  • internal/tcp package test
  • code refactoring

The test coverage is over 90% in internal/net/tcp package.

When I working on this PR, I found a bug about sharing cache. and I created a PR for this bug fix. #560

Performance result:

Gateway replicas: 10
Agent replicas: 30
Dataset: random-786-100000
Concurrency: 32
Batch size: 100

Insert mode (100000 random vectors)

Nightly branch (20200713)
Average VPS for each run:

5395.421578
6424.425950
6425.912179
6461.443722
5988.220358
6493.199904
6486.264278
6335.389072
6129.457926
6659.673990

Variance

Total Average: 6279.9408957


PR-501
Average VPS for each run:

6217.897276
6673.575530
6976.387795
6890.498418
6487.006260
6585.224161
6734.012306
6966.123523
5937.095263
6751.386072

Variance

Total Average: 6621.9206604 (+ 5.4455 % )

Search Mode

Nightly branch (20200714)
Average VPS for each run:

55342.011671
55041.653094
54863.910108
55507.475455
54847.253156
55087.350757
54773.136435
55560.020191
55438.817729
55180.390630

Variance

Total Average: 55164.2019226


PR501
Average VPS for each run:

53006.025749
54954.973641
55533.508719
55152.016128
55107.615004
55149.334190
55255.700455
55688.780070
54430.523454
54487.434100

Variance

Total Average: 54876.591151 (- 0.521372124%)

Search Mode (with 20000 random data & 3 index replica)

Nightly branch (20200715):
Average VPS for each run:

54754.772502
54210.456157
55277.095015
54375.751102
54606.793579
54980.820024
55043.223001
54279.938913
54407.296268
54939.336378

Variance

Total Average: 54687.5482939


PR 501:
Average VPS for each run:

54635.047079
54744.703738
55256.844790
54916.153493
55260.394869
54986.154799
55572.723950
54315.390605
55549.817220
53304.934344

Variance

Total Average: 54854.2164888 (+ 3%)

Related Issue:

How Has This Been Tested?:

Environment:

  • Go Version: 1.14.3
  • Docker Version: 19.03.8
  • Kubernetes Version: 1.18.2
  • NGT Version: 1.11.5

Types of changes:

  • Bug fix [type/bug]
  • New feature [type/feature]
  • Add tests [type/test]
  • Security related changes [type/security]
  • Add documents [type/documentation]
  • Refactoring [type/refactoring]
  • Update dependencies [type/dependency]
  • Update benchmarks and performances [type/bench]
  • Update CI [type/ci]

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Checklist:

  • I have read the CONTRIBUTING document.
  • I have checked open Pull Requests for the similar feature or fixes?
  • I have added tests and benchmarks to cover my changes.
  • I have ensured all new and existing tests passed.
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly.

@pull-assistant
Copy link

pull-assistant bot commented Jun 22, 2020

Score: 0.93

Best reviewed: commit by commit


Optimal code review plan (9 warnings)

refactor

internal/net/tcp/dialer.go 75% changes removed in fix

     bug fix

     add test code

     add test case

     improve performance

fix test

internal/net/tcp/dialer.go 60% changes removed in fix

     fix template and rename file

     add option test and missing file

refactor

internal/net/tcp/dialer.go 46% changes removed in fix

fix

internal/net/tcp/dialer.go 50% changes removed in add test case

     use thread safe

     fix

     Apply suggestions from code review

     fix

     fix failed test case

     fix

     fix

     add test case

     fix

fix

...nternal/net/tcp/dialer_test.go 80% changes removed in fix

fix

...nternal/net/tcp/dialer_test.go 56% changes removed in add connection check...

     fix

fix

internal/net/tcp/dialer.go 60% changes removed in Update internal/net/...

     fix

     fix

fix

internal/net/tcp/dialer.go 67% changes removed in fix

     fix

     fix

     revert change of cache bug fix

     Merge remote-tracking branch 'origin/master' into test/internal/tcp

fix lint

internal/net/tcp/dialer.go 50% changes removed in fix

     fix

     🤖 Update license headers / Format go codes and yaml files

     fix comment

     Apply suggestions from code review

     add connection check testing

     fix

     Merge branch 'master' into test/internal/tcp

     Merge branch 'master' into test/internal/tcp

     Merge branch 'master' into test/internal/tcp

     fix

     Merge branch 'master' into test/internal/tcp

     add comment to option.go

     Update internal/net/tcp/option.go

     Merge branch 'master' into test/internal/tcp

     fix deepsource

     fix

     Apply suggestions from code review

     remove failed and unused test

     Update internal/net/tcp/dialer.go

     Update internal/net/tcp/dialer.go

     rename function name

     fix comment

Powered by Pull Assistant. Last update 1572b71 ... c5b390d. Read the comment docs.

"github.com/vdaas/vald/internal/errors"
"github.com/vdaas/vald/internal/net"

"go.uber.org/goleak"
)

var (
goleakIgnoreOptions = []goleak.Option{
Copy link
Contributor

Choose a reason for hiding this comment

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

[golangci] reported by reviewdog 🐶
goleakIgnoreOptions is a global variable (gochecknoglobals)

internal/net/tcp/dialer.go Outdated Show resolved Hide resolved
internal/net/tcp/dialer_test.go Outdated Show resolved Hide resolved
return !(x == nil && y != nil) || !(y == nil && x != nil)
}),
cmp.Comparer(func(x, y tls.Config) bool {
return reflect.DeepEqual(x, y)
Copy link
Contributor

Choose a reason for hiding this comment

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

[golangci] reported by reviewdog 🐶
copylocks: call of reflect.DeepEqual copies lock value: crypto/tls.Config contains sync.Once contains sync.Mutex (govet)

@codecov
Copy link

codecov bot commented Jun 22, 2020

Codecov Report

Merging #501 into master will increase coverage by 0.60%.
The diff coverage is 92.85%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #501      +/-   ##
==========================================
+ Coverage   11.08%   11.69%   +0.60%     
==========================================
  Files         403      404       +1     
  Lines       20930    20928       -2     
==========================================
+ Hits         2321     2448     +127     
+ Misses      18340    18213     -127     
+ Partials      269      267       -2     
Impacted Files Coverage Δ
internal/errors/net.go 0.00% <0.00%> (ø)
internal/net/tcp/dialer.go 94.93% <96.22%> (+94.93%) ⬆️
internal/net/tcp/option.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ba21911...c5b390d. Read the comment docs.

@kevindiu
Copy link
Contributor Author

/rebase

@vdaas-ci
Copy link
Collaborator

[REBASE] Rebase triggered by kevindiu for branch: test/internal/tcp

@github-actions github-actions bot added size/XXL and removed size/XL labels Jun 24, 2020
@kevindiu
Copy link
Contributor Author

/rebase

@vdaas-ci
Copy link
Collaborator

[REBASE] Rebase triggered by kevindiu for branch: test/internal/tcp

internal/net/tcp/dialer.go Outdated Show resolved Hide resolved
internal/net/tcp/dialer.go Outdated Show resolved Hide resolved
internal/net/tcp/dialer.go Outdated Show resolved Hide resolved
@kevindiu
Copy link
Contributor Author

/rebase

@vdaas-ci
Copy link
Collaborator

[REBASE] Rebase triggered by kevindiu for branch: test/internal/tcp

@kevindiu
Copy link
Contributor Author

/rebase

@vdaas-ci
Copy link
Collaborator

[REBASE] Rebase triggered by kevindiu for branch: test/internal/tcp

internal/net/tcp/dialer.go Outdated Show resolved Hide resolved
@kevindiu
Copy link
Contributor Author

kevindiu commented Jul 14, 2020

@vankichi

Is this result statistically significant?

I think no. It decrease 0.5% searching performance but increase 5% insert performance

And, could you give us the variance value not only ave.?

I have updated the description for more details.Please tell me if you have more questions :)

@rinx
Copy link
Contributor

rinx commented Jul 14, 2020

Insert: nightly
Insert: pr-501
Search: nightly
Search: pr-501

@kevindiu
Copy link
Contributor Author

@rinx thank you!

@kevindiu
Copy link
Contributor Author

/rebase

@vdaas-ci
Copy link
Collaborator

[REBASE] Rebase triggered by kevindiu for branch: test/internal/tcp

@vdaas-ci
Copy link
Collaborator

[REBASE] Failed to rebase.

}(),
func() test {
tc := &tls.Config{
InsecureSkipVerify: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

[golangci] reported by reviewdog 🐶
G402: TLS InsecureSkipVerify set true. (gosec)

kpango
kpango previously approved these changes Jul 17, 2020
Copy link
Collaborator

@kpango kpango left a comment

Choose a reason for hiding this comment

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

LGTM


func (d *dialer) cacheExpireHook(ctx context.Context, addr string) {
if err := safety.RecoverFunc(func() error {
_, err1 := d.lookup(ctx, addr)
Copy link
Collaborator

Choose a reason for hiding this comment

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

please do not use numbering variable

Suggested change
_, err1 := d.lookup(ctx, addr)
_, err1 := d.lookup(ctx, addr)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@kpango kpango dismissed their stale review July 17, 2020 05:26

need fix

internal/net/tcp/dialer.go Outdated Show resolved Hide resolved
Comment on lines 196 to 198
if err := safety.RecoverFunc(func() error {
_, err1 := d.lookup(ctx, addr)
return err1
_, lerr := d.lookup(ctx, addr)
return lerr
Copy link
Collaborator

Choose a reason for hiding this comment

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

please use named return lerr looks dirty

internal/net/tcp/dialer.go Outdated Show resolved Hide resolved

// GetIP returns the next cached IP address in round robin order.
// It starts getting the index 1 cache instead of index 0 cache.
func (d *dialerCache) GetIP() string {
Copy link
Collaborator

Choose a reason for hiding this comment

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

could you please change function naming to IP()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed :)

if d.dnsCache && !isIP {
if dc, err := d.lookup(dctx, host); err == nil {
for i := uint32(0); i < dc.Len(); i++ {
if conn, err := d.dial(dctx, network, fmt.Sprintf("%s:%d", dc.IP(), port)); err == nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

fmt.Sprintf is slow is there any plan to improve performance?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think strconv.FormatInt is better than Sprint

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed! thank you :)

Copy link
Collaborator

@kpango kpango left a comment

Choose a reason for hiding this comment

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

LGTM

@kpango kpango merged commit 08c5fdf into master Jul 17, 2020
@kpango kpango deleted the test/internal/tcp branch July 17, 2020 06:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants