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

test: add benchmark for long-running sessions clean up task. #2564

Merged

Conversation

arpan14
Copy link
Collaborator

@arpan14 arpan14 commented Aug 2, 2023

Adding benchmarks for long running sessions cleanup feature introduced as part of - #2419 .

@arpan14 arpan14 requested a review from a team as a code owner August 2, 2023 10:21
@product-auto-label product-auto-label bot added size: l Pull request size is large. api: spanner Issues related to the googleapis/java-spanner API. labels Aug 2, 2023
@arpan14 arpan14 requested a review from olavloite August 2, 2023 10:22
client.singleUse().executeQuery(StandardBenchmarkMockServer.SELECT1)) {
while (rs.next()) {
// introduce random sleep times to have long-running sessions
randomWait();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Pure theoretically this random function could end up never adding a long wait time if random.nextBool returns false every time. Would it maybe make sense to let this method update an atomic integer every time it sets a long wait time, and then at the end of the test verify that the number of sessions that was removed is equal to that atomic integer (instead of just checking that it's greater than zero, which could in theory fail)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's a very good idea. Let me do this. It will make the benchmark even more precise.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added this logic and then realised that the number of sessions removed may not be equal to the value of the atomic integer since

  1. The background task may not have run and thus there may be a few dangling sessions which would be pending to be cleaned up.
  2. Even if we force run a maintenance task, there may still be other reasons why the session may not get cleaned. For ex - If session hasn't breached the idle threshold.

#1 is easy to mitigate by force running a maintenance loop at the end of the test. But for #2 we will require to setup our fake clock setup and play around with the timestamps. Since we already do this for all other tests that were part of the other PR, I was thinking we can keep this benchmark close to real setup and avoid all the mocking.

What do you think?

@arpan14 arpan14 added the owlbot:run Add this label to trigger the Owlbot post processor. label Aug 2, 2023
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Aug 2, 2023
@arpan14 arpan14 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 2, 2023
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 2, 2023
@gcf-owl-bot gcf-owl-bot bot requested a review from a team as a code owner August 2, 2023 16:02
@arpan14 arpan14 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 2, 2023
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 2, 2023
@arpan14 arpan14 added automerge Merge the pull request once unit tests and other checks pass. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Aug 2, 2023
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 2, 2023
@gcf-merge-on-green gcf-merge-on-green bot merged commit fa745e8 into googleapis:main Aug 2, 2023
21 of 22 checks passed
@gcf-merge-on-green gcf-merge-on-green bot removed the automerge Merge the pull request once unit tests and other checks pass. label Aug 2, 2023
@arpan14 arpan14 deleted the long-session-benchmark-pr branch August 3, 2023 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/java-spanner API. size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants