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

Extend load generator to produce high volume traffic #3492

Merged
merged 2 commits into from
Oct 1, 2022

Conversation

dmkozh
Copy link
Contributor

@dmkozh dmkozh commented Aug 1, 2022

Description

Extend load generator to produce high volume traffic that easily triggers limiting and surge pricing logic. Also added fee diversification and did some refactoring to easier introduce new parameters.

Checklist

  • Reviewed the contributing document
  • Rebased on top of master (no merge commits)
  • Ran clang-format v8.0.0 (via make format or the Visual Studio extension)
  • Compiles
  • Ran all tests
  • If change impacts performance, include supporting evidence per the performance document

@dmkozh dmkozh changed the title Load gen Extend load generator to produce high volume traffic Aug 1, 2022
dmkozh added a commit to dmkozh/supercluster that referenced this pull request Aug 4, 2022
…traffic.

This is based on the capability to generate load ignoring low fee tx errors (stellar/stellar-core#3492)

I'm adding the following scenarios:
- Regular load generation, but with the limiting logic
- Protocol upgrade under load (and with limiting) - this could be relevant for e.g. p20 upgrade
- Running the mixed image version network at 51% quorum and with load - this could have caught network forking of 19.3.0 release.
dmkozh added a commit to dmkozh/supercluster that referenced this pull request Aug 4, 2022
…traffic.

This is based on the capability to generate load and ignore low fee tx errors (stellar/stellar-core#3492)

I'm adding the following scenarios:
- Regular load generation, but with limiting/surge pricing triggering
- Protocol upgrade under load/limiting - this would be relevant for e.g. p20 upgrade to use generalized tx sets
- Running the mixed image version network at 51% quorum and with load - this could have caught network forking of 19.3.0 release.
dmkozh added a commit to dmkozh/supercluster that referenced this pull request Aug 4, 2022
@@ -49,6 +50,10 @@ const uint32_t LoadGenerator::TX_SUBMIT_MAX_TRIES = 10;
// ledger.
const uint32_t LoadGenerator::TIMEOUT_NUM_LEDGERS = 20;

// After successfully submitting desired load, wait for this many ledgers
// without checking for account consistency.
const uint32_t LoadGenerator::COMPLETION_TIMEOUT_WITHOUT_CHECKS = 4;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm less familiar with the internals of the tx queue, but was wondering if this might be too aggressive? In other loadgen modes we allow up to 20 ledgers to finish load processing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm actually not sure why do we wait for so much. We buffer just 2x the max tx set size operations, so that should be applied within a single ledger from the load generation finish. Supercluster has an additional synchronization check mechanism that doesn't rely on account seq num consistency. So I think this should be enough for at least single-node load generation and small missions. I haven't tested this mode with complex topologies though; OTOH I'm not sure that would be useful for those.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I see. Should we just use one parameter across all loadgen modes for consistency? I think as soon loadgen is done submitting load, the transactions would either be picked up within the next 3 ledgers or dropped, so it seems like there isn't much value in waiting for 20 ledgers (I can't recall how we landed on 20, it might have been an arbitrary choice. @MonsieurNicolas might know better)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess for the old constant we wouldn't normally reach the limit (unless something is broken), so there was no point in fine-tuning it. For the new constant we always have to wait this much. I'm not opposed to using a single small constant, though maybe would do that separately to be safe.

dmkozh added a commit to dmkozh/supercluster that referenced this pull request Aug 12, 2022
`txrate`
* `maxfeerate` defines the maximum per-operation fee for generated
transactions (when not specified only minimum base fee is used)
* when `skiplowfeetxs` is set to `1` the transactions that are not accepted by
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: we use explicit "true" and "false" for bools in other http commands, so it'd be nice to do the same here for consistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

auto feeRateDistr =
uniform_int_distribution<uint32_t>(baseFee, *maxGeneratedFeeRate);
// Add a bit more fee to get non-integer fee rates, such that
// `ceil(fee / ops.size()) == feeRate`, but
Copy link
Contributor

Choose a reason for hiding this comment

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

should be feeRate + 1, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually it should be floor instead (when added value is 0 ceil would be equal to feeRate, so + 1 won't be correct).

bool const& defaultValue)
{
auto paramStr = parseOptionalParam<std::string>(map, key);
return paramStr && *paramStr == "true";
Copy link
Contributor

Choose a reason for hiding this comment

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

this condition doesn't respect the default value (if option is not provided, it should return the default)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch, fixed.

auto baseFee = mApp.getLedgerManager().getLastTxFee();
if (baseFee > *maxGeneratedFeeRate)
{
throw std::runtime_error(
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm, this isn't an internal bug, just bad parameters from the user, so no need to crash here (need to gracefully fail instead). Also, is this the right place for the check? We could fast fail in CommandHandler right after parsing maxGeneratedFeeRate (and return an appropriate error message to the user in retStr)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, moved the check to CommandHandler.

Copy link
Contributor

@marta-lokhova marta-lokhova left a comment

Choose a reason for hiding this comment

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

LGTM! Just need to squash the commits

@dmkozh
Copy link
Contributor Author

dmkozh commented Sep 28, 2022

LGTM! Just need to squash the commits

Rebased & squashed.

This currently has a significant number of arguments, some of which are only modified in a single place. The following changes need even more parameters, so maintaining all the args/defaults becomes unwieldy.

This will look nicer with struct designators in C++20, currently I'm using factory functions to address the common patterns.
…te diverse fees.

While it's currently possible to trigger surge pricing with load generator, the request need to fit exactly into 1x and 2x the tx set size, which is tricky if we want to also randomize operation counts.

This mode also allows to exercise the tx queue limiter, which is useful too.
@MonsieurNicolas
Copy link
Contributor

r+ 31566c8

@latobarita latobarita merged commit 22ff47c into stellar:master Oct 1, 2022
dmkozh added a commit to dmkozh/supercluster that referenced this pull request Oct 3, 2022
dmkozh added a commit to dmkozh/supercluster that referenced this pull request Oct 3, 2022
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.

4 participants