zhangshenghang opened a new pull request, #13589:
URL: https://github.com/apache/seatunnel/pull/13589

   ### Purpose of this pull request
   
   Yes, I am contributing this JDBC optimization to Apache SeaTunnel. This 
change follows up on the converter benchmark introduced in #13214.
   
   Both conversion directions rebuilt the physical row type for every row. Sink 
parameter binding also resolved the native target type by column name for every 
field on every row.
   
   Each converter now retains one read metadata entry and one write metadata 
entry. The read entry stores the physical row type. The write entry stores the 
physical row type and target native types in parameter order. A different input 
or target schema instance rebuilds the relevant entry, including after schema 
evolution. Each call holds its own reference to the fully initialized entry. 
The entries are transient and can be rebuilt after deserialization. The cache 
is private to JDBC, so callers of the public schema API still receive a fresh 
row type.
   
   The existing per-type JDBC getters and setters, dialect hooks, generated 
SQL, batching, transaction boundaries and retry behavior are preserved.
   
   ### Does this PR introduce any user-facing change?
   
   JDBC conversion allocates less memory in steady state. Existing job 
configuration and data semantics are preserved.
   
   ### How was this patch tested?
   
   - Ran Spotless and 44 targeted JDBC tests on JDK 17. The regression tests 
switch read schemas, change a target binary column's native type, and bind a 
reordered source schema with a missing target metadata entry.
   - Extended the existing MySQL multi-table integration case so a single 
reader processes two projections with different widths and column orders.
   - Compared base commit `5cf050be` and this branch using the existing JDBC 
converter benchmark on the same arm64 macOS host. Results use the default mixed 
20-column fixture, two JVM forks per case, three warmup iterations, five 
measurement iterations, and the GC profiler.
   
   | JMH case | Base ops/s | Optimized ops/s | Base B/op | Optimized B/op |
   | --- | ---: | ---: | ---: | ---: |
   | Read conversion | 1,647,422 | 4,194,336 | 2,712 | 1,128 |
   | Sink parameter binding | 1,096,669 | 3,170,125 | 2,712 | 1,144 |
   
   ```bash
   ./mvnw -Pbenchmark -pl seatunnel-benchmarks -am -DskipTests -Dskip.ui=true 
-Dlicense.skipAddThirdParty=true package
   java -jar seatunnel-benchmarks/target/benchmarks.jar 
JdbcRowConverterBenchmark \
     -f 2 -wi 3 -i 5 -w 600ms -r 800ms -prof gc -foe true \
     -jvmArgsAppend '-Xms512m -Xmx512m -XX:+UseG1GC -XX:ActiveProcessorCount=4'
   ```
   
   I also ran the real SeaTunnel `JdbcInputFormat` and `JdbcSinkWriter` against 
an isolated MySQL 8.0.43 instance. Each version warmed up with 150,000 rows and 
then processed 500,000 mixed 12-column rows per run. Both versions used 
Connector/J 8.0.27, plain INSERT, 10,000 rows per batch, autocommit and binary 
logging. Below are the medians from three interleaved runs per version. Each 
copy verified the target row count and all 12 columns against the source by 
primary key.
   
   | MySQL JDBC component test | Base rows/s | Optimized rows/s | Throughput 
change | JVM allocation per row |
   | --- | ---: | ---: | ---: | ---: |
   | Read only | 558,946 | 586,063 | +4.9% | 3,511 → 2,479 B |
   | Read and write | 64,684 | 72,835 | +12.6% | 12,239 → 10,191 B |
   
   The MySQL timings cover the JDBC components in a single-thread driver 
program. Engine scheduling and network between workers are outside these 
timings.
   
   The Zeta and MySQL multi-table integration case passed.
   
   ```bash
   RUN_ENGINES=zeta ./mvnw -Pci -pl :connector-jdbc-e2e-part-1 -am \
     -DskipUT=true -DskipIT=false 
-Dit.test=JdbcMysqlMultipleTablesIT#testMysqlJdbcMultipleTableE2e \
     -Dit.failIfNoSpecifiedTests=false -Dskip.ui=true 
-Dlicense.skipAddThirdParty=true verify
   ```
   
   The full-repository Maven verify is running locally.
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to