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

Avoid unnecessary decoding in etcd3 client #34435

Merged

Conversation

wojtek-t
Copy link
Member

@wojtek-t wojtek-t commented Oct 10, 2016

Ref #33653

With the "Cacher" layer in Kubernetes, most of the watches processed by "pkg/storage/etcd3/watcher.go" have "filter = Everything()". That said, we generally don't need to decode previous value of the object (which is used only to get the value of filter of it), because we already know it will be true.

This PR is basically fixing this problem.

Should be merged after #34246

etcd3: avoid unnecessary decoding in etcd3 client 

This change is Reviewable

@wojtek-t wojtek-t added do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. release-note-none Denotes a PR that doesn't merit a release note. labels Oct 10, 2016
@k8s-github-robot k8s-github-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 10, 2016
@k8s-ci-robot
Copy link
Contributor

Jenkins GCE Node e2e failed for commit 7f63c5d. Full PR test history.

The magic incantation to run this job again is @k8s-bot node e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@@ -52,6 +52,7 @@ type watchChan struct {
initialRev int64
recursive bool
filter storage.FilterFunc
filterAcceptsAll bool
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need this additional field? can we simply set filter to nil if we accept everything?

Copy link
Contributor

Choose a reason for hiding this comment

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

basically (wc *watchChan) acceptAll bool (return wc.filter == nil)

Copy link
Member Author

Choose a reason for hiding this comment

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

Well - that would mean that whenever we are accessing wc.filter, we need to check whether it is nil or not. This will complicate the code in my opinion.

Copy link
Contributor

Choose a reason for hiding this comment

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

@wojtek-t transform is not the only place we access it? if not, i agree.

Copy link
Member Author

Choose a reason for hiding this comment

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

transform is the only place, but there are 4 places in transform...

Copy link
Contributor

@xiang90 xiang90 Oct 10, 2016

Choose a reason for hiding this comment

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

This might be overkill, but still want to bring it up.

we can add another layer of abstraction to get rid of the duplicated field.

wc.filter() {
    if wc.internalFilter == nil{
        ...
    }
    wc.internalFilter()
}

wc.acceptAll {return wc.internalFilter == nil}

this is totally up to you though. not blocking issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK - if you think it's worth it, I can change that tomorrow.

res = &watch.Event{
Type: watch.Modified,
Object: curObj,
}
case curObjPasses && !oldObjPasses:
Copy link
Contributor

Choose a reason for hiding this comment

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

i feel we have too many indentations here. can we return directly in this case and remove the else at line 267?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@xiang90
Copy link
Contributor

xiang90 commented Oct 10, 2016

The idea looks good to me. @hongchaodeng Can you also take a look?

@wojtek-t wojtek-t force-pushed the avoid_unnecessary_decoding branch from 7f63c5d to fe706bb Compare October 10, 2016 18:02
@k8s-ci-robot
Copy link
Contributor

Jenkins GCI GCE e2e failed for commit fe706bb0d9f1ab0923ef459e98bc2341a96fcf15. Full PR test history.

The magic incantation to run this job again is @k8s-bot gci gce e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@hongchaodeng
Copy link
Contributor

The approach lgtm.
The part on prepareObjs() might need to be updated after rebasing #34246. Will take another look after that.

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 11, 2016
@wojtek-t wojtek-t force-pushed the avoid_unnecessary_decoding branch from fe706bb to b675b22 Compare October 11, 2016 08:39
@wojtek-t
Copy link
Member Author

@xiang90 @hongchaodeng - comments applied. PTAL

@wojtek-t wojtek-t removed the do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. label Oct 11, 2016
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 11, 2016
@k8s-ci-robot
Copy link
Contributor

Jenkins Kubemark GCE e2e failed for commit b675b22. Full PR test history.

The magic incantation to run this job again is @k8s-bot kubemark e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@wojtek-t
Copy link
Member Author

@k8s-bot gce e2e test this, issue: #IGNORE (firewall quota)

@wojtek-t
Copy link
Member Author

@k8s-bot kubemark test this, issue: #IGNORE (gcloud auth issues)

@wojtek-t
Copy link
Member Author

@k8s-bot gce e2e test this, issue: #IGNORE (firewall quota)

1 similar comment
@wojtek-t
Copy link
Member Author

@k8s-bot gce e2e test this, issue: #IGNORE (firewall quota)

@xiang90
Copy link
Contributor

xiang90 commented Oct 11, 2016

/lgtm

@k8s-github-robot k8s-github-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 11, 2016
@wojtek-t
Copy link
Member Author

@k8s-bot gce e2e test this, issue: #IGNORE (previous run didn't start)

@wojtek-t
Copy link
Member Author

I don't know why bot is not picking this up.

@k8s-bot gce e2e test this, issue: #33867

@xiang90
Copy link
Contributor

xiang90 commented Oct 11, 2016

@k8s-bot gce e2e test this, issue: #33867

@k8s-ci-robot
Copy link
Contributor

Jenkins GCE e2e failed for commit b675b22. Full PR test history.

The magic incantation to run this job again is @k8s-bot cvm gce e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@wojtek-t
Copy link
Member Author

@k8s-bot gce e2e test this, issue: #33867

@wojtek-t wojtek-t added the priority/backlog Higher priority than priority/awaiting-more-evidence. label Oct 12, 2016
@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue

@k8s-github-robot k8s-github-robot merged commit b65a07b into kubernetes:master Oct 12, 2016
@k8s-cherrypick-bot
Copy link

Removing label cherrypick-candidate because no release milestone was set. This is an invalid state and thus this PR is not being considered for cherry-pick to any release branch. Please add an appropriate release milestone and then re-add the label.

@wojtek-t wojtek-t added this to the v1.4 milestone Oct 19, 2016
@jessfraz jessfraz added cherry-pick-approved Indicates a cherry-pick PR into a release branch has been approved by the release branch manager. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Oct 20, 2016
k8s-github-robot pushed a commit that referenced this pull request Oct 21, 2016
#31704-#32831-#32907-#33003-#33349-#31190-#33581-#34089-#34234-#32822-#33393-#34246-#34435-#32477-upstream-release-1.4

Automatic merge from submit-queue

Automated cherry pick of #31189 #31704 #32831 #32907 #33003 #33349 #31190 #33581 #34089 #34234 #32822 #33393 #34246 #34435 #32477 upstream release 1.4

We are going to release etcd v3 in 1.4.x release.

```
Cherrypick etcd v3-related bug fixes to 1.4 branch
```

Those PRs include:
- Updates of etcd Godeps
- Update to pkg/storage/etcd directory
- Two PR that were unnecessary to avoid conflicts: #31189 #31704

Automated cherry pick of #31189 #31704 #32831 #32907 #33003 #33349 #31190 #33581 #34089 #34234 #32822 #33393 #34246 #34435 #32477

@hongchaodeng @xiang90 @lavalamp @smarterclayton
@k8s-cherrypick-bot
Copy link

Commit found in the "release-1.4" branch appears to be this PR. Removing the "cherrypick-candidate" label. If this is an error find help to get your PR picked.

@wojtek-t wojtek-t deleted the avoid_unnecessary_decoding branch November 18, 2016 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick-approved Indicates a cherry-pick PR into a release branch has been approved by the release branch manager. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/backlog Higher priority than priority/awaiting-more-evidence. release-note Denotes a PR that will be considered when it comes time to generate 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.

8 participants