You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "nzw921rx (via GitHub)" <gi...@apache.org> on 2026/09/06 05:16:02 UTC
[I] [Feature][Benchmark] Add open-loop MultiTableSinkWriter benchmarks [seatunnel]
nzw921rx opened a new issue, #12145:
URL: https://github.com/apache/seatunnel/issues/12145
### Search before asking
- [x] I had searched in the [feature](https://github.com/apache/seatunnel/issues?q=is%3Aissue+label%3A%22Feature%22) and found no similar feature requirement.
### Description
## Motivation
`MultiTableSinkWriter` is a shared runtime path for multi-table writes. Each record passes through table lookup, queue selection, asynchronous handoff, and dispatch to a child `SinkWriter`.
These operations introduce framework costs independently of the destination database or connector, including synchronization, queue operations, object allocation, and pending-record accounting.
Add a focused benchmark that measures this internal path under an open-loop workload and verifies that records actually reach the correct child writers.
A successful return from `MultiTableSinkWriter.write()` only confirms enqueueing. It must not be treated as successful completion of the child writer's processing.
Related benchmark framework: #11598.
## Scope
Cover the complete internal path:
`MultiTableSinkWriter.write(row)` → production queue → production worker → child `SinkWriter.write(row)` completion.
Use the real `MultiTableSinkWriter` and its asynchronous workers, with lightweight in-memory child writers. No database, network, or external service is required.
The initial implementation should cover:
- `writeWithPrimaryKey`: records are routed using the production primary-key routing logic.
- `writeWithoutPrimaryKey`: records are routed using the production no-primary-key routing logic.
Both scenarios must support multiple tables and multiple worker queues.
Use a small parameter set for table count, queue count, and target arrival rate. Document the chosen values and keep the default run practical.
## Code organization
Place the JMH measurement class at:
`seatunnel-benchmarks/src/main/java/org/apache/seatunnel/benchmark/MultiTableSinkWriterBenchmark.java`
Place supporting code in:
`seatunnel-benchmarks/src/main/java/org/apache/seatunnel/benchmark/multisink/`
The support package should separate these responsibilities:
- In-memory child writer implementation.
- Fixture construction and lifecycle management.
- Open-loop load generation.
- Consumption tracking and result validation.
Suggested classes:
- `InMemorySinkWriter`
- `MultiSinkBenchmarkFixture`
- `OpenLoopLoadGenerator`
- `MultiSinkResultVerifier`
Keep the outer benchmark class focused on parameters, lifecycle, and measurement entry points.
## Child writer fixture
Create a distinct child writer instance for each configured table/writer replica.
The child writers may use the same lightweight implementation. Different external connector implementations are not required.
The fixture must:
- Construct valid `SinkIdentifier`, writer context, and resource-sharing configuration.
- Register each child writer with the appropriate table and replica.
- Consume records without database, file, or network I/O.
- Track completion only after the child writer has processed the record.
- Keep mutable tracking state local to each child writer where possible.
- Avoid a shared per-record global lock or contended global counter.
- Avoid retaining every consumed row indefinitely.
A single shared dummy writer for every table and replica is insufficient because it would hide routing errors.
## Open-loop workload
Generate arrivals according to a predetermined schedule and target rate.
The schedule must not depend on the completion of previous records or batches:
- Do not wait for a record to complete before submitting the next one.
- Do not use a repeated "submit batch → wait for completion → submit next batch" workload.
- Do not calculate each next arrival as "previous write return time + interval".
- Keep the original planned arrival times when submission falls behind.
The production `write()` call may block when its bounded queue is full. In that case:
- Record submission lag relative to the planned arrival time.
- Report that the configured target rate could not be maintained.
- Do not silently lower the target rate.
- Do not add unbounded staging buffers, tasks, or producer threads.
- Use a bounded run duration and bounded shutdown/drain timeout.
Use one submitting thread per `MultiTableSinkWriter` instance for the initial scope. Its production queue workers remain asynchronous.
Each measured run should have a defined arrival window. After arrivals stop, drain outstanding work for validation, with a timeout. Report drain results separately from completions achieved during the arrival window.
A plain JMH loop calling `write()` is not sufficient to establish open-loop behavior.
## Deterministic input
Prepare the input fixture before measurement:
- Fixed table identifiers and row schemas.
- Deterministic field values and table distribution.
- Stable primary keys for the primary-key scenario.
- Sequence information sufficient to validate delivery and ordering.
- A bounded input fixture or safe record-reuse strategy.
Do not modify or recycle a submitted row while an asynchronous worker may still be using it.
The no-primary-key scenario should exercise the production random routing behavior. It must not require an exact distribution across worker queues.
## Completion and correctness validation
Validate the actual child writer output, not only the return value of the outer `write()` call.
Required checks:
- All successfully submitted records are consumed after the final drain.
- No records are lost or duplicated.
- Every record reaches a writer registered for its intended table.
- Records for the same table and primary key preserve submission order.
- No global ordering guarantee is imposed on the no-primary-key scenario.
- No asynchronous worker error is ignored.
- Outstanding work does not leak into the next measured run.
Distinguish records that were planned, successfully submitted, and actually completed. Records not submitted before a run deadline must be reported separately.
Use bounded validation state. Perform detailed assertions outside the measured path, with a deterministic correctness run where necessary. Keep measured-path tracking lightweight and document its overhead.
## Measurement and reporting
Report direct measurements with clearly defined units:
- Configured arrival rate.
- Planned, successfully submitted, and completed record counts.
- Actual submission throughput.
- Actual completion throughput.
- Submission lag relative to the planned schedule.
- Outstanding submitted records over time or their observed peak.
- Latency from planned arrival to child writer completion.
- Final drain duration and any remaining records or timeout.
Define outstanding records as submitted but not yet completed; this includes both queued and currently processing records.
Distinguish target rate from achieved throughput. A benchmark that falls behind must expose the lag and backlog rather than appearing healthy because its producer slowed down.
No additional normalization scheme or normalized metrics are required.
CPU, wall-clock, lock, and allocation profiling may be used to explain observed costs. Profiling is diagnostic support, not a substitute for completion and correctness validation.
## JMH integration and lifecycle
Extend `BenchmarkBase` and reuse the project's standard warm-up, measurement, fork, and output configuration where applicable.
Document how the open-loop arrival window maps to a JMH invocation and how results are reported. If an invocation represents an entire workload window, its JMH `ops/s` score must not be presented as records per second.
Before measurement:
- Build schemas, rows, contexts, and child writers.
- Construct the production `MultiTableSinkWriter`.
- Start and warm up its queue workers.
- Ensure warm-up records have completed and reset measurement tracking.
After measurement:
- Stop arrivals.
- Drain outstanding records within a bounded timeout.
- Validate consumption.
- Close the writer and terminate all supporting threads.
Benchmark state must not be accidentally shared between independent JMH workers.
## Out of scope
Do not include:
- Real JDBC, Kafka, file, or network sinks.
- Full SeaTunnel engine jobs.
- DDL or schema-change performance scenarios.
- Checkpoint or commit performance scenarios.
- Failure injection, retry, or table-isolation performance scenarios.
- Production implementation optimizations.
- Automatic performance thresholds or blocking CI gates.
Potential optimizations discovered through this benchmark should be proposed separately, with comparable before-and-after evidence.
## Validation
The contribution should:
- Pass the applicable formatting and build checks.
- Build the benchmark module.
- Execute both benchmark scenarios independently.
- Pass deterministic routing and delivery validation.
- Include a short open-loop smoke run.
- Demonstrate submission-lag reporting when the target rate cannot be maintained.
- Shut down cleanly without leaked workers or an unbounded drain.
Attach the workload configuration and representative output so reviewers can verify the measurement semantics.
## Acceptance criteria
- [ ] The benchmark exercises the real multi-table routing, queue, and worker path.
- [ ] Multiple independent in-memory child writer instances are configured.
- [ ] Primary-key and no-primary-key scenarios are both covered.
- [ ] Arrivals follow an open-loop schedule independent of consumption.
- [ ] Blocking submission is reflected in lag and achieved-rate reporting.
- [ ] Completion is observed at the child writer.
- [ ] Delivery count, routing, duplicates, and required ordering are validated.
- [ ] Fixture and validation memory remain bounded.
- [ ] The measurement class and `multisink` support package are separated.
- [ ] No external I/O, unrelated production changes, or normalization requirements are introduced.
- [ ] Build, smoke execution, correctness validation, and cleanup pass.
### Usage Scenario
_No response_
### Related issues
Provide repeatable performance evidence for changes to SeaTunnel's shared multi-table sink runtime.
The benchmark measures whether MultiTableSinkWriter can sustain a configured arrival rate while correctly routing and completing records across multiple tables and writer workers, independently of destination connector or database performance.
It helps reviewers identify changes in completion throughput, submission lag, processing latency, and backlog, and provides a baseline for investigating synchronization, routing, queueing, and allocation costs.
### Are you willing to submit a PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Feature][Benchmark] Add open-loop MultiTableSinkWriter benchmarks [seatunnel]
Posted by "nzw921rx (via GitHub)" <gi...@apache.org>.
nzw921rx closed issue #12145: [Feature][Benchmark] Add open-loop MultiTableSinkWriter benchmarks
URL: https://github.com/apache/seatunnel/issues/12145
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Feature][Benchmark] Add open-loop MultiTableSinkWriter benchmarks [seatunnel]
Posted by "nzw921rx (via GitHub)" <gi...@apache.org>.
nzw921rx commented on issue #12145:
URL: https://github.com/apache/seatunnel/issues/12145#issuecomment-5560095956
After reviewing the complete production path again, I am closing this issue for now.
MultiTableSinkWriter.write() returns after enqueueing, while child-writer completion happens asynchronously. The production drain paths call checkQueueRemain(), but including prepareCommit(long), snapshotState(), or close() in the measured region would introduce drain polling and unrelated lifecycle work. Waiting for each record to complete would instead turn the workload into closed-loop execution, while a fixed-rate open-loop window would make the JMH score largely reflect the configured arrival schedule.
Therefore, the current design cannot cleanly produce meaningful JMH Score, Error, and CV for the complete asynchronous path without measuring only enqueueing or changing the workload into a batch/saturation benchmark. We can revisit this benchmark when a suitable measurement model is available.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org