Skip to content

Add an option to spread the TPC-C terminals over every warehouse - #639

Open
akorotkov wants to merge 1 commit into
cmu-db:mainfrom
akorotkov:tpcc-all-warehouses
Open

akorotkov wants to merge 1 commit into
cmu-db:mainfrom
akorotkov:tpcc-all-warehouses

Conversation

@akorotkov

Copy link
Copy Markdown

Add an option to spread the TPC-C terminals over every warehouse

By default, a TPC-C terminal is bound to a warehouse for the whole run, as the specification requires. A side effect is that the data a run touches is bounded by the terminal count rather than the scale factor: covering every warehouse needs at least one terminal per warehouse, so the working set cannot be chosen independently of the concurrency point, and a database built to exceed memory ends up measured out of cache. This commit adds the useAllWarehouses option, which makes a terminal pick a random warehouse, and a district within it, for every transaction. HammerDB offers the same as pg_allwarehouse; go-tpc does it unconditionally. Runs made this way are not specification-compliant, and their tpmC is not comparable with compliant results. Claude generated the code and the rest of the description.

Why

A TPC-C terminal is assigned a warehouse and stays on it for the whole run, as
the specification requires. A side effect of that rule is easy to miss when
sizing an experiment: the data a run actually touches is bounded by the number of
terminals, not by the scale factor. Thirty-two terminals against a two thousand
warehouse database address thirty-two warehouses — about 4 GB of a 243 GB
database — so a dataset built specifically to exceed memory is measured entirely
out of cache, and the scale factor in the report says otherwise.

Measured on a 243 GB database, PostgreSQL 18 with 32 GB of shared buffers on a
host with 125 GB of RAM, 32 terminals, six minute runs each started from a
dropped page cache, statistics taken over the last three minutes:

throughput buffer misses per commit read rate
useAllWarehouses=false 18,496 tps 0.33 34 MB/s
useAllWarehouses=true 10,577 tps 4.86 403 MB/s

The first row is a cached workload whatever its scale factor says. The second is
the storage test that scale factor was chosen for. Fifteen times the buffer
misses per transaction is the difference between measuring a buffer pool and
measuring a storage engine.

Other TPC-C harnesses expose the same switch — HammerDB calls it "all
warehouses" — precisely because a database larger than memory is a common thing
to want to measure.

What this adds

<useAllWarehouses>true</useAllWarehouses>

Each terminal draws a warehouse, and a district within it, for every transaction
instead of using the one it was assigned. Nothing else changes: the transaction
mix, the remote warehouse rates in New-Order and Payment, and the amount of work
per transaction are the same, and the procedures themselves are untouched.

Runs made this way are not specification compliant — a terminal belongs to a
warehouse for the duration of a compliant run — and their tpmC is not comparable
with compliant results. Both the README and the option's javadoc say so.

The option is off by default; existing configurations behave exactly as before.

Testing

  • mvn test — 247 tests, all passing.
  • Coverage, on a 50 warehouse database driven by 8 terminals for 60 s, counting
    the warehouses whose highest order id advanced during the run:
    • false: 8 warehouses of 50
    • true: 50 of 50
  • All four TPC-C consistency conditions of clause 3.3.2 hold after both runs, and
    neither produced an SQL error:
    • w_ytd = sum(d_ytd) per warehouse
    • d_next_o_id - 1 = max(o_id) per district
    • the new_order ids of a district are contiguous
    • sum(o_ol_cnt) = count(order_line) per district
  • The two large runs above, on the 2000 warehouse database.

Note

This is independent of the stored procedure PR; the two branches both start from
the same upstream commit and touch different code, apart from both adding a field
to TPCCBenchmark.

A terminal is assigned a warehouse and stays on it for the whole run, as
the specification requires. A side effect is that the data a run touches
is bounded by the number of terminals rather than by the scale factor:
thirty-two terminals against a two thousand warehouse database address
thirty-two warehouses, so a database built to exceed memory is measured
entirely out of cache.

Measured on a 243 GB database with 32 GB of shared buffers and 125 GB of
RAM, 32 terminals, six minute runs from a cold page cache, the last three
minutes of each:

  useAllWarehouses=false   18,496 tps   0.33 buffer misses per commit
  useAllWarehouses=true    10,577 tps   4.86 buffer misses per commit

The first run reads 34 MB/s and is a cached workload whatever the scale
factor says. The second reads 403 MB/s and is the storage test the scale
factor was chosen for.

With <useAllWarehouses>true</useAllWarehouses> a terminal draws a
warehouse, and a district within it, for every transaction. Nothing else
changes: the transaction mix, the remote warehouse rates and the
consistency conditions are as before. Runs made this way are not
specification compliant and their tpmC is not comparable with compliant
results, which the option documents.

The option is off by default.
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.

1 participant