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

Adding control for submission rate. #84

Merged
merged 5 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,10 @@ There are various options for creating your own customized tests. A full list of
- All values default to `0` which has the effect of not limiting the rate of the test.
- The test will allow at most `startRate` actions to happen per second. Over the period of `rateRampUpTime` seconds the allowed rate will increase linearly until `endRate` actions per seconds are reached. At this point the test will continue at `endRate` actions per second until the test finishes.
- If `startRate` is the only value that is set, the test will run at that rate for the entire test.
- Waiting for mint transactions to be confirmed before doing the next one
- Waiting for events to be confirmed before doing the next submission
- See `noWaitSubmission` (defaults to `false`).
- When set to `true` each worker routine will perform its action (e.g. minting a token) and wait for confirmation of that event before doing its next action.
- `maxSubmissionsPerSecond` can be used to control the maximum number of submissions per second to avoid overloading the system under test.
- Setting the features of a token being tested
- See `supportsData` and `supportsURI` attributes of a test instance.
- `supportsData` defaults to `true` since the sample token contract used by FireFly supports minting tokens with data. When set to `true` the message included in the mint transaction will include the ID of the worker routine and used to correlate received confirmation events.
Expand Down
1 change: 1 addition & 0 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ func generateRunnerConfigFromInstance(instance *conf.InstanceConfig, perfConfig
runnerConfig.LogLevel = perfConfig.LogLevel
runnerConfig.SkipMintConfirmations = instance.SkipMintConfirmations
runnerConfig.NoWaitSubmission = instance.NoWaitSubmission
runnerConfig.MaxSubmissionsPerSecond = instance.MaxSubmissionsPerSecond
runnerConfig.Length = instance.Length
runnerConfig.Daemon = perfConfig.Daemon
runnerConfig.LogEvents = perfConfig.LogEvents
Expand Down
2 changes: 2 additions & 0 deletions internal/conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type RunnerConfig struct {
RampLength time.Duration
SkipMintConfirmations bool // deprecated
NoWaitSubmission bool
MaxSubmissionsPerSecond int
SubscriptionCoreOptions *core.SubscriptionCoreOptions
}

Expand Down Expand Up @@ -87,6 +88,7 @@ type InstanceConfig struct {
RampLength time.Duration `json:"rampLength,omitempty" yaml:"rampLength,omitempty"`
SkipMintConfirmations bool `json:"skipMintConfirmations" yaml:"skipMintConfirmations"` // deprecated
NoWaitSubmission bool `json:"noWaitSubmission" yaml:"noWaitSubmission"`
MaxSubmissionsPerSecond int `json:"maxSubmissionsPerSecond" yaml:"maxSubmissionsPerSecond"`
DelinquentAction string `json:"delinquentAction,omitempty" yaml:"delinquentAction,omitempty"`
PerWorkerSigningKeyPrefix string `json:"perWorkerSigningKeyPrefix,omitempty" yaml:"perWorkerSigningKeyPrefix,omitempty"`
SubscriptionCoreOptions *core.SubscriptionCoreOptions `json:"subscriptionOptions,omitempty" yaml:"subscriptionOptions,omitempty"`
Expand Down
51 changes: 40 additions & 11 deletions internal/perf/perf.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,25 +549,54 @@ perfLoop:
break perfLoop
}

select {
case <-signalCh:
break perfLoop
case pr.bfr <- i:
i++
if time.Since(lastCheckedTime).Seconds() > pr.cfg.MaxTimePerAction.Seconds() {
if pr.cfg.MaxSubmissionsPerSecond > 0 {
// control send rate
secondTicker := time.NewTicker(1 * time.Second)
select {
case <-signalCh:
break perfLoop
case <-secondTicker.C:
for j := 0; j < pr.cfg.MaxSubmissionsPerSecond; j++ {
pr.bfr <- j
}
i++
if time.Since(lastCheckedTime).Seconds() > pr.cfg.MaxTimePerAction.Seconds() {
if pr.detectDelinquentMsgs() && pr.cfg.DelinquentAction == conf.DelinquentActionExit.String() {
break perfLoop
}
lastCheckedTime = time.Now()
}
break
case <-timeout:
if pr.detectDelinquentMsgs() && pr.cfg.DelinquentAction == conf.DelinquentActionExit.String() {
Chengxuan marked this conversation as resolved.
Show resolved Hide resolved
break perfLoop
}
lastCheckedTime = time.Now()
break
}
break
case <-timeout:
if pr.detectDelinquentMsgs() && pr.cfg.DelinquentAction == conf.DelinquentActionExit.String() {

} else {
select {
case <-signalCh:
break perfLoop
case pr.bfr <- i:
i++
if time.Since(lastCheckedTime).Seconds() > pr.cfg.MaxTimePerAction.Seconds() {
if pr.detectDelinquentMsgs() && pr.cfg.DelinquentAction == conf.DelinquentActionExit.String() {
break perfLoop
}
lastCheckedTime = time.Now()
}
break
case <-timeout:
if pr.detectDelinquentMsgs() && pr.cfg.DelinquentAction == conf.DelinquentActionExit.String() {
break perfLoop
}
lastCheckedTime = time.Now()
break
}
lastCheckedTime = time.Now()
break
}

}

// If configured, check that the balance of the mint recipient address is correct
Expand Down
Loading