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

GEODE-10010: Sample Redis ops per second during operations in test #7358

Merged
merged 6 commits into from
Mar 1, 2022

Conversation

DonalEvans
Copy link
Contributor

@DonalEvans DonalEvans commented Feb 10, 2022

  • Rather than a value that updates once per second, instantaneous
    operations per second and instantaneous kilobytes read per second now
    return a rolling average of those stats updated 16 times per second
  • Rename AbstractRedisInfoStatsIntegrationTest to match child classes
  • Rather than measuring instantaneous per second stats after
    operations have finished, sample them while operations are ongoing and
    calculate the expected value based on the number of operations
    performed in the one second prior to sampling.

Authored-by: Donal Evans [email protected]

For all changes:

  • Is there a JIRA ticket associated with this PR? Is it referenced in the commit message?

  • Has your PR been rebased against the latest commit within the target branch (typically develop)?

  • Is your initial contribution a single, squashed commit?

  • Does gradlew build run cleanly?

  • Have you written or updated unit tests to verify your changes?

  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?

@jdeppe-pivotal jdeppe-pivotal added the redis Issues related to the geode-for-redis module label Feb 11, 2022
@DonalEvans DonalEvans force-pushed the GEODE-10010-opsPerSecondStat branch 2 times, most recently from b065cf7 to bed9338 Compare February 11, 2022 21:06
 - Rather than a value that updates once per second, instantaneous
 operations per second and instantaneous kilobytes read per second now
 return a rolling average of those stats updated 16 times per second
 - Rename AbstractRedisInfoStatsIntegrationTest to match child classes
 - Rather than measuring instantaneous per second stats after
 operations have finished, sample them while operations are ongoing and
 calculate the expected value based on the number of operations
 performed in the one second prior to sampling.

Authored-by: Donal Evans <[email protected]>
 - Rename rollingAverageSamplesPerSecond to use all-caps
 - Extract rolling average calculations to static nested class

Authored-by: Donal Evans <[email protected]>
Arrays.stream(networkBytesReadOverLastNSamples).sum() / 1024.0;
totalNetworkBytesReadLastTick = totalNetworkBytesRead;
}
private static class RollingUpgradeStat {
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be named "RollingAverageStat"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I was apparently on auto-pilot when I typed that, thanks for catching it

private int rollingAverageTick = 0;
private final RollingUpgradeStat networkKiloBytesReadRollingAverageStat =
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be named "Bytes" instead of "KiloBytes" to make clear that the units it computes is bytes and the caller needs to convert then to kilobytes by dividing by 1024?

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 call

 - Reduce poll interval to 10ms in awaits
 - Retrieve stats before calculating expected value
 - Make variables final

Authored-by: Donal Evans <[email protected]>
Copy link
Contributor

@ringles ringles left a comment

Choose a reason for hiding this comment

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

With the suggested renames, looks good.

Copy link
Contributor

@onichols-pivotal onichols-pivotal left a comment

Choose a reason for hiding this comment

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

comment deleted

Copy link
Contributor

@onichols-pivotal onichols-pivotal left a comment

Choose a reason for hiding this comment

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

comment deleted

.calculate(getTotalNetworkBytesRead(), rollingAverageTick) / 1024.0;
opsPerformedOverLastSecond =
opsPerformedRollingAverageStat.calculate(getCommandsProcessed(), rollingAverageTick);
rollingAverageTick++;
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 not sure about this suggestion but I think it would be better if "rollingAverageTick" was an instance var on RollingAverageStat. Then all this tick manipulation code would happen inside RollingAverageStat.calculate. I know this will use a little bit more memory and time but it does allow the possibility of each RollingAverageStat to have its own number of samples it will average. As it is now when you just look at the calculate method it is unclear how the array index is managed and if we might have an out of bounds index. If this code was moved to calculate it would be clearer

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 like this idea. Since the tick count is inherently tied to the samples per second, which is also used when determining the delay for the ScheduledExecutorService, it's not possible to have different instances of RollingAverageStat with different number of samples to average over without also having a different instance of ScheduledExecutorService to execute them, but it still cleans things up to move the tick logic into RollingAverageStat.

To make the RollingAverageStat instances more self-contained, I also moved the call to get the current stat value inside the class, so all you need to do is create an instance, then call a zero-argument calculate() method to get the latest average.

 - Take a max tick count and a getCurrentValue callable into the
 constructor
 - Move tick count management into the calculate() method
 - Move getting current value into the calculate() method

Authored-by: Donal Evans <[email protected]>
@DonalEvans DonalEvans merged commit ea20f25 into apache:develop Mar 1, 2022
@DonalEvans DonalEvans deleted the GEODE-10010-opsPerSecondStat branch March 1, 2022 16:58
DonalEvans added a commit to DonalEvans/geode that referenced this pull request Mar 1, 2022
DonalEvans added a commit that referenced this pull request Mar 1, 2022
mhansonp pushed a commit to mhansonp/geode that referenced this pull request Mar 11, 2022
Code changes:
 - Rather than a value that updates once per second, instantaneous
 operations per second and instantaneous kilobytes read per second now
 return a rolling average of those stats updated 16 times per second
 - Introduce RollingAverageStat nested class in RedisStats

Test changes:
 - Rename AbstractRedisInfoStatsIntegrationTest to match child classes
 - Rather than measuring instantaneous per second stats after
 operations have finished, sample them while operations are ongoing and
 calculate the expected value based on the number of operations
 performed in the one second prior to sampling.
 - Change test tolerances from fixed value to 12.5% of expected value

Authored-by: Donal Evans <[email protected]>
mhansonp pushed a commit to mhansonp/geode that referenced this pull request Mar 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
redis Issues related to the geode-for-redis module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants