-
Notifications
You must be signed in to change notification settings - Fork 970
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
Implement a spike feature for generateload #2553
Implement a spike feature for generateload #2553
Conversation
afa8b43
to
923c9c8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two minor suggestions, otherwise looks good to me.
c99a9ac
to
0d31cf7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Questions and/or suggestions to simplify
src/main/CommandHandler.cpp
Outdated
fmt::format(" Generating load: {:d} {:s}, {:d} tx/s = {:f} hours", | ||
numItems, itemType, txRate, hours); | ||
|
||
if (spikeSize < txRate) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure I understand the relationship between txRate
and spikeSize
as written.
txRate
is expressed in transactions per second, while spikeSize
is a number of transactions per spikeInterval
seconds so on can only compare txRate * spikeInterval
to spikeSize
.
I thought what you wanted to implement was that you'd configure the load generator to generate load with the same average of txRate
, but causing a spike of spikeSize
every spikeInterval
?
So wouldn't the relationship be spikeSize/spikeInterval <= txRate
so the test here would really be (spikeSize > txRate * spikeInterval)
and when this happens, it's just a warning that the average rate will be higher than expected (and there will only be spikes for the most part)?
That or you can add the spikes on top of the steady rate, and this makes the math even simpler (and in that case, there is no restriction on txRate
vs spikeSize
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your suggestions!
I changed my code to the "additive" approach (add spikes on top of the steady rate) as this makes the math simpler.
txRate
is the "base" rate of the number of transactions per second.- A spike will occur every
spikeInterval
seconds. - A spike adds
spikeSize
transactions in one second on top of the base rate. Thus when there's a spike,spikeSize + txRate
transactions will be injected in a second.
src/simulation/LoadGenerator.cpp
Outdated
{ | ||
auto elapsedSec = | ||
std::chrono::duration_cast<std::chrono::seconds>(elapsed); | ||
txs += bigDivide(elapsedSec.count(), 1, spikeInterval.count(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you make spikes additive to the base rate, this gets simplified down to txs += bigDivide(elapsedSec.count(), spikeSize, spikeInterval.count(),Rounding::ROUND_DOWN);
which is quite simpler to understand (I'm actually quite not sure the math written here is correct as it's mixing spikeSize
and txRate
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to me that the division may need to happen before the multiplication. For instance, if elapsedSec.count() = 1
, spikeInterval.count() = 3
and spikeSize = 300
, we want to add 0
on this line as we have not had our first spike, but bigDivide(1, 300, 3, Rounding::ROUND_DOWN)
would give us 100
.
234b0e8
to
99604b7
Compare
99604b7
to
f1247de
Compare
@MonsieurNicolas I updated the code based on our discussion. Specifically, the code used to generate |
r+ f1247de |
Description
Implementation of a spike feature. By setting spikeSize = S & spikeInterval = I, a spike that injects S transactions will occur every I seconds on top of the base rate. Whenever there is no spike, txRate transactions will be injected per second.
For instance, with the command
generateload?mode=pay&txs=5000&txrate=3&spikeinterval=4&spikesize=200
,...
until 5000 transactions get injected in total.
Checklist
clang-format
v5.0.0 (viamake format
or the Visual Studio extension)