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

Fix active VU reporting by arrival-rate executors #2953

Merged
merged 4 commits into from
Mar 8, 2023

Conversation

imiric
Copy link
Contributor

@imiric imiric commented Mar 3, 2023

This is a somewhat quick and dirty fix of #1977, where instead of changing the global active VUs when the VU is activated, we change it when the VU is actually running. This synchronizes it with the running count of the internal activeVUPool, and reports the correct value everywhere the ExecutionState is used (the real-time total active VU count while the test is running, in all outputs, etc.).

This is a somewhat quick and dirty fix of #1977, where instead of
changing the global active VUs when the VU is activated, we change it
when the VU is actually running. This synchronizes it with the running
count of the internal activeVUPool, and reports the correct value
everywhere the ExecutionState is used (the real-time total active VU
count while the test is running, in all outputs, etc.).
@imiric imiric force-pushed the fix/arrival-rate-active-vus branch from c148f61 to 6f6a4ef Compare March 3, 2023 17:21
@codecov-commenter
Copy link

codecov-commenter commented Mar 3, 2023

Codecov Report

Merging #2953 (fe9ff74) into master (e565316) will decrease coverage by 0.14%.
The diff coverage is 82.73%.

❗ Current head fe9ff74 differs from pull request most recent head 8d43a83. Consider uploading reports for the commit 8d43a83 to get more accurate results

@@            Coverage Diff             @@
##           master    #2953      +/-   ##
==========================================
- Coverage   76.88%   76.74%   -0.14%     
==========================================
  Files         226      227       +1     
  Lines       16908    16919      +11     
==========================================
- Hits        13000    12985      -15     
- Misses       3074     3086      +12     
- Partials      834      848      +14     
Flag Coverage Δ
ubuntu 76.74% <82.73%> (-0.08%) ⬇️
windows ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
cloudapi/client.go 72.91% <0.00%> (ø)
cloudapi/config.go 89.13% <ø> (ø)
cloudapi/errors.go 60.00% <ø> (ø)
output/cloud/output.go 84.70% <ø> (ø)
js/initcontext.go 80.00% <70.37%> (-8.19%) ⬇️
js/gomodule.go 77.27% <77.27%> (ø)
js/cjsmodule.go 78.26% <78.26%> (ø)
js/bundle.go 84.72% <83.92%> (-5.87%) ⬇️
js/modules.go 90.90% <90.90%> (ø)
cmd/login_cloud.go 20.68% <100.00%> (ø)
... and 16 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Contributor

@codebien codebien left a comment

Choose a reason for hiding this comment

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

where instead of changing the global active VUs when the VU is activated, we change it when the VU is actually running

Is this logic consistent across all executors now? 🤔

lib/executor/ramping_arrival_rate_test.go Show resolved Hide resolved
lib/executor/constant_arrival_rate.go Show resolved Hide resolved
@imiric
Copy link
Contributor Author

imiric commented Mar 7, 2023

@codebien

where instead of changing the global active VUs when the VU is activated, we change it when the VU is actually running

Is this logic consistent across all executors now?

This behavior is unique to the arrival rate executors, which are the only ones that have an internal VU pool. They introduce an additional meaning to "active" VUs, which can actually remain dormant until they're "running" an iteration. This change simply synchronizes the "running" counter to the global "active" one, which makes the value reported globally more accurate.

@imiric imiric requested a review from codebien March 7, 2023 11:59
codebien
codebien previously approved these changes Mar 7, 2023
Copy link
Contributor

@codebien codebien left a comment

Choose a reason for hiding this comment

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

LGTM 🙇

mstoykov
mstoykov previously approved these changes Mar 8, 2023
Copy link
Contributor

@mstoykov mstoykov left a comment

Choose a reason for hiding this comment

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

LGTM! That seems way too easy 🤣 but I expect it was hard to make it this easy 👏

I did some benchmarking and it seems to have some performance impact in one of my scripts lying around, but it seemed really small. After some more tests - specifically with empty default functions, I am pretty sure that was due to some randomness in my original script, so it seems to work really well.


runner := simpleRunner(func(ctx context.Context, _ *lib.State) error {
runMx.Lock()
assert.Equal(t, atomic.AddInt64(&running, 1), getCurrActiveVUs())
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: either the atomic here is pointless (we already have mutex) or you should also use it t o read the value in the checks at the end of the test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. I removed the atomic in 7162f77.

The reason I didn't use it at the end is because the test is already done at that point, so it should be safe to read it directly.

@imiric imiric dismissed stale reviews from mstoykov and codebien via 7162f77 March 8, 2023 10:16
@imiric imiric requested review from mstoykov and codebien March 8, 2023 10:19
@imiric
Copy link
Contributor Author

imiric commented Mar 8, 2023

but I expect it was hard to make it this easy

Not really, I was surprised as well, and thought there might be a catch I'm missing. 😅 It does have the side effect that the global VU counter is now "bursty" as the arrival rate VU counter is, so we might want to cache it slightly at least in the UI, since currently it's not very legible on terminals with high refresh rate.

Thanks for confirming it doesn't impact performance. I was slightly concerned about that as well. 👍

Copy link
Contributor

@codebien codebien left a comment

Choose a reason for hiding this comment

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

@imiric FYI, I triggered the stuck CLA check. Remember to squash and merge so we can aggregate the fixups. Thanks for doing this 🙇

@imiric imiric merged commit 367163b into master Mar 8, 2023
@imiric imiric deleted the fix/arrival-rate-active-vus branch March 8, 2023 11:00
@olegbespalov olegbespalov added this to the v0.44.0 milestone Apr 18, 2023
@agilob
Copy link
Contributor

agilob commented Apr 25, 2023

Awesome, thats for constant arrival rate
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

arrival-rate executors do not report active VUs accurately, they report initialized VUs instead
6 participants