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

P&F: Enable support for indexes in watch tracker #105974

Merged
merged 2 commits into from
Nov 2, 2021

Conversation

wojtek-t
Copy link
Member

Ref #105804

NONE

/kind bug
/priority important-soon
/sig api-machinery

/assign @MikeSpreitzer @tkashem

@k8s-ci-robot k8s-ci-robot added the release-note-none Denotes a PR that doesn't merit a release note. label Oct 28, 2021
@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Oct 28, 2021
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. area/apiserver labels Oct 28, 2021
return w.forgetWatch(identifier, index)
}

func (w *watchTracker) updateIndexLocked(identifier *watchIdentifier, index *indexValue, incr int) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Obviously we want to add tests for it before submitting - but I wanted to get your thoughts if this is acceptable (for the sake of making progress on it).
@MikeSpreitzer @tkashem

@fedebongio
Copy link
Contributor

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Oct 28, 2021
@tkashem
Copy link
Contributor

tkashem commented Oct 29, 2021

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 29, 2021
@tkashem
Copy link
Contributor

tkashem commented Oct 29, 2021

didn't realize that verify is failing, looks good to me otherwise

/lgtm cancel

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 29, 2021
Copy link
Member

@MikeSpreitzer MikeSpreitzer left a comment

Choose a reason for hiding this comment

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

It is certainly safe while we have the usage of these watch counts disabled!

Considering that we had no usage of watch counts in earlier releases, I think this would be a safe step to take even the watch counts get used.

Comment on lines +71 to +73
// builtinIndexes represents of set of indexes registered in
// watchcache that are indexing watches and increase speed of
// their processing.
Copy link
Member

Choose a reason for hiding this comment

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

It would be good to include an explanation of what the keys and values are.

Copy link
Member Author

Choose a reason for hiding this comment

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

added

watchCount map[watchIdentifier]int
}

func NewWatchTracker() WatchTracker {
return &watchTracker{
watchCount: make(map[watchIdentifier]int),
indexes: getBuiltinIndexes(),
Copy link
Member

Choose a reason for hiding this comment

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

I would order the fields in this construction the same as in the struct definition.

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

Comment on lines 163 to 164
// empty value (we assume that number of those for empty value is not
// smaller than for any other value). That's not always true, but in
Copy link
Member

Choose a reason for hiding this comment

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

I think the assumption being made here is rather that the count for not-unset non-empty value stays tiny in absolute terms.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not exactly (and what you're saying is also not true in practice - e.g. each kubelet is watching for its own pods, which means that there are N such watches with N being number of nodes).

The observation is that for a given object create/update/delete the amount of work (also filtering given index implementaion in watchcache) is proportional to:

  • watches interested in all objects (those that are "unset" here)
  • watches interssted in the value coming from that object

So we're basically assuming (which seem to be true in practice too), that the difference between "unset + my-value" is small comparing to "unset + empty".

Tried to clarify the comment.

Copy link
Member Author

@wojtek-t wojtek-t left a comment

Choose a reason for hiding this comment

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

Comment on lines +71 to +73
// builtinIndexes represents of set of indexes registered in
// watchcache that are indexing watches and increase speed of
// their processing.
Copy link
Member Author

Choose a reason for hiding this comment

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

added

watchCount map[watchIdentifier]int
}

func NewWatchTracker() WatchTracker {
return &watchTracker{
watchCount: make(map[watchIdentifier]int),
indexes: getBuiltinIndexes(),
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

Comment on lines 163 to 164
// empty value (we assume that number of those for empty value is not
// smaller than for any other value). That's not always true, but in
Copy link
Member Author

Choose a reason for hiding this comment

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

Not exactly (and what you're saying is also not true in practice - e.g. each kubelet is watching for its own pods, which means that there are N such watches with N being number of nodes).

The observation is that for a given object create/update/delete the amount of work (also filtering given index implementaion in watchcache) is proportional to:

  • watches interested in all objects (those that are "unset" here)
  • watches interssted in the value coming from that object

So we're basically assuming (which seem to be true in practice too), that the difference between "unset + my-value" is small comparing to "unset + empty".

Tried to clarify the comment.

Copy link
Member

@MikeSpreitzer MikeSpreitzer left a comment

Choose a reason for hiding this comment

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

Yes, this looks like a good start.

@MikeSpreitzer
Copy link
Member

/lgtm

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: MikeSpreitzer, wojtek-t

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 1, 2021
@k8s-triage-robot
Copy link

The Kubernetes project has merge-blocking tests that are currently too flaky to consistently pass.

This bot retests PRs for certain kubernetes repos according to the following rules:

  • The PR does have any do-not-merge/* labels
  • The PR does not have the needs-ok-to-test label
  • The PR is mergeable (does not have a needs-rebase label)
  • The PR is approved (has cncf-cla: yes, lgtm, approved labels)
  • The PR is failing tests required for merge

You can:

/retest

@k8s-ci-robot k8s-ci-robot merged commit 88f8974 into kubernetes:master Nov 2, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.23 milestone Nov 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/apiserver cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants