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

Mitigate wind-up problem in AP&F: prevent queue virtualStart lag #95986

Merged
merged 1 commit into from Nov 5, 2020

Conversation

yue9944882
Copy link
Member

@yue9944882 yue9944882 commented Oct 29, 2020

NONE

here is simpler simulation how the max-min fairness issue happens for the wind-up test where the global virtual time proceeds 1.5/s because rate = ConcurrencyLimit/NEQ hence 1.5 = 3/2 and at the beginning of the test Q1 demands 2/s and Q2 demands 1/s, at the middle of test, we double the demand for Q2 to 2/s:

# VS(queue) = virtual start for the queue,  VSE(queue) = virtual start for the queue excluding the estimated service time
# GVT = global virtual time, or per-queue-set virtual time, RT = real world time

(before this PR)
---------------------------------------------------------------------
| RT      |  1  |  2  |  3  | ... | 20 |  21  | 22 |  23  | ...| 40 | 
---------------------------------------------------------------------
| VSE(Q1) |  2  |  4  |  6  | ... | 40 |  41  | 42 |  43  | ...| 60 | 
---------------------------------------------------------------------
| VSE(Q2) |  1  |  2  |  3  | ... | 20 |  22  | 24 |  26  | ...| 60 |
---------------------------------------------------------------------
| GVT     | 1.5 |  3  | 4.5 | ... | 30 | 31.5 | 33 | 34.5 | ...| 60 |
---------------------------------------------------------------------
                                    ^                               ^
        (we double the throughput for Q2 at this point)         (VSE reaches equal for Q1 and Q2 at this point)                                                            



(after this PR)
------------------------------------------------------------------------------------
| RT      |  1  |  2  |  3  | ... | 20 |  21  | 22 |  23  | ...| 30 |  31  | ...| 40 |
------------------------------------------------------------------------------------
| VSE(Q1) |  2  |  4  |  6  | ... | 40 |  41  | 42 |  43  | ...| 50 | 51.5 | ...| 65 | 
------------------------------------------------------------------------------------
| VSE(Q2) | 1.5 |  3  | 4.5 | ... | 30 |  32  | 34 |  36  | ...| 50 | 51.5 | ...| 65 |
------------------------------------------------------------------------------------
| GVT     | 1.5 |  3  | 4.5 | ... | 30 | 31.5 | 33 | 34.5 | ...| 45 | 46.5 | ...| 60 |
------------------------------------------------------------------------------------
                                    ^                               ^
        (we double the throughput for Q2 at this point)         (VSE reaches equal for Q1 and Q2 at this point)                

then let's generalize the ratio of demanding concurrency of Q1:Q2 from 2:1 to n:1, if the credit accumulates for a period of real time T, then Q2 will take T/n real time to catch up with Q1's VSE. hence the bigger burst of credit accumulation we have, the shorter period of time it takes to ease the burst.

btw the tests are adjusted to introduce a margin value for evaluating fairness.

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 29, 2020
@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Oct 29, 2020
@yue9944882
Copy link
Member Author

yue9944882 commented Oct 29, 2020

@yue9944882
Copy link
Member Author

/retest

@roycaihw
Copy link
Member

/assign @lavalamp
/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 29, 2020
@MikeSpreitzer
Copy link
Member

This is a partial mitigation of the problem (#95979). This mitigation addresses one of the two sides of the imbalance. This is better than nothing.

The other side of the imbalance is that queues using more than the even allocation build up a disadvantage in their virtualStart. Such a queue keeps its accumulated disadvantage until that queue becomes empty. This is a disadvantage relative to queues using less than the even allocation --- including empty queues. Thus, a queue that transitions from empty to non-empty starts with a relative advantage compared to the queues that have a built-up disadvantage.

@MikeSpreitzer
Copy link
Member

How about changing the title of this PR from speaking about a "fix" to speaking about "mitigation"? Perhaps something like "Mitigate wind-up problem in API Priority and Fairness"? Or perhaps something more specific, such as "Prevent queue virtualStart lag in API Priority and Fairness"?

@yue9944882 yue9944882 changed the title Fixes max-min fairness for wind-up credit accumulation Mitigate wind-up problem in AP&F: prevent queue virtualStart lag Nov 2, 2020
@ahg-g
Copy link
Member

ahg-g commented Nov 2, 2020

/milestone v1.20

@k8s-ci-robot k8s-ci-robot added this to the v1.20 milestone Nov 2, 2020
@MikeSpreitzer
Copy link
Member

/LGTM

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 2, 2020
@lavalamp
Copy link
Member

lavalamp commented Nov 4, 2020

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lavalamp, yue9944882

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 approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 4, 2020
@spiffxp spiffxp added do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. and removed needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Nov 5, 2020
@MikeSpreitzer
Copy link
Member

/kind bug

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. and removed do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Nov 5, 2020
@MikeSpreitzer
Copy link
Member

/priority important-soon

@k8s-ci-robot k8s-ci-robot added priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Nov 5, 2020
@k8s-ci-robot k8s-ci-robot merged commit c0e88a3 into kubernetes:master Nov 5, 2020
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

7 participants