diff options
| author | Will Hawkins <[email protected]> | 2023-07-14 14:08:57 -0400 |
|---|---|---|
| committer | Will Hawkins <[email protected]> | 2023-07-14 15:26:30 -0400 |
| commit | cca033fe0d7389bfa647afa47a47de2a3f6af47d (patch) | |
| tree | a114899b9b78cf775b920a303dfd98da76151c92 /rpm | |
| parent | 123e75ac641721de9c19a652c9b1450b60bc7ef9 (diff) | |
[Feature] Relative RPM
With this feature, the user can use `--relative-rpm` to gather
additional data: a relative RPM. The relative RPM score
1. Calculates an RPM before working conditions are achieved.
2. Achieves working conditions (upload and download)
3. Calculates an RPM under working conditions (upload and download)
4. Calculates the percent difference between the RPM calculated in (1)
and the RPMs calculated in (3).
Signed-off-by: Will Hawkins <[email protected]>
Diffstat (limited to 'rpm')
| -rw-r--r-- | rpm/calculations.go | 4 | ||||
| -rw-r--r-- | rpm/rpm.go | 127 |
2 files changed, 71 insertions, 60 deletions
diff --git a/rpm/calculations.go b/rpm/calculations.go index 8b3cf92..f3619dc 100644 --- a/rpm/calculations.go +++ b/rpm/calculations.go @@ -37,7 +37,7 @@ type Rpm[Data utilities.Number] struct { func CalculateRpm[Data utilities.Number, Bucket constraints.Ordered]( selfRtts series.WindowSeries[Data, Bucket], aggregatedForeignRtts series.WindowSeries[Data, Bucket], trimming uint, percentile uint, -) Rpm[Data] { +) *Rpm[Data] { // There may be more than one round trip accumulated together. If that is the case, // we will blow them apart in to three separate measurements and each one will just // be 1 / 3. @@ -82,7 +82,7 @@ func CalculateRpm[Data utilities.Number, Bucket constraints.Ordered]( pnRpm := 60.0 / (float64(selfProbeRoundTripTimePN+foreignProbeRoundTripTimePN) / 2.0) meanRpm := 60.0 / (float64(selfProbeRoundTripTimeMean+foreignProbeRoundTripTimeMean) / 2.0) - return Rpm[Data]{ + return &Rpm[Data]{ SelfRttsTotal: selfRttsTotalCount, ForeignRttsTotal: foreignRttsTotalCount, SelfRttsTrimmed: selfRttsTrimmedCount, ForeignRttsTrimmed: foreignRttsTrimmedCount, SelfProbeRttPN: selfProbeRoundTripTimePN, ForeignProbeRttPN: foreignProbeRoundTripTimePN, @@ -204,83 +204,95 @@ func ResponsivenessProber[BucketType utilities.Number]( } var selfProbeConnection *lgc.LoadGeneratingConnection = nil - func() { - selfProbeConnectionCollection.Lock.Lock() - defer selfProbeConnectionCollection.Lock.Unlock() - selfProbeConnection, err = selfProbeConnectionCollection.GetRandom() - if err != nil { + if selfProbeConnectionCollection != nil { + func() { + selfProbeConnectionCollection.Lock.Lock() + defer selfProbeConnectionCollection.Lock.Unlock() + selfProbeConnection, err = selfProbeConnectionCollection.GetRandom() + if err != nil { + if debug.IsWarn(debugging.Level) { + fmt.Printf( + "(%s) Failed to get a random %s load-generating connection on which to send a probe: %v.\n", + debugging.Prefix, + probeDirection, + err, + ) + } + return + } + }() + } + if selfProbeConnectionCollection != nil && selfProbeConnection == nil { + return + } + + var selfProbeDataPoint *probe.ProbeDataPoint = nil + if selfProbeConnection != nil { + // TODO: Make the following sanity check more than just a check. + // We only want to start a SelfUp probe on a connection that is + // in the RUNNING state. + if (*selfProbeConnection).Status() != lgc.LGC_STATUS_RUNNING { if debug.IsWarn(debugging.Level) { fmt.Printf( - "(%s) Failed to get a random %s load-generating connection on which to send a probe: %v.\n", + "(%s) The selected random %s load-generating connection on which to send a probe was not running.\n", debugging.Prefix, probeDirection, - err, ) } return } - }() - if selfProbeConnection == nil { - return - } - // TODO: Make the following sanity check more than just a check. - // We only want to start a SelfUp probe on a connection that is - // in the RUNNING state. - if (*selfProbeConnection).Status() != lgc.LGC_STATUS_RUNNING { - if debug.IsWarn(debugging.Level) { + if debug.IsDebug(debugging.Level) { fmt.Printf( - "(%s) The selected random %s load-generating connection on which to send a probe was not running.\n", + "(%s) Selected %s load-generating connection with ID %d to send a self probe with Id %d.\n", debugging.Prefix, probeDirection, + (*selfProbeConnection).ClientId(), + probeCount, ) } - return - } - - if debug.IsDebug(debugging.Level) { - fmt.Printf( - "(%s) Selected %s load-generating connection with ID %d to send a self probe with Id %d.\n", - debugging.Prefix, - probeDirection, - (*selfProbeConnection).ClientId(), + selfProbeDataPoint, err = probe.Probe( + proberCtx, + (*selfProbeConnection).Client(), + selfProbeConfiguration.URL, + selfProbeConfiguration.Host, + utilities.Conditional(probeDirection == lgc.LGC_DOWN, probe.SelfDown, probe.SelfUp), probeCount, + captureExtendedStats, + debugging, ) - } - selfProbeDataPoint, err := probe.Probe( - proberCtx, - (*selfProbeConnection).Client(), - selfProbeConfiguration.URL, - selfProbeConfiguration.Host, - utilities.Conditional(probeDirection == lgc.LGC_DOWN, probe.SelfDown, probe.SelfUp), - probeCount, - captureExtendedStats, - debugging, - ) - if err != nil { - // We may see an error here because the prober context was cancelled - // and requests were attempting to be sent. This situation is not an - // error (per se) so we will not log it as such. + if err != nil { + // We may see an error here because the prober context was cancelled + // and requests were attempting to be sent. This situation is not an + // error (per se) so we will not log it as such. - if proberCtx.Err() != nil { - if debug.IsDebug(debugging.Level) { - fmt.Printf( - "(%s) Failed to send a probe (id: %v) because the prober context was cancelled.\n", - debugging.Prefix, - probeCount, - ) + if proberCtx.Err() != nil { + if debug.IsDebug(debugging.Level) { + fmt.Printf( + "(%s) Failed to send a probe (id: %v) because the prober context was cancelled.\n", + debugging.Prefix, + probeCount, + ) + } + return } + fmt.Printf( + "(%s) There was an error sending a self probe with Id %d: %v\n", + debugging.Prefix, + probeCount, + err, + ) return } - fmt.Printf( - "(%s) There was an error sending a self probe with Id %d: %v\n", - debugging.Prefix, - probeCount, - err, - ) - return + } else { + if debug.IsDebug(debugging.Level) { + fmt.Printf( + "(%s) Did not send a self probe at id %d of probes!\n", + debugging.Prefix, + probeCount, + ) + } } - if debug.IsDebug(debugging.Level) { fmt.Printf( "(%s) About to report results for round %d of probes!\n", @@ -288,10 +300,9 @@ func ResponsivenessProber[BucketType utilities.Number]( probeCount, ) } - dataPointsLock.Lock() defer dataPointsLock.Unlock() - // Now we have our four data points (three in the foreign probe data point and one in the self probe data point) + // Now we have our (maybe) four data points (three in the foreign probe data point and [maybe] one in the self probe data point) if dataPoints != nil { measurement := ResponsivenessProbeResult{ Foreign: foreignProbeDataPoint, Self: selfProbeDataPoint, |
