Skip to content

[FLINK-38199][benchmark] Add SinkUpsertMaterializerBenchmark for V1 and V2 - #126

Open
MartijnVisser wants to merge 2 commits into
apache:masterfrom
MartijnVisser:FLINK-38199-sum-benchmark
Open

MartijnVisser wants to merge 2 commits into
apache:masterfrom
MartijnVisser:FLINK-38199-sum-benchmark

Conversation

@MartijnVisser

@MartijnVisser MartijnVisser commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Purpose of the change

FLINK-38199 adds a benchmark for the sink upsert materializer. This supersedes #106, which stalled after the review in August 2025. Roman's commit is kept as the first one, formatted for spotless and checkstyle.

Brief change log

  • SinkUpsertMaterializerBenchmark with the flink-table-runtime test-jar (Roman's commit).
  • Steady-state invocation as requested in [FLINK-38199] Add SinkUpsertMaterializerBenchmark #106, retracting the row in the middle of the history, the four table.exec.sink.upsert-materialize-strategy.type strategies as strategy, historyLength instead of retractDelay and retractPercentage, and the method renamed to sinkUpsertMaterializer for codespeed.

Verifying this change

Nightly settings (3 forks, 1s iterations), Apple M4 Pro, JDK 17.0.20, Flink 2.5-SNAPSHOT of 2026-10-27:

Benchmark               (hasUpsertKey)  (historyLength)  (stateBackend)  (strategy)  Cnt      Score      Error  Units
sinkUpsertMaterializer           false                1            HEAP      LEGACY   30  11672.290  ± 207.134  ops/ms
sinkUpsertMaterializer           false                1            HEAP       VALUE   30  10934.342  ± 336.420  ops/ms
sinkUpsertMaterializer           false                1            HEAP         MAP   30   3725.430  ± 199.853  ops/ms
sinkUpsertMaterializer           false                1            HEAP    ADAPTIVE   30  10602.502  ± 234.836  ops/ms
sinkUpsertMaterializer           false                1         ROCKSDB      LEGACY   30   1093.548  ±   8.109  ops/ms
sinkUpsertMaterializer           false                1         ROCKSDB       VALUE   30   1098.939  ±   6.432  ops/ms
sinkUpsertMaterializer           false                1         ROCKSDB         MAP   30    134.725  ±   1.393  ops/ms
sinkUpsertMaterializer           false                1         ROCKSDB    ADAPTIVE   30   1076.401  ±   6.093  ops/ms
sinkUpsertMaterializer           false              500            HEAP      LEGACY   30   2435.096  ±  10.258  ops/ms
sinkUpsertMaterializer           false              500            HEAP       VALUE   30   3468.880  ±  23.754  ops/ms
sinkUpsertMaterializer           false              500            HEAP         MAP   30   3024.327  ±  52.651  ops/ms
sinkUpsertMaterializer           false              500            HEAP    ADAPTIVE   30   2674.529  ±  15.488  ops/ms
sinkUpsertMaterializer           false              500         ROCKSDB      LEGACY   30     61.423  ±   0.713  ops/ms
sinkUpsertMaterializer           false              500         ROCKSDB       VALUE   30     51.788  ±   0.490  ops/ms
sinkUpsertMaterializer           false              500         ROCKSDB         MAP   30     92.584  ±   2.823  ops/ms
sinkUpsertMaterializer           false              500         ROCKSDB    ADAPTIVE   30     78.044  ±   1.431  ops/ms
sinkUpsertMaterializer            true                1            HEAP      LEGACY   30  11126.870  ± 142.354  ops/ms
sinkUpsertMaterializer            true                1            HEAP       VALUE   30  10911.535  ± 317.291  ops/ms
sinkUpsertMaterializer            true                1            HEAP         MAP   30   4566.504  ± 299.417  ops/ms
sinkUpsertMaterializer            true                1            HEAP    ADAPTIVE   30  10022.936  ± 406.970  ops/ms
sinkUpsertMaterializer            true                1         ROCKSDB      LEGACY   30   1110.359  ±  10.663  ops/ms
sinkUpsertMaterializer            true                1         ROCKSDB       VALUE   30   1087.621  ±   5.760  ops/ms
sinkUpsertMaterializer            true                1         ROCKSDB         MAP   30    119.707  ±   1.945  ops/ms
sinkUpsertMaterializer            true                1         ROCKSDB    ADAPTIVE   30   1087.451  ±   8.032  ops/ms
sinkUpsertMaterializer            true              500            HEAP      LEGACY   30    656.858  ±   4.361  ops/ms
sinkUpsertMaterializer            true              500            HEAP       VALUE   30   1612.959  ±  49.669  ops/ms
sinkUpsertMaterializer            true              500            HEAP         MAP   30   3725.263  ±  64.487  ops/ms
sinkUpsertMaterializer            true              500            HEAP    ADAPTIVE   30   3669.555  ±  96.052  ops/ms
sinkUpsertMaterializer            true              500         ROCKSDB      LEGACY   30     51.840  ±   2.317  ops/ms
sinkUpsertMaterializer            true              500         ROCKSDB       VALUE   30     50.032  ±   1.457  ops/ms
sinkUpsertMaterializer            true              500         ROCKSDB         MAP   30     80.890  ±   1.172  ops/ms
sinkUpsertMaterializer            true              500         ROCKSDB    ADAPTIVE   30     67.167  ±   0.766  ops/ms

In a short run with the sink loggers at INFO, no retraction missed its row in any combination.

Impact and documentation

Adds 32 combinations, about 35 minutes in the nightly run.


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: Claude Code (Claude Opus 5.5)

Squashed from apache#106 and rebased onto master,
with spotless and checkstyle fixes applied.

@rkhachatryan rkhachatryan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for resurrecting this :)

I've left some comments, PTAL.

harness = getHarness(createSum(hasUpsertKey), stateBackend);
payload = generatePayload(payloadSize);
numRecordsTotal = RECORDS_PER_INVOCATION;
retractOffset = (1 + retractDelay) / 2;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Older version retracted an element from the middle; new version retracts from the tail.
That eliminates the O(N) list scan when using list-backed state.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It now retracts the middle row. #106 hit the oldest row too, since retractPercentage 100 skips retractDelay. LEGACY on HEAP without an upsert key at 500 rows drops from 9850 to 2435 ops/ms.

Comment on lines +177 to +178
SequencedMultiSetStateConfig.defaults(
TimeDomain.PROCESSING_TIME, TTL_CONFIG));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we have more cases benchmarked here?

  • defaults/forValue is a slightly modified V1
  • forMap is a map-based implementation
  • adaptive is a combination that should be used in Production

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've added them, configured as StreamExecSink does with the default adaptive thresholds. ADAPTIVE stays on VALUE at 1 row and on MAP at 500. That doubles its nightly time to about 35 minutes.

…re steady state

Build the history in the iteration setup and have each invocation
insert one row and retract the middle row, so the measured method no
longer creates a harness and the history length stays constant. Add
the table.exec.sink.upsert-materialize-strategy.type strategies as a
parameter and replace retractDelay and retractPercentage with
historyLength.

Generated-by: Claude Code (Claude Opus 5.5)
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