Skip to content

adapter: choose table append completion by group size#37627

Closed
def- wants to merge 1 commit into
MaterializeInc:mainfrom
def-:pr-txn
Closed

adapter: choose table append completion by group size#37627
def- wants to merge 1 commit into
MaterializeInc:mainfrom
def-:pr-txn

Conversation

@def-

@def- def- commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Motivation

Responding once a txn-wal commit is durable reduces table write latency, but allowing large single-table groups to continue before physical apply makes immediate reads pile up behind apply. The first version of this PR always waited for single-shard apply. That recovered the mixed read and write workload, but nightly testing exposed two new regressions:

  • InsertWorkload at concurrency 2 fell from 416.9 to 211.9 TPS, a 49.2% regression.
  • ManySmallInserts increased from 1.130s to 1.295s, a 14.5% regression.

Description

Make append response timing an explicit StorageController contract and let group commit choose the completion point. Multi-table writes and groups of up to four user writes respond once the txn-wal commit is durable. Larger single-table groups respond after physical apply. Bootstrap appends continue to wait for physical apply.

Also update the stray COPY pgtest expectation. Unsupported COPY FORMAT BINARY now correctly uses SQLSTATE 0A000 for feature not supported.

Verification

The response policy has a unit test, and the pgtest fixture covers both simple and extended query protocol paths.

Targeted optimized benchmarks against commit 75cdbb9 showed:

  • InsertWorkload at concurrency 2: 966 versus 848 TPS, 13.9% faster.
  • InsertWorkload at concurrency 4: 1591 versus 1549 TPS, 2.8% faster.
  • InsertWorkload at concurrency 16: 3326 versus 3259 TPS, 2.0% faster.
  • InsertAndSelectLimitWorkload at concurrency 16: 2638 versus 2448 TPS, 7.7% faster.
  • ManySmallInserts: 0.356s versus 0.358s, 0.6% faster.

Follow-up to #37443.

Nightly benchmark: https://buildkite.com/materialize/nightly/builds/17312

@def- def- requested a review from DAlperin July 14, 2026 09:29
@def- def- requested a review from a team as a code owner July 14, 2026 09:29
Txn-wal commits are durable before they are physically applied. Responding at commit reduces latency and prevents small group commits from starving, but allowing large single-table groups to continue before apply makes immediate reads pile up behind apply.

Make append response timing explicit in StorageController and let group commit choose it. Respond at durable commit for multi-table writes and groups of up to four user writes. Wait for physical apply for larger single-table groups.

This preserves pure-write throughput across concurrency levels while improving InsertAndSelectLimitWorkload by 7.7% at concurrency 16. Also update the stale pgtest expectation for unsupported COPY FORMAT BINARY to SQLSTATE 0A000.
@def- def- requested a review from a team as a code owner July 14, 2026 11:02
@def- def- changed the title storage-controller: apply single-shard writes before responding adapter: choose table append completion by group size Jul 14, 2026
@def- def- closed this Jul 14, 2026
def- added a commit that referenced this pull request Jul 14, 2026
…ply (#37443) (#37631)

This reverts commit 6c590b0.

I tried to fix performance regression the change introduced in other
benchmarks in #37627,
but failed.

This feels safer. It's too bad we lose the ~2.5x improvement the PR had
though.

Nightly perf. run shows us that we do lose some performance from
reverting: https://buildkite.com/materialize/nightly/builds/17318
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