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

Refactor ramping VUs executor #2155

Merged
merged 10 commits into from
Nov 29, 2021
Merged

Refactor ramping VUs executor #2155

merged 10 commits into from
Nov 29, 2021

Conversation

inancgumus
Copy link
Member

@inancgumus inancgumus commented Oct 4, 2021

RampingVUs.Run method is complex and this PR aims to refactor it.

Improvements:

  • Makes the Run method easier to read and understand.
  • Makes it explicit which Goroutines are being fired in the Run method.
  • Separates responsibilities to other parts like:
    • rampingVUsRunState and its methods.
    • Moves trackProgress Goroutine from the makeProgressFn to the Run method.
    • Makes populateVUHandles to only handle initializing VU handles (not firing up a GR)
    • Uses two strategy functions for code reusability and clarity (handleVUs and handleRemainingVUs use them).
  • Makes the handleVUs algorithm easier to understand and manage.
  • Adds a handleRemainingVUs test with explanations to make newcomers' and new contributors' job easier

Note: The other PR (#2124) is convoluted and somehow creates problems locally and with Github. I'd like to keep working on it on this separate branch.

@inancgumus inancgumus mentioned this pull request Oct 4, 2021
3 tasks
@mstoykov mstoykov added this to the v0.35.0 milestone Oct 6, 2021
imiric
imiric previously approved these changes Oct 14, 2021
Copy link
Contributor

@imiric imiric left a comment

Choose a reason for hiding this comment

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

LGTM! Nice job with the test as well. It's very time dependent so hopefully it's not flaky, but there's not much we can do about that right now.

@inancgumus
Copy link
Member Author

inancgumus commented Oct 14, 2021

LGTM! Nice job with the test as well. It's very time dependent so hopefully it's not flaky, but there's not much we can do about that right now.

Thanks! I actually automatically ran the test 1000 times to make sure that it's not flaky.

@inancgumus inancgumus self-assigned this Oct 19, 2021
.github/workflows/xk6.yml Outdated Show resolved Hide resolved
lib/executor/ramping_vus_test.go Outdated Show resolved Hide resolved
yorugac
yorugac previously approved these changes Oct 21, 2021
codebien
codebien previously approved these changes Oct 21, 2021
Copy link
Member

@na-- na-- left a comment

Choose a reason for hiding this comment

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

Mostly LGTM, the code is much neater ❤️ There are a few issues though, I've noted them and potential improvement suggestions inline.

lib/executor/ramping_vus.go Outdated Show resolved Hide resolved
lib/executor/ramping_vus.go Outdated Show resolved Hide resolved
lib/executor/ramping_vus.go Outdated Show resolved Hide resolved
lib/executor/ramping_vus.go Outdated Show resolved Hide resolved
lib/executor/ramping_vus.go Outdated Show resolved Hide resolved
lib/executor/ramping_vus.go Outdated Show resolved Hide resolved
@inancgumus
Copy link
Member Author

inancgumus commented Oct 22, 2021

Thanks, @na-- 😍 I’ll fix these today.

@inancgumus inancgumus dismissed stale reviews from codebien and yorugac via fd45828 October 22, 2021 16:00
@inancgumus inancgumus force-pushed the refactor/rampingvus branch 6 times, most recently from 2ce9b73 to 5157a36 Compare October 24, 2021 15:09
Copy link
Contributor

@yorugac yorugac left a comment

Choose a reason for hiding this comment

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

All seems fine overall, just small suggestions mostly.

lib/executor/ramping_vus.go Outdated Show resolved Hide resolved
lib/executor/ramping_vus.go Outdated Show resolved Hide resolved
lib/executor/ramping_vus.go Outdated Show resolved Hide resolved
lib/executor/ramping_vus.go Outdated Show resolved Hide resolved
inancgumus and others added 7 commits November 18, 2021 16:39
RampingVUs.Run method was complex and this refactors it by adding
rampingVUsRunState to share run state between functions used by
the Run method.

+ Makes the Run method easier to read and understand
+ Makes it explicit which Goroutines are being fired in the Run
+ Separates responsibilities to other parts like:
  + rampingVUsRunState and its methods.
  + Moves trackProgress Goroutine from the makeProgressFn
    to the Run method
  + Makes initializeVUs to only handle initializing GRs
  + Uses two strategy functions to make them reusable
    and clearer. handleVUs and handleRemainingVUs use them.
+ Makes the handleVUs algorithm easier to understand and
  manage.
This test aims to check whether the ramping VU executor interrupts
hanging/remaining VUs after the graceful rampdown period finishes.

handleRemainingVUs method should be interrupting the VUs that
are beyond their allowed time budgets. See the comments in the
test for more information.
This commit uses longer variables names to help understand code.
handleVUs and handleRemainingVUs was not sharing the current number of
planned VUs in graceful steps. This may cause the latter method to act
strangely.

It's because handleRemainingVUs needs to know the number of
remaining graceful steps so that it can stop the remaining VUs
accordinly.

Now the handleVUs method returns the number of handled graceful steps.
So the handleRemainingVUs method can use this information and hard stop
the remaining VUs.
lib/executor/ramping_vus.go Outdated Show resolved Hide resolved
lib/executor/ramping_vus.go Outdated Show resolved Hide resolved
lib/executor/ramping_vus.go Outdated Show resolved Hide resolved
Copy link
Contributor

@yorugac yorugac left a comment

Choose a reason for hiding this comment

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

The ramping-vus are structured much better now 😄 Great job, Inanc! ⭐

@inancgumus inancgumus requested a review from na-- November 22, 2021 10:31
Copy link
Member

@na-- na-- left a comment

Choose a reason for hiding this comment

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

Looks awesome! ❤️ :shipit:

@inancgumus
Copy link
Member Author

At last, thanks! 😅

@inancgumus inancgumus merged commit a8a0c29 into master Nov 29, 2021
@inancgumus inancgumus deleted the refactor/rampingvus branch November 29, 2021 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants