Skip to content

Benchmark suite for table unions #694

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

recursion-ninja
Copy link
Collaborator

@recursion-ninja recursion-ninja commented Apr 28, 2025

Benchmarks for table unions.

Overview

Here is a summary of the table union benchmark. Note that all function calls are made throught the Database.LSMTree.Simple API.

Phase 1: Setup

The benchmark will setup an initial set of tables to be unioned together during "Phase 2." The number of tables create is user specified via the --tableCount command line option with a default value of 10 tables.

The size of each generated table is the same and is user specified via the --initial-size command line option with a default value of 1_000_000 entries. Each created table has $initial-size insertions operations performed on it before being written out to disk as a snapshot. The $initial-size$ inserted entries in each table are randomly selected from the range following range:

$$\left[\quad 0,\quad 2 * initialSize \quad\right)$$

Additionally, the directory in which to isolate the benchmark environment is specified via the --bench-dir command line option, with a default of _union_wp16. The table snapshots are saved here along with the benchmarked measurements from Phase 2.

Phase 2: Measurement

When generating measurements for the table unions, the benchmark will reload the snapshots of the tables generated in Phase 1 from disk. Subsequently, the tables will be "incrementally unioned" together.

Once the tables have been loaded and the union initiated, a series of "lookup batches" will be performed. A lookup batch involves performing a large number key lookups on the incrementally unioned table and then calculating the number of lookup operations per second. The measurement series consists of 200 batch lookups.

First, 50 batch lookups are performed without supplying any credits to the unioned table. This establishes a base-line performance picture. Indices [-50, 0] measure lookups to the unioned table with 100% of the debt remaining.

Subsequently, 100 more batch looukps are performed. Before each of these 100 batch lookups, a fixed number of credits are supplied to the incremental union table. The number of credits supplied remain constant between each batch lookup for the entire series of measurements. The series of measurements allows reasoning able table performance over time as the tables debt decreases (at a uniform rate). The number of credits supplied before each lookup batch is 1% of the total starting debt. After 100 steps, 100% of the debt will be paid off. Indices [1, 100] measure lookups to the unioned table with as the remaining debt decreases.

Finally, 50 concluding batch looukps are performed. Since no debt is remaining, no credits are supplied. Rather these meausrments create a "post-payoff" performance picture. Indices [101, 150] measure lookups to the unioned table with 1% of the debt remaining.

The general benchmark format is as follows:

do
measurements <- LSM.withSession (rootDir gopts) $ \session ->
  withLatencyHandle $ \h -> do
    tables <- forM [ 1 .. tableCount gopts ] $ do
      LSM.openTableFromSnapshot <...>

    LSM.withIncrementalUnions tables $ \table -> do
      -- Before payoff picture
      forM [-50 .. 0] $ \step -> do
        measureLookups $ table <...>

      -- During payoff picture
      forM [1 .. 100] $ \step -> do
        LSM.supplyUnionCredits table credits
        measureLookups $ table <...>

      -- After payoff picture
      forM [101 .. 150] $ \step -> do
        measureLookups $ table <...>

outputResults $ analyze measurements

An informative performance plot of the benchmark measurements is generated and placed in the benchmark's directory.

@recursion-ninja
Copy link
Collaborator Author

recursion-ninja commented Apr 28, 2025

Surprisingly, the performance gets worse when the union table debt reaches 0 (see the red arrow)!

unions-benchmark

@recursion-ninja recursion-ninja force-pushed the recursion-ninja/benchmark-union-merge branch from f5e1248 to 0d8238e Compare April 28, 2025 13:27
@recursion-ninja recursion-ninja marked this pull request as draft April 28, 2025 14:16
@recursion-ninja recursion-ninja force-pushed the recursion-ninja/benchmark-union-merge branch from dc2cc99 to 6617a65 Compare May 4, 2025 20:05
@recursion-ninja
Copy link
Collaborator Author

benchmark-10x1_000_000-SEED_008802b0b5fc1ca2

The benchmarks have been reworked. No insert/delete/updates occur during the measurements; only lookups. The output plot has been re-rendered for clarity. The axes are now labeled with units and depict the aggregated lookup time of each batch. Per the suggestion of @dcoutts, a pre- and post- payoff performance picture is generated along side the performance as credits are supplied and the debt is repaid.

@recursion-ninja recursion-ninja marked this pull request as ready for review May 4, 2025 21:20
@recursion-ninja recursion-ninja changed the title WIP: Benchmark suite for table unions Benchmark suite for table unions May 4, 2025
@recursion-ninja recursion-ninja force-pushed the recursion-ninja/benchmark-union-merge branch 4 times, most recently from b704902 to 625c1c3 Compare May 12, 2025 13:18
@recursion-ninja recursion-ninja enabled auto-merge May 12, 2025 13:20
@recursion-ninja recursion-ninja force-pushed the recursion-ninja/benchmark-union-merge branch from fb1a253 to f0ed570 Compare May 16, 2025 18:38
@jorisdral jorisdral force-pushed the recursion-ninja/benchmark-union-merge branch from 60c6365 to 71f5fc1 Compare May 19, 2025 10:39
Copy link
Collaborator

@jorisdral jorisdral left a comment

Choose a reason for hiding this comment

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

The output looks nice, but I have some suggestions for changes. I've also pushed a few commits to the branch that remove features that I don't think the benchmark needs

Copy link
Collaborator

Choose a reason for hiding this comment

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

5ec26a5 says "minor cabal file changes" but it also adds a whole new file

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in squashing of commits.

Copy link
Collaborator

Choose a reason for hiding this comment

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

My remark still stands, but the commit has new hash now: e4214a2

Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems like 8acf503 shouldn't be on this branch

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed this change. Honestly not sure how it slipped into this branch.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The commit seems to still exist, but under a different hash: 7a855b6

@recursion-ninja recursion-ninja force-pushed the recursion-ninja/benchmark-union-merge branch 2 times, most recently from 8c162e3 to 092fdd1 Compare May 22, 2025 22:55
@recursion-ninja recursion-ninja requested a review from jorisdral May 22, 2025 22:56
Copy link
Collaborator

Choose a reason for hiding this comment

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

My remark still stands, but the commit has new hash now: e4214a2

Copy link
Collaborator

Choose a reason for hiding this comment

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

The commit seems to still exist, but under a different hash: 7a855b6

@recursion-ninja recursion-ninja force-pushed the recursion-ninja/benchmark-union-merge branch from 092fdd1 to 8e42e98 Compare May 23, 2025 15:43
@recursion-ninja
Copy link
Collaborator Author

The computation is there still

Strange, that's not what I'm seeing on my machine. I pushed changes again. Maybe that will remove it.

@recursion-ninja recursion-ninja force-pushed the recursion-ninja/benchmark-union-merge branch 3 times, most recently from d0a90c2 to 2c4719c Compare May 26, 2025 17:15
@recursion-ninja recursion-ninja force-pushed the recursion-ninja/benchmark-union-merge branch from 2c4719c to d236827 Compare May 26, 2025 17:26
@recursion-ninja recursion-ninja force-pushed the recursion-ninja/benchmark-union-merge branch from d236827 to 798fb2e Compare June 2, 2025 13:07
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