✨ Add a priority queue#3014
Merged
Merged
Conversation
This was referenced Nov 17, 2024
4c80ffb to
506d130
Compare
This change contains the POC of a priority workqueue that allows to prioritize events over one another. It is opt-in and will by default de-prioritize events originating from the initial listwatch and from periodic resyncs.
```
$ benchstat slice.txt btree.txt
goos: darwin
goarch: arm64
pkg: sigs.k8s.io/controller-runtime/pkg/controllerworkqueue
cpu: Apple M2 Pro
│ slice.txt │ btree.txt │
│ sec/op │ sec/op vs base │
AddGetDone-10 5.078m ± 0% 1.163m ± 0% -77.09% (p=0.000 n=10)
│ slice.txt │ btree.txt │
│ B/op │ B/op vs base │
AddGetDone-10 55.11Ki ± 0% 46.98Ki ± 0% -14.75% (p=0.000 n=10)
│ slice.txt │ btree.txt │
│ allocs/op │ allocs/op vs base │
AddGetDone-10 3.000k ± 0% 1.000k ± 0% -66.67% (p=0.000 n=10)
```
This reverts commit ce23de5. Speedup is tiny and at the expense of increased mem usage (which due to increasing GC pressure is likely the explanation why its so small), so doesn't seem worth it overall: ``` goos: darwin goarch: arm64 pkg: sigs.k8s.io/controller-runtime/pkg/controller/priorityqueue cpu: Apple M2 Pro │ blocking.txt │ non-blocking.txt │ │ sec/op │ sec/op vs base │ AddGetDone-10 1.320m ± 1% 1.410m ± 0% +6.81% (p=0.000 n=10) AddOnly-10 373.9µ ± 1% 343.2µ ± 1% -8.22% (p=0.000 n=10) AddLockContended-10 375.8µ ± 1% 342.8µ ± 1% -8.78% (p=0.000 n=10) geomean 570.3µ 549.4µ -3.66% │ blocking.txt │ non-blocking.txt │ │ B/op │ B/op vs base │ AddGetDone-10 109.9Ki ± 0% 164.2Ki ± 0% +49.42% (p=0.000 n=10) AddOnly-10 553.0 ± 2% 56045.0 ± 0% +10034.72% (p=0.000 n=10) AddLockContended-10 569.0 ± 6% 56045.0 ± 0% +9749.74% (p=0.000 n=10) geomean 3.207Ki 78.94Ki +2361.60% │ blocking.txt │ non-blocking.txt │ │ allocs/op │ allocs/op vs base │ AddGetDone-10 3.013k ± 0% 5.001k ± 0% +65.98% (p=0.000 n=10) AddOnly-10 16.00 ± 6% 2000.00 ± 0% +12400.00% (p=0.000 n=10) AddLockContended-10 16.00 ± 6% 2000.00 ± 0% +12400.00% (p=0.000 n=10) geomean 91.71 2.715k +2860.01% ```
de6bfbd to
b4fc147
Compare
vincepri
reviewed
Dec 6, 2024
Contributor
|
LGTM label has been added. DetailsGit tree hash: b25ef6b7e50afc63336079f6a9eb6b6582091930 |
Contributor
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alvaroaleman, vincepri The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Member
|
/lgtm |
Contributor
|
LGTM label has been added. DetailsGit tree hash: 4c1190390c83244fd75e957ce61387db2254ae91 |
Member
Author
|
/hold cancel |
8 tasks
sbueringer
reviewed
Jan 2, 2025
lingdie
reviewed
Apr 8, 2025
| // isObjectUnchanged checks if the object in a create event is unchanged, for example because | ||
| // we got it in our initial listwatch or because of a resync. The heuristic it uses is to check | ||
| // if the object is older than one minute. | ||
| func isObjectUnchanged[object client.Object](e event.TypedCreateEvent[object]) bool { |
There was a problem hiding this comment.
Consider resource modification during controller restart time period and whether this function does not fulfill this scenario?
Member
There was a problem hiding this comment.
2 tasks
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.
This change contains a priority workqueue that allows to prioritize events over one another. It is opt-in and will by default de-prioritize events originating from the initial listwatch and from periodic resyncs.
Ref #2374
Ref #3013
/hold