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

Improve compact benchmark #106

Merged
merged 5 commits into from
Jul 1, 2024
Merged

Conversation

marco6
Copy link
Collaborator

@marco6 marco6 commented Jun 18, 2024

This PR aims at making the compact benchmark a little bit better.

The main problem with the current approach is that it measures insertions and deletions together with the compaction itself - and those two operations are taking the most of the time. This means that the result of the benchmark is not very representative of what compaction does.

Also, the test takes from 5 to 7 *minutes to run a single iteration which is basically most of the execution time for the benchmark themselves. Running only one iteration makes the measure unreliable and difficult to compare.

This PR attempts to solve those issues by:

  • initializing the database with a single transaction, instead of one per item;
  • relating the size of the test to b.N so that Go can take measures accurately;
  • measuring time only during compaction;
  • switching the log off (to avoid corrupting the benchmark report).

It also moves the benchmark (and the test) to the drivers package as compaction is a backend operation (in fact, during tested logic, the client was used just to set up the test and as such has been removed).

Last, tests under kind folder were not running. Now they are, but I had to fix the TestMigrate as it wasn't working. If required that can be moved to another PR before this one.

@marco6 marco6 requested a review from a team as a code owner June 18, 2024 15:33
@marco6 marco6 marked this pull request as draft June 19, 2024 07:08
@marco6
Copy link
Collaborator Author

marco6 commented Jun 19, 2024

Marking as draft since sqlite tests are not compiling if dqlite lib is missing.

@marco6 marco6 marked this pull request as ready for review June 19, 2024 12:50
@marco6 marco6 force-pushed the improve-compact-benchmark branch from b5a1832 to e432c32 Compare June 25, 2024 06:31
@marco6 marco6 mentioned this pull request Jun 25, 2024
Copy link
Contributor

@bschimke95 bschimke95 left a comment

Choose a reason for hiding this comment

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

Great work @marco6

Did a first pass - code looks good to me. However, the PR does more than what it currently says, e.g. updating the version command, adding dqlite tag fields etc.

I would ask you to either put the rationale for that in the PR description or split this into a separate one.

pkg/kine/drivers/generic/generic.go Outdated Show resolved Hide resolved
pkg/kine/drivers/generic/generic.go Outdated Show resolved Hide resolved
pkg/kine/logstructured/sqllog/sql.go Show resolved Hide resolved
@marco6
Copy link
Collaborator Author

marco6 commented Jun 27, 2024

Agreed. I will link here all the smaller PRs I create and mark this as draft for now.

@marco6 marco6 marked this pull request as draft June 27, 2024 06:19
@marco6
Copy link
Collaborator Author

marco6 commented Jun 27, 2024

Depends on #108 and #109

@marco6
Copy link
Collaborator Author

marco6 commented Jun 27, 2024

Depends on #110

@marco6
Copy link
Collaborator Author

marco6 commented Jun 27, 2024

Depends on #111

@marco6 marco6 force-pushed the improve-compact-benchmark branch from 61e9b51 to 6b2d0b7 Compare July 1, 2024 12:18
Signed-off-by: Marco Manino <marco.manino@canonical.com>
Signed-off-by: Marco Manino <marco.manino@canonical.com>
Signed-off-by: Marco Manino <marco.manino@canonical.com>
Signed-off-by: Marco Manino <marco.manino@canonical.com>
Signed-off-by: Marco Manino <marco.manino@canonical.com>
@marco6 marco6 force-pushed the improve-compact-benchmark branch from 6b2d0b7 to a22ab77 Compare July 1, 2024 13:14
@marco6
Copy link
Collaborator Author

marco6 commented Jul 1, 2024

All pending PR were merged. Marking as ready.

@marco6 marco6 marked this pull request as ready for review July 1, 2024 13:15
@marco6 marco6 requested a review from bschimke95 July 1, 2024 13:15
Copy link
Contributor

@bschimke95 bschimke95 left a comment

Choose a reason for hiding this comment

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

LGTM, great work!

@marco6 marco6 merged commit 98c55be into canonical:master Jul 1, 2024
8 of 9 checks passed
@marco6 marco6 deleted the improve-compact-benchmark branch July 1, 2024 13:38
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.

2 participants