From 7482da58353ee31dd0f637f84a7c3f9a4a319e4d Mon Sep 17 00:00:00 2001 From: Jordan Epstein Date: Mon, 30 Nov 2026 20:17:21 -0500 Subject: [PATCH 1/3] Benchmark streaming Paimon log ingestion across the routing regression Measure a complete write-only append job with an SLS-shaped row source, the date partition projection, checkpoint commits, and exact stock readback. Verify the submitted native graph and file encoders and retain the release checkout comparisons, isolated routing ablation, and CPU and allocation profile findings. Restoring local routing on the November 20 checkout improves median throughput 1.16x. Current upstream processes 2.12 million rows per second on the same four-writer shape. The alternate single-writer path did not establish an elapsed-time improvement. --- docs/benchmarks/paimon-log-sink.md | 138 +++++++++ .../results/paimon-log-sink-20261130.csv | 85 ++++++ docs/connectors/paimon.md | 3 +- docs/optimizations/paimon-local-append.md | 5 + mkdocs.yml | 1 + .../paimon/PaimonLogSinkBenchmark.java | 285 ++++++++++++++++++ 6 files changed, 516 insertions(+), 1 deletion(-) create mode 100644 docs/benchmarks/paimon-log-sink.md create mode 100644 docs/benchmarks/results/paimon-log-sink-20261130.csv create mode 100644 streamfusion-paimon/src/benchmark/java/tech/streamfusion/paimon/PaimonLogSinkBenchmark.java diff --git a/docs/benchmarks/paimon-log-sink.md b/docs/benchmarks/paimon-log-sink.md new file mode 100644 index 000000000..c5c0e3bee --- /dev/null +++ b/docs/benchmarks/paimon-log-sink.md @@ -0,0 +1,138 @@ +# Streaming Paimon log sink + +`PaimonLogSinkBenchmark` submits a Flink streaming SQL job and times execution from +MiniCluster submission through the final Paimon commit. It uses a bounded, deterministic +row source that generates log content, hostname and path values, and epoch-second +timestamps. The projection applies the hostname/path NULL and space checks, conditional +concatenation, `FROM_UNIXTIME`, substring extraction, and 15-minute rounding. The public +Flink SQL spelling for the stakeholder's `LENGTH` call is `CHAR_LENGTH`. + +The sink is a Paimon Parquet append table partitioned by `ds`, `hh`, and `mm`, with +`bucket=-1`, `write-only=true`, `changelog-producer=none`, and the six-hour update-time +partition expiration option. The default uses four source subtasks, four writers, four +interleaved partitions crossing midnight UTC, two million rows, 256-byte input messages, +65,536 deterministic message tails, and one-second checkpoints. The fixture substitutes a +local warehouse and a generated source for SLS and DFS. It uses the released Paimon Java +connector and omits deployment-specific catalog and connector options. The job duration +covers periodic and final commits. The six-hour retention window stays open throughout +each trial. + +Stock and native jobs alternate order after a warmup for each engine. The timed interval +includes source generation, Flink job startup, the SQL transformation, required row/Arrow +conversions and IPC, Parquet encoding, filesystem writes, and commits. Planning and +verification occur outside the interval. Each trial checks the submitted graph, reads the +committed data through Paimon's released reader, checks every ID and exact content and +partition values, and verifies the writer in every Parquet footer. It reports native Calc +use, the presence of the round-robin stage, committed snapshots, file count, Parquet +bytes, elapsed time, and throughput. + +## Reproduce + +Run locally on a controlled host with JDK 17 and release native libraries. + +```sh +mvn -Ppaimon,bench,benchmarks -pl streamfusion-paimon -am test \ + -Dtest=PaimonLogSinkBenchmark -Dsurefire.failIfNoSpecifiedTests=false \ + -Dsf.paimon.log.benchmark=true +``` + +Use `-Dsf.paimon.log.partitions=1` for one active 15-minute partition and +`-Dsf.paimon.log.partitions=24` for six hours of interleaved arrivals. Use +`-Dsf.paimon.log.writers=1` to exercise redistribution at a source parallelism of four. +The other knobs are `rows`, `parallelism`, `payloadBytes`, `payloadVariants`, +`checkpointMs`, `warmup`, and `runs`, all prefixed with `sf.paimon.log.`. Set +`-Dsf.paimon.log.engine=STOCK` or `NATIVE` for a single-engine profile. The benchmark +deletes its temporary warehouse after each trial. Set `java.io.tmpdir` for the fork to +place warehouse and Flink runtime files on the disk under test. + +For CPU, allocation, and wall-clock sampling with async-profiler on macOS, set the fork +JVM argument below and run one engine per recording. The equivalent CPU event on Linux +is `cpu`. Filter the output to Flink task threads to exclude planning and readback. +Use unprofiled invocations for elapsed-time comparisons. + +```sh +-Dsf.extraJvmArgs="-XX:+PreserveFramePointer -agentpath:$agent=start,event=itimer,interval=2ms,alloc=256k,wall=10ms,threads,cstack=fp,file=$recording" +``` + +Copy the benchmark into the corresponding test source tree for revisions before the +`benchmarks` profile existed. Build release libraries from each historical checkout, and +run the same fixture and settings. A single-file planner overlay can additionally +measure a routing change while holding the rest of the runtime constant. + +## Historical routing regression + +A ten-step source bisect from `743adedcf` to `3082b2626` located the added row/channel +reassignment at `8f12e1637` (November 13). That path reached main in `9d44371f1`, including append jobs +whose input and writers already had the same parallelism. `71dbaf767` (November 28) restored +local writer chaining in that case. The `v0.1.0-rc5` tag contains the added route and predates +the fix. The additional route split already partition-grouped Arrow batches, crossed the C +Data Interface again, serialized the routed batches and stripped the channel at the writer. + +To isolate the change, the A/B comparison overlays the released `71dbaf767` sink planner +class on `3082b2626` (November 20). Both sides use the same Flink 2.2.1 and Paimon 2.1.0 +artifacts, native release libraries, SQL, fixture, and resources. The local Apple M4 host +runs macOS 15.3.1 and Temurin 17.0.17 with a 3 GiB Java heap and six active JVM processors. +Release libraries use mimalloc with the unused native RocksDB feature disabled. Each +side uses two independent JVMs with one warmup and two measured jobs each. Fork order is +local, baseline, baseline, local. + +| Four million rows, four partitions, four writers | Median s (range) | Median rows/s | +| --- | ---: | ---: | +| November 20, additional route and exchange | 2.531 (2.404–2.789) | 1,580,617 | +| November 20 with local routing from November 28 | 2.180 (1.960–2.450) | 1,834,839 | + +Local routing increased throughput **1.16×** and reduced median elapsed time **13.9%**. +The patched runs also wrote 774 MB per job versus 704–772 MB in the original measured +runs. Changing the routing changes the order seen by the encoder. An initial 8,192-tail +corpus amplified the resulting compression difference, so the primary comparison uses +65,536 tails and reports the physical bytes for every job. + +In diagnostic runs with async-profiler 4.6, the additional round-robin operator appeared +in 2,295 of 18,256 CPU samples (12.6%) and 40.1% of estimated Java allocation bytes on the +Flink task threads. These are inclusive stacks, so downstream work can appear under the +operator. The local variant had no such frames or Arrow IPC serializer frames in the +task-thread allocation recording. Across three jobs with identical input counts, sampled +task-thread allocation weight fell from 56.8 GB to 22.3 GB (−61%). These figures estimate +intermediate allocation traffic. Peak heap and RSS were outside this profile. With the +extra exchange removed, Calc and file encoding remain prominent in CPU samples. The +wall-clock recording was dominated by condition and semaphore waits and is unsuitable as +a stage throughput breakdown. + +### Release checkout comparison + +The historical checkout runs use their own release libraries. Each checkout alternates +stock Flink and native jobs with one warmup and three measured jobs per engine. The +November 20 row takes the four-million-row native samples from the routing ablation above. + +| Git revision | Paimon | Native median s (range) | Stock median s (range) | Native median rows/s | +| --- | --- | ---: | ---: | ---: | +| Oct 29, `743adedcf` | 2.0.0 | 1.918 (1.888–1.975) | 3.373 (3.218–3.478) | 2,085,636 | +| Nov 20, `3082b2626` | 2.1.0 | 2.531 (2.404–2.789) | — | 1,580,617 | +| Nov 30, `1e5d322ba` | 2.1.0 | 1.882 (1.830–1.912) | 3.129 (3.012–3.210) | 2,124,980 | + +The November 30 checkout processed **1.66×** as many rows per second as its stock Flink +control. The October and November 30 native runs used local writer chaining. Their +comparison includes intervening runtime and Paimon changes. The routing ablation controls +for those changes. Live SLS, DFS, and the stakeholder's connector distribution require +separate measurements for production throughput. + +At 24 interleaved partitions and two million rows, medians were 1.988 s (1.946–2.042) +native and 2.031 s (1.934–2.205) stock. The ranges overlap. Snapshot boundaries and +file counts varied across trials. The four-partition speedup depends on the workload's +active partitions and checkpoint behavior. + +### One writer + +An experimental global exchange sent already routed bucket-zero batches from four source +tasks to one writer and avoided a second grouping. It passed the submitted-graph and +checkpoint-recovery checks on Flink 2.2/Paimon 2.1 and Flink 1.18/Paimon 2.0 and 1.0. +At 256 bytes per message and four million rows, the original median was 3.045 s +(3.028–3.073) and the direct-exchange median was 3.017 s (2.988–3.060). At 1,024 bytes +and two million rows, those medians were 4.084 s (3.978–4.189) and 4.216 s +(4.148–4.283). The profiling run showed 35.2 GB versus 34.6 GB of sample-weighted +Java task allocation, including warmup. The wider run and the overlapping narrow +samples leave the additional shortcut without a demonstrated elapsed-time gain. +The checked-in runtime uses the existing redistribution when writer parallelism differs. + +The [structured trial data](results/paimon-log-sink-20261130.csv) include warmups, +diagnostics, file counts, and physical sizes alongside the unprofiled measurements. diff --git a/docs/benchmarks/results/paimon-log-sink-20261130.csv b/docs/benchmarks/results/paimon-log-sink-20261130.csv new file mode 100644 index 000000000..1305a3e19 --- /dev/null +++ b/docs/benchmarks/results/paimon-log-sink-20261130.csv @@ -0,0 +1,85 @@ +comparison,revision,variant,recording,fork,engine,trial,rows,parallelism,writers,partitions,payload_bytes,payload_variants,checkpoint_ms,seconds,rows_per_second,snapshots,files,bytes,native_calc,round_robin +stock-native-initial,3082b2626256d2d24f508dad0d86fae062ec4bf7,unmodified,unprofiled,1,NATIVE,-1,2000000,4,4,4,256,8192,1000,2.730920,732354,2,32,97576979,true,true +stock-native-initial,3082b2626256d2d24f508dad0d86fae062ec4bf7,unmodified,unprofiled,1,STOCK,-1,2000000,4,4,4,256,8192,1000,2.452358,815542,2,32,387814160,false,false +stock-native-initial,3082b2626256d2d24f508dad0d86fae062ec4bf7,unmodified,unprofiled,1,STOCK,0,2000000,4,4,4,256,8192,1000,2.050862,975200,3,48,387839954,false,false +stock-native-initial,3082b2626256d2d24f508dad0d86fae062ec4bf7,unmodified,unprofiled,1,NATIVE,0,2000000,4,4,4,256,8192,1000,1.480802,1350619,2,32,99241230,true,true +stock-native-initial,3082b2626256d2d24f508dad0d86fae062ec4bf7,unmodified,unprofiled,1,NATIVE,1,2000000,4,4,4,256,8192,1000,1.421002,1407458,1,16,101995136,true,true +stock-native-initial,3082b2626256d2d24f508dad0d86fae062ec4bf7,unmodified,unprofiled,1,STOCK,1,2000000,4,4,4,256,8192,1000,1.857414,1076766,2,32,387817823,false,false +stock-native-initial,3082b2626256d2d24f508dad0d86fae062ec4bf7,unmodified,unprofiled,1,STOCK,2,2000000,4,4,4,256,8192,1000,1.847699,1082427,2,32,387819689,false,false +stock-native-initial,3082b2626256d2d24f508dad0d86fae062ec4bf7,unmodified,unprofiled,1,NATIVE,2,2000000,4,4,4,256,8192,1000,1.378627,1450718,2,32,131916970,true,true +append-routing-initial,3082b2626256d2d24f508dad0d86fae062ec4bf7,round-robin,unprofiled,1,NATIVE,-1,2000000,4,4,4,256,8192,1000,2.646141,755817,3,48,99144267,true,true +append-routing-initial,3082b2626256d2d24f508dad0d86fae062ec4bf7,round-robin,unprofiled,1,NATIVE,0,2000000,4,4,4,256,8192,1000,1.468122,1362285,2,32,97477071,true,true +append-routing-initial,3082b2626256d2d24f508dad0d86fae062ec4bf7,round-robin,unprofiled,1,NATIVE,1,2000000,4,4,4,256,8192,1000,1.485495,1346352,2,32,104307191,true,true +append-routing-initial,3082b2626256d2d24f508dad0d86fae062ec4bf7,round-robin,unprofiled,2,NATIVE,-1,2000000,4,4,4,256,8192,1000,2.640788,757350,3,48,145254035,true,true +append-routing-initial,3082b2626256d2d24f508dad0d86fae062ec4bf7,round-robin,unprofiled,2,NATIVE,0,2000000,4,4,4,256,8192,1000,1.536164,1301945,2,32,95427958,true,true +append-routing-initial,3082b2626256d2d24f508dad0d86fae062ec4bf7,round-robin,unprofiled,2,NATIVE,1,2000000,4,4,4,256,8192,1000,1.380033,1449240,2,32,126366712,true,true +append-routing-initial,3082b2626256d2d24f508dad0d86fae062ec4bf7,local-planner-overlay,unprofiled,1,NATIVE,-1,2000000,4,4,4,256,8192,1000,2.553072,783370,2,24,387917689,true,false +append-routing-initial,3082b2626256d2d24f508dad0d86fae062ec4bf7,local-planner-overlay,unprofiled,1,NATIVE,0,2000000,4,4,4,256,8192,1000,1.474058,1356799,2,32,387990280,true,false +append-routing-initial,3082b2626256d2d24f508dad0d86fae062ec4bf7,local-planner-overlay,unprofiled,1,NATIVE,1,2000000,4,4,4,256,8192,1000,1.181094,1693346,1,16,387873990,true,false +append-routing-initial,3082b2626256d2d24f508dad0d86fae062ec4bf7,local-planner-overlay,unprofiled,2,NATIVE,-1,2000000,4,4,4,256,8192,1000,2.462858,812065,2,28,387936554,true,false +append-routing-initial,3082b2626256d2d24f508dad0d86fae062ec4bf7,local-planner-overlay,unprofiled,2,NATIVE,0,2000000,4,4,4,256,8192,1000,1.278729,1564052,2,32,387986700,true,false +append-routing-initial,3082b2626256d2d24f508dad0d86fae062ec4bf7,local-planner-overlay,unprofiled,2,NATIVE,1,2000000,4,4,4,256,8192,1000,1.753431,1140621,2,32,387986902,true,false +append-routing-ablation,3082b2626256d2d24f508dad0d86fae062ec4bf7,round-robin,unprofiled,1,NATIVE,-1,4000000,4,4,4,256,65536,1000,3.948404,1013068,4,64,756675628,true,true +append-routing-ablation,3082b2626256d2d24f508dad0d86fae062ec4bf7,round-robin,unprofiled,1,NATIVE,0,4000000,4,4,4,256,65536,1000,2.493317,1604288,3,48,719036701,true,true +append-routing-ablation,3082b2626256d2d24f508dad0d86fae062ec4bf7,round-robin,unprofiled,1,NATIVE,1,4000000,4,4,4,256,65536,1000,2.567998,1557634,3,48,703533560,true,true +append-routing-ablation,3082b2626256d2d24f508dad0d86fae062ec4bf7,round-robin,unprofiled,2,NATIVE,-1,4000000,4,4,4,256,65536,1000,3.838551,1042060,4,64,691763313,true,true +append-routing-ablation,3082b2626256d2d24f508dad0d86fae062ec4bf7,round-robin,unprofiled,2,NATIVE,0,4000000,4,4,4,256,65536,1000,2.789433,1433983,3,48,750121968,true,true +append-routing-ablation,3082b2626256d2d24f508dad0d86fae062ec4bf7,round-robin,unprofiled,2,NATIVE,1,4000000,4,4,4,256,65536,1000,2.404032,1663872,3,48,772141242,true,true +append-routing-ablation,3082b2626256d2d24f508dad0d86fae062ec4bf7,local-planner-overlay,unprofiled,1,NATIVE,-1,4000000,4,4,4,256,65536,1000,2.906709,1376127,3,48,774510120,true,false +append-routing-ablation,3082b2626256d2d24f508dad0d86fae062ec4bf7,local-planner-overlay,unprofiled,1,NATIVE,0,4000000,4,4,4,256,65536,1000,2.449974,1632671,2,32,774449134,true,false +append-routing-ablation,3082b2626256d2d24f508dad0d86fae062ec4bf7,local-planner-overlay,unprofiled,1,NATIVE,1,4000000,4,4,4,256,65536,1000,1.959907,2040913,3,48,774560215,true,false +append-routing-ablation,3082b2626256d2d24f508dad0d86fae062ec4bf7,local-planner-overlay,unprofiled,2,NATIVE,-1,4000000,4,4,4,256,65536,1000,3.132684,1276860,3,48,774547298,true,false +append-routing-ablation,3082b2626256d2d24f508dad0d86fae062ec4bf7,local-planner-overlay,unprofiled,2,NATIVE,0,4000000,4,4,4,256,65536,1000,2.034270,1966307,2,32,774448694,true,false +append-routing-ablation,3082b2626256d2d24f508dad0d86fae062ec4bf7,local-planner-overlay,unprofiled,2,NATIVE,1,4000000,4,4,4,256,65536,1000,2.325786,1719849,2,32,774448502,true,false +append-routing-profile,3082b2626256d2d24f508dad0d86fae062ec4bf7,round-robin,itimer+allocation+wall,1,NATIVE,-1,4000000,4,4,4,256,65536,1000,4.105501,974302,4,64,745881095,true,true +append-routing-profile,3082b2626256d2d24f508dad0d86fae062ec4bf7,round-robin,itimer+allocation+wall,1,NATIVE,0,4000000,4,4,4,256,65536,1000,2.615072,1529595,3,48,722179253,true,true +append-routing-profile,3082b2626256d2d24f508dad0d86fae062ec4bf7,round-robin,itimer+allocation+wall,1,NATIVE,1,4000000,4,4,4,256,65536,1000,2.702224,1480262,3,48,741603490,true,true +append-routing-profile,3082b2626256d2d24f508dad0d86fae062ec4bf7,local-planner-overlay,itimer+allocation+wall,1,NATIVE,-1,4000000,4,4,4,256,65536,1000,3.303149,1210966,3,48,774558780,true,false +append-routing-profile,3082b2626256d2d24f508dad0d86fae062ec4bf7,local-planner-overlay,itimer+allocation+wall,1,NATIVE,0,4000000,4,4,4,256,65536,1000,2.314255,1728418,2,32,774444945,true,false +append-routing-profile,3082b2626256d2d24f508dad0d86fae062ec4bf7,local-planner-overlay,itimer+allocation+wall,1,NATIVE,1,4000000,4,4,4,256,65536,1000,2.226992,1796145,3,48,774562460,true,false +history,743adedcf782be9b721e6186414aa4bf0a7858d2,unmodified,unprofiled,1,NATIVE,-1,4000000,4,4,4,256,65536,1000,3.050710,1311170,2,32,774446204,true,false +history,743adedcf782be9b721e6186414aa4bf0a7858d2,unmodified,unprofiled,1,STOCK,-1,4000000,4,4,4,256,65536,1000,3.612850,1107159,4,64,774334452,false,false +history,743adedcf782be9b721e6186414aa4bf0a7858d2,unmodified,unprofiled,1,STOCK,0,4000000,4,4,4,256,65536,1000,3.372575,1186037,4,64,774333096,false,false +history,743adedcf782be9b721e6186414aa4bf0a7858d2,unmodified,unprofiled,1,NATIVE,0,4000000,4,4,4,256,65536,1000,1.974610,2025716,2,32,774445107,true,false +history,743adedcf782be9b721e6186414aa4bf0a7858d2,unmodified,unprofiled,1,NATIVE,1,4000000,4,4,4,256,65536,1000,1.888127,2118501,2,32,774445710,true,false +history,743adedcf782be9b721e6186414aa4bf0a7858d2,unmodified,unprofiled,1,STOCK,1,4000000,4,4,4,256,65536,1000,3.218132,1242957,4,60,774329310,false,false +history,743adedcf782be9b721e6186414aa4bf0a7858d2,unmodified,unprofiled,1,STOCK,2,4000000,4,4,4,256,65536,1000,3.477690,1150189,4,64,774338493,false,false +history,743adedcf782be9b721e6186414aa4bf0a7858d2,unmodified,unprofiled,1,NATIVE,2,4000000,4,4,4,256,65536,1000,1.917880,2085636,2,32,774443177,true,false +history,1e5d322baea4d8b31a22572693a01ce3ae54cf72,unmodified,unprofiled,1,NATIVE,-1,4000000,4,4,4,256,65536,1000,3.187374,1254952,3,48,774558987,true,false +history,1e5d322baea4d8b31a22572693a01ce3ae54cf72,unmodified,unprofiled,1,STOCK,-1,4000000,4,4,4,256,65536,1000,3.664067,1091683,4,64,774331057,false,false +history,1e5d322baea4d8b31a22572693a01ce3ae54cf72,unmodified,unprofiled,1,STOCK,0,4000000,4,4,4,256,65536,1000,3.129451,1278179,3,48,774308080,false,false +history,1e5d322baea4d8b31a22572693a01ce3ae54cf72,unmodified,unprofiled,1,NATIVE,0,4000000,4,4,4,256,65536,1000,1.911816,2092252,2,32,774446026,true,false +history,1e5d322baea4d8b31a22572693a01ce3ae54cf72,unmodified,unprofiled,1,NATIVE,1,4000000,4,4,4,256,65536,1000,1.882371,2124980,2,32,774445682,true,false +history,1e5d322baea4d8b31a22572693a01ce3ae54cf72,unmodified,unprofiled,1,STOCK,1,4000000,4,4,4,256,65536,1000,3.011914,1328059,4,64,774332435,false,false +history,1e5d322baea4d8b31a22572693a01ce3ae54cf72,unmodified,unprofiled,1,STOCK,2,4000000,4,4,4,256,65536,1000,3.210204,1246027,4,64,774338500,false,false +history,1e5d322baea4d8b31a22572693a01ce3ae54cf72,unmodified,unprofiled,1,NATIVE,2,4000000,4,4,4,256,65536,1000,1.830309,2185424,2,32,774450109,true,false +partition-pressure,1e5d322baea4d8b31a22572693a01ce3ae54cf72,local,unprofiled,1,NATIVE,-1,2000000,4,4,24,256,65536,1000,3.429050,583252,3,328,389053354,true,false +partition-pressure,1e5d322baea4d8b31a22572693a01ce3ae54cf72,local,unprofiled,1,STOCK,-1,2000000,4,4,24,256,65536,1000,2.642701,756801,3,288,387860566,false,false +partition-pressure,1e5d322baea4d8b31a22572693a01ce3ae54cf72,local,unprofiled,1,STOCK,0,2000000,4,4,24,256,65536,1000,2.204805,907110,3,288,387860845,false,false +partition-pressure,1e5d322baea4d8b31a22572693a01ce3ae54cf72,local,unprofiled,1,NATIVE,0,2000000,4,4,24,256,65536,1000,2.042122,979373,2,232,388554839,true,false +partition-pressure,1e5d322baea4d8b31a22572693a01ce3ae54cf72,local,unprofiled,1,NATIVE,1,2000000,4,4,24,256,65536,1000,1.946424,1027525,2,232,388479420,true,false +partition-pressure,1e5d322baea4d8b31a22572693a01ce3ae54cf72,local,unprofiled,1,STOCK,1,2000000,4,4,24,256,65536,1000,1.933556,1034364,2,192,387708610,false,false +partition-pressure,1e5d322baea4d8b31a22572693a01ce3ae54cf72,local,unprofiled,1,STOCK,2,2000000,4,4,24,256,65536,1000,2.031266,984608,2,192,387710103,false,false +partition-pressure,1e5d322baea4d8b31a22572693a01ce3ae54cf72,local,unprofiled,1,NATIVE,2,2000000,4,4,24,256,65536,1000,1.987612,1006232,2,232,388868497,true,false +single-writer,1e5d322baea4d8b31a22572693a01ce3ae54cf72,round-robin,unprofiled,1,NATIVE,-1,4000000,4,1,4,256,65536,1000,4.335454,922625,4,16,774990995,true,true +single-writer,1e5d322baea4d8b31a22572693a01ce3ae54cf72,round-robin,unprofiled,1,NATIVE,0,4000000,4,1,4,256,65536,1000,3.055970,1308914,4,16,774995204,true,true +single-writer,1e5d322baea4d8b31a22572693a01ce3ae54cf72,round-robin,unprofiled,1,NATIVE,1,4000000,4,1,4,256,65536,1000,3.034761,1318061,4,16,774998292,true,true +single-writer,1e5d322baea4d8b31a22572693a01ce3ae54cf72,round-robin,unprofiled,2,NATIVE,-1,4000000,4,1,4,256,65536,1000,4.307636,928584,4,16,774997163,true,true +single-writer,1e5d322baea4d8b31a22572693a01ce3ae54cf72,round-robin,unprofiled,2,NATIVE,0,4000000,4,1,4,256,65536,1000,3.072663,1301803,3,12,774962781,true,true +single-writer,1e5d322baea4d8b31a22572693a01ce3ae54cf72,round-robin,unprofiled,2,NATIVE,1,4000000,4,1,4,256,65536,1000,3.027682,1321143,4,16,774993493,true,true +single-writer,1e5d322baea4d8b31a22572693a01ce3ae54cf72,direct,unprofiled,1,NATIVE,-1,4000000,4,1,4,256,65536,1000,4.447344,899413,4,16,774990604,true,false +single-writer,1e5d322baea4d8b31a22572693a01ce3ae54cf72,direct,unprofiled,1,NATIVE,0,4000000,4,1,4,256,65536,1000,2.987639,1338850,3,12,774965624,true,false +single-writer,1e5d322baea4d8b31a22572693a01ce3ae54cf72,direct,unprofiled,1,NATIVE,1,4000000,4,1,4,256,65536,1000,3.060208,1307101,4,16,774999374,true,false +single-writer,1e5d322baea4d8b31a22572693a01ce3ae54cf72,direct,unprofiled,2,NATIVE,-1,4000000,4,1,4,256,65536,1000,4.287139,933023,4,16,774990484,true,false +single-writer,1e5d322baea4d8b31a22572693a01ce3ae54cf72,direct,unprofiled,2,NATIVE,0,4000000,4,1,4,256,65536,1000,3.001287,1332762,3,12,774976855,true,false +single-writer,1e5d322baea4d8b31a22572693a01ce3ae54cf72,direct,unprofiled,2,NATIVE,1,4000000,4,1,4,256,65536,1000,3.031848,1319327,4,16,774997115,true,false +single-writer-wide,1e5d322baea4d8b31a22572693a01ce3ae54cf72,round-robin,unprofiled,1,NATIVE,-1,2000000,4,1,4,1024,65536,1000,5.433853,368063,5,20,1549044576,true,true +single-writer-wide,1e5d322baea4d8b31a22572693a01ce3ae54cf72,round-robin,unprofiled,1,NATIVE,0,2000000,4,1,4,1024,65536,1000,3.978482,502704,5,20,1549035566,true,true +single-writer-wide,1e5d322baea4d8b31a22572693a01ce3ae54cf72,round-robin,unprofiled,1,NATIVE,1,2000000,4,1,4,1024,65536,1000,4.189147,477424,4,16,1549048811,true,true +single-writer-wide,1e5d322baea4d8b31a22572693a01ce3ae54cf72,direct,unprofiled,1,NATIVE,-1,2000000,4,1,4,1024,65536,1000,5.215427,383478,5,20,1549056840,true,false +single-writer-wide,1e5d322baea4d8b31a22572693a01ce3ae54cf72,direct,unprofiled,1,NATIVE,0,2000000,4,1,4,1024,65536,1000,4.283257,466934,4,16,1549030342,true,false +single-writer-wide,1e5d322baea4d8b31a22572693a01ce3ae54cf72,direct,unprofiled,1,NATIVE,1,2000000,4,1,4,1024,65536,1000,4.148496,482102,4,16,1549034957,true,false +single-writer-profile,1e5d322baea4d8b31a22572693a01ce3ae54cf72,round-robin,itimer+allocation+wall,1,NATIVE,-1,2000000,4,1,4,1024,65536,1000,5.566544,359289,5,20,1549065004,true,true +single-writer-profile,1e5d322baea4d8b31a22572693a01ce3ae54cf72,round-robin,itimer+allocation+wall,1,NATIVE,0,2000000,4,1,4,1024,65536,1000,4.248184,470789,5,20,1549027093,true,true +single-writer-profile,1e5d322baea4d8b31a22572693a01ce3ae54cf72,direct,itimer+allocation+wall,1,NATIVE,-1,2000000,4,1,4,1024,65536,1000,5.443815,367389,5,20,1549076395,true,false +single-writer-profile,1e5d322baea4d8b31a22572693a01ce3ae54cf72,direct,itimer+allocation+wall,1,NATIVE,0,2000000,4,1,4,1024,65536,1000,3.898368,513035,5,20,1549041665,true,false diff --git a/docs/connectors/paimon.md b/docs/connectors/paimon.md index 404262d8b..7bd6e7310 100644 --- a/docs/connectors/paimon.md +++ b/docs/connectors/paimon.md @@ -88,7 +88,8 @@ default before native routing. Shared plan tests compare actual stock/native Job for partitioned/unpartitioned tables, input parallelism 3 or 786, and unchanged/smaller/larger writer counts. Checkpoint recovery tests compare complete committed rows and NULLs with stock and require native Parquet output. See [local append routing](../optimizations/paimon-local-append.md) -for the structural reduction and its measurement limits. +for the job graph and [the complete streaming log-sink benchmark](../benchmarks/paimon-log-sink.md) +for measured throughput and profiles. Continuous tails, periodic watermarks and consumer-retention cursors apply to streaming jobs. Batch reads retain the other source type, format, option and split-level fallbacks below. diff --git a/docs/optimizations/paimon-local-append.md b/docs/optimizations/paimon-local-append.md index 773334fc9..b80d9ce97 100644 --- a/docs/optimizations/paimon-local-append.md +++ b/docs/optimizations/paimon-local-append.md @@ -11,6 +11,11 @@ input parallelism, while the custom shuffle targets the configured writers. Expl dynamic partition strategies, fixed/dynamic buckets and postpone routing keep their separate required exchanges. +The local routing shortcut improved complete-job throughput 1.16× in a four-million-row +streaming SQL benchmark. The benchmark also covers 24 active partitions and a single writer. +See the [streaming Paimon log sink benchmark](../benchmarks/paimon-log-sink.md) for the +profile and matched trials. + ## Structural evidence The plan regression builds stock and native jobs with input parallelism 3 or 786 and a diff --git a/mkdocs.yml b/mkdocs.yml index ca743872e..5398e5726 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -140,6 +140,7 @@ nav: - TPC-H batch workload: benchmarks/tpch.md - TPC-DS Paimon workload: benchmarks/tpcds.md - Bounded Paimon: benchmarks/paimon-batch.md + - Streaming Paimon log sink: benchmarks/paimon-log-sink.md - Paimon byte-backed STRING: benchmarks/paimon-byte-strings.md - Native Criterion suites: benchmarks/native-criterion.md - AppendFast Top-1: benchmarks/append-top1.md diff --git a/streamfusion-paimon/src/benchmark/java/tech/streamfusion/paimon/PaimonLogSinkBenchmark.java b/streamfusion-paimon/src/benchmark/java/tech/streamfusion/paimon/PaimonLogSinkBenchmark.java new file mode 100644 index 000000000..2cc1860db --- /dev/null +++ b/streamfusion-paimon/src/benchmark/java/tech/streamfusion/paimon/PaimonLogSinkBenchmark.java @@ -0,0 +1,285 @@ +package tech.streamfusion.paimon; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.time.Instant; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; +import java.util.Base64; +import java.util.BitSet; +import java.util.Comparator; +import java.util.List; +import java.util.Locale; +import java.util.Random; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import org.apache.flink.api.common.RuntimeExecutionMode; +import org.apache.flink.api.common.typeinfo.Types; +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; +import org.apache.flink.table.api.bridge.java.StreamTableEnvironment; +import org.apache.flink.types.Row; +import org.apache.paimon.format.parquet.ParquetUtil; +import org.apache.paimon.fs.local.LocalFileIO; +import org.apache.paimon.options.Options; +import org.apache.paimon.reader.RecordReaderIterator; +import org.apache.paimon.table.FileStoreTableFactory; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledIfSystemProperty; +import tech.streamfusion.compat.ListCollectors; +import tech.streamfusion.planner.NativePlanner; + +/** Streaming SQL log projection into a write-only, bucket-unaware Paimon table. */ +@EnabledIfSystemProperty(named = "sf.paimon.log.benchmark", matches = "true") +class PaimonLogSinkBenchmark { + private static final int ROWS = Integer.getInteger("sf.paimon.log.rows", 2_000_000); + private static final int PARALLELISM = Integer.getInteger("sf.paimon.log.parallelism", 4); + private static final int WRITERS = Integer.getInteger("sf.paimon.log.writers", PARALLELISM); + private static final int PARTITIONS = Integer.getInteger("sf.paimon.log.partitions", 4); + private static final int PAYLOAD_BYTES = Integer.getInteger("sf.paimon.log.payloadBytes", 256); + private static final int PAYLOAD_VARIANTS = + Integer.getInteger("sf.paimon.log.payloadVariants", 65_536); + private static final int CHECKPOINT_MS = Integer.getInteger("sf.paimon.log.checkpointMs", 1000); + private static final int WARMUP = Integer.getInteger("sf.paimon.log.warmup", 1); + private static final int RUNS = Integer.getInteger("sf.paimon.log.runs", 3); + private static final ZoneId ZONE = ZoneId.of("UTC"); + private static final long BASE = Instant.parse("2026-11-29T23:30:00Z").getEpochSecond(); + private static final DateTimeFormatter PARTITION_FORMAT = + DateTimeFormatter.ofPattern("uuuuMMddHHmm", Locale.ROOT).withZone(ZoneOffset.UTC); + private static final String[] PAYLOADS = payloads(); + private static final String INSERT = + "INSERT INTO p.`default`.logs SELECT CASE WHEN hostname IS NULL OR " + + "CHAR_LENGTH(TRIM(BOTH ' ' FROM hostname)) = 0 OR path IS NULL OR " + + "CHAR_LENGTH(TRIM(BOTH ' ' FROM path)) = 0 THEN content " + + "ELSE CONCAT(hostname, ',', path, ',', content) END, " + + "SUBSTR(timestampvar, 0, 8), SUBSTR(timestampvar, 9, 2), " + + "LPAD(CAST(CAST(SUBSTR(timestampvar, 11, 2) AS INTEGER) / 15 * 15 AS VARCHAR), " + + "2, '0') FROM log_source"; + + private enum Engine { + STOCK, + NATIVE + } + + @Test + void writeAndVerifyCommittedLogs() throws Exception { + assertEquals( + "false", + System.getProperty("streamfusion.exchange.zeroCopyLocal"), + "run with -Pbench to include production Arrow IPC"); + assertTrue(ROWS > 0 && PARTITIONS > 0 && PARALLELISM > 0 && WRITERS > 0 && PAYLOAD_BYTES >= 10); + assertTrue(PAYLOAD_VARIANTS > 0 && CHECKPOINT_MS > 0 && RUNS > 0 && WARMUP >= 0); + String selected = System.getProperty("sf.paimon.log.engine"); + List engines = + selected == null ? List.of(Engine.values()) : List.of(Engine.valueOf(selected)); + String option = "streamfusion.native.enabled"; + String former = System.getProperty(option); + Path scratch = Files.createTempDirectory("paimon-log-sink-"); + try { + for (int trial = -WARMUP; trial < RUNS; trial++) { + for (int i = 0; i < engines.size(); i++) { + int position = Math.floorMod(trial, 2) == 0 ? i : engines.size() - 1 - i; + var engine = engines.get(position); + System.setProperty(option, Boolean.toString(engine == Engine.NATIVE)); + Path output = scratch.resolve(trial + "-" + engine); + try { + run(output, engine, trial); + } finally { + deleteTree(output); + } + } + } + } finally { + if (former == null) System.clearProperty(option); + else System.setProperty(option, former); + deleteTree(scratch); + } + } + + private static void run(Path output, Engine engine, int trial) throws Exception { + var env = StreamExecutionEnvironment.getExecutionEnvironment(); + env.setRuntimeMode(RuntimeExecutionMode.STREAMING); + env.setParallelism(PARALLELISM); + env.enableCheckpointing(CHECKPOINT_MS); + var sql = StreamTableEnvironment.create(env); + sql.getConfig().setLocalTimeZone(ZONE); + sql.createTemporaryView( + "log_rows", + env.fromSequence(0, ROWS - 1) + .map(id -> Row.of(hostname(id), path(id), timestamp(id), payload(id))) + .returns( + Types.ROW_NAMED( + new String[] {"hostname", "path", "log_timestamp", "content"}, + Types.STRING, + Types.STRING, + Types.LONG, + Types.STRING))); + sql.executeSql( + "CREATE TEMPORARY VIEW log_source AS SELECT *, " + + "FROM_UNIXTIME(log_timestamp, 'yyyyMMddHHmm') AS timestampvar FROM log_rows"); + sql.executeSql("CREATE CATALOG p WITH ('type'='paimon', 'warehouse'='" + output.toUri() + "')"); + sql.executeSql( + "CREATE TABLE p.`default`.logs (content VARCHAR, ds VARCHAR, hh VARCHAR, mm VARCHAR) " + + "PARTITIONED BY (ds, hh, mm) WITH ('bucket'='-1', 'file.format'='parquet', " + + "'sink.parallelism'='" + + WRITERS + + "', 'changelog-producer'='none', " + + "'partition.expiration-strategy'='update-time', 'partition.expiration-time'='6h', " + + "'write-only'='true')"); + boolean accelerated = engine == Engine.NATIVE; + var scan = accelerated ? NativePlanner.install(sql) : null; + sql.createStatementSet().addInsertSql(INSERT).attachAsDataStream(); + var graph = env.getStreamGraph(); + var operators = + graph.getStreamNodes().stream() + .map(node -> node.getOperatorName()) + .collect(ListCollectors.toList()); + assertEquals( + accelerated, + operators.stream().anyMatch(name -> name.startsWith("NativeSink(")), + () -> operators + (scan == null ? "" : "\n" + scan.explainSummary())); + boolean nativeCalc = operators.stream().anyMatch(name -> name.startsWith("NativeCalc(")); + assertEquals(accelerated, nativeCalc, operators.toString()); + boolean roundRobin = operators.contains("native-paimon-round-robin-route"); + if (trial == -WARMUP) { + System.out.printf("PAIMON_LOG_PLAN engine=%s operators=%s%n", engine, operators); + if (scan != null) System.out.println(scan.explainSummary()); + } + System.out.printf("PAIMON_LOG_START engine=%s trial=%d%n", engine, trial); + long start = System.nanoTime(); + var job = env.executeAsync(graph); + try { + job.getJobExecutionResult().get(5, TimeUnit.MINUTES); + } catch (TimeoutException timeout) { + try { + job.cancel().get(30, TimeUnit.SECONDS); + } catch (Exception cancellation) { + timeout.addSuppressed(cancellation); + } + throw timeout; + } + double seconds = (System.nanoTime() - start) / 1e9; + System.out.printf( + Locale.ROOT, + "PAIMON_LOG_COMMITTED engine=%s trial=%d seconds=%.6f%n", + engine, + trial, + seconds); + + output = output.resolve("default.db").resolve("logs"); + var io = LocalFileIO.create(); + var table = FileStoreTableFactory.create(io, new org.apache.paimon.fs.Path(output.toUri())); + var read = table.newReadBuilder(); + var splits = read.newScan().plan().splits(); + var seen = new BitSet(ROWS); + String[] partitions = new String[PARTITIONS]; + for (int i = 0; i < PARTITIONS; i++) { + partitions[i] = PARTITION_FORMAT.format(Instant.ofEpochSecond(BASE + i * 900L)); + } + for (var split : splits) { + try (var rows = new RecordReaderIterator<>(read.newRead().createReader(split))) { + while (rows.hasNext()) { + var row = rows.next(); + String content = row.getString(0).toString(); + int idStart = content.lastIndexOf(',') + 1; + int idEnd = content.indexOf(':', idStart); + int id = Integer.parseInt(content.substring(idStart, idEnd)); + assertTrue(id >= 0 && id < ROWS && !seen.get(id), "unexpected or duplicate id " + id); + seen.set(id); + String host = hostname(id); + String path = path(id); + assertEquals( + host == null || host.isBlank() || path == null || path.isBlank() + ? payload(id) + : host + "," + path + "," + payload(id), + content); + String partition = partitions[id % PARTITIONS]; + assertEquals(partition.substring(0, 8), row.getString(1).toString()); + assertEquals(partition.substring(8, 10), row.getString(2).toString()); + assertEquals(partition.substring(10, 12), row.getString(3).toString()); + } + } + } + assertEquals(ROWS, seen.cardinality()); + long files = 0; + long fileBytes = 0; + try (var paths = Files.walk(output)) { + for (Path file : + paths.filter(p -> p.toString().endsWith(".parquet")).collect(ListCollectors.toList())) { + long bytes = Files.size(file); + try (var reader = + ParquetUtil.getParquetReader( + io, new org.apache.paimon.fs.Path(file.toUri()), bytes, new Options())) { + String writer = reader.getFooter().getFileMetaData().getCreatedBy(); + assertEquals(accelerated, writer.contains("parquet-rs"), writer); + } + files++; + fileBytes += bytes; + } + } + assertTrue(files > 0); + System.out.printf( + Locale.ROOT, + "PAIMON_LOG_RESULT engine=%s trial=%d rows=%d parallelism=%d writers=%d partitions=%d" + + " payload_bytes=%d payload_variants=%d checkpoint_ms=%d seconds=%.6f" + + " rows_per_second=%.0f snapshots=%d files=%d bytes=%d native_calc=%s" + + " round_robin=%s%n", + engine, + trial, + ROWS, + PARALLELISM, + WRITERS, + PARTITIONS, + PAYLOAD_BYTES, + PAYLOAD_VARIANTS, + CHECKPOINT_MS, + seconds, + ROWS / seconds, + table.snapshotManager().latestSnapshotId(), + files, + fileBytes, + nativeCalc, + roundRobin); + } + + private static String hostname(long id) { + return id % 13 == 0 ? null : id % 11 == 0 ? " " : "host-" + (id % 16); + } + + private static String path(long id) { + return id % 17 == 0 ? null : id % 19 == 0 ? "" : "/var/log/应用/" + (id % 8); + } + + private static long timestamp(long id) { + return BASE + id % PARTITIONS * 900 + (id / PARTITIONS % 900); + } + + private static String payload(long id) { + String prefix = id + ":"; + return prefix + + PAYLOADS[(int) (id % PAYLOADS.length)].substring(0, PAYLOAD_BYTES - prefix.length()); + } + + private static String[] payloads() { + var random = new Random(42); + var payloads = new String[PAYLOAD_VARIANTS]; + byte[] bytes = new byte[PAYLOAD_BYTES]; + for (int i = 0; i < payloads.length; i++) { + random.nextBytes(bytes); + payloads[i] = Base64.getEncoder().encodeToString(bytes); + } + return payloads; + } + + private static void deleteTree(Path root) throws Exception { + if (Files.notExists(root)) return; + try (var paths = Files.walk(root)) { + for (Path path : paths.sorted(Comparator.reverseOrder()).collect(ListCollectors.toList())) { + Files.delete(path); + } + } + } +} From 74f7722584375c6c3ee819e5b6d8f4d9b3b4ffd7 Mon Sep 17 00:00:00 2001 From: Jordan Epstein Date: Mon, 30 Nov 2026 21:16:10 -0500 Subject: [PATCH 2/3] Remove redundant date formatting and Arrow batch copies Write ordinary numeric FROM_UNIXTIME fields directly and keep timezone addition on the narrow path when it fits. Reuse the input arrays for a single Paimon destination and borrow full ranges at the Parquet writer. Matched release jobs reduced median elapsed time by 7.0% and 3.6% at one and four active partitions. The 24-partition comparison was flat. The prepared date partition Calc fell from 30.43 ms to 19.78 ms with identical output checksums. --- docs/benchmarks/native-sync-calc.md | 8 ++ docs/benchmarks/paimon-log-sink.md | 49 ++++++++++ .../results/paimon-log-sink-followup.csv | 95 +++++++++++++++++++ docs/optimizations/paimon-local-append.md | 4 +- docs/optimizations/scalar-function-kernels.md | 9 +- native/engine/src/bucket_route.rs | 11 +++ .../engine/src/flink_functions/date_format.rs | 2 +- .../src/flink_functions/from_unixtime.rs | 24 ++++- native/parquet/src/files.rs | 9 +- 9 files changed, 201 insertions(+), 10 deletions(-) create mode 100644 docs/benchmarks/results/paimon-log-sink-followup.csv diff --git a/docs/benchmarks/native-sync-calc.md b/docs/benchmarks/native-sync-calc.md index 35cb2c426..27d19c218 100644 --- a/docs/benchmarks/native-sync-calc.md +++ b/docs/benchmarks/native-sync-calc.md @@ -133,6 +133,14 @@ native library, and run the Java driver with `-Dsync.mode=previous -Dsync.discar This mode permits the baseline JVM assignment; it does not change the engine's SQL or evaluation path. Keep each Flink line's compiled target directory separate. +## Direct numeric formatting follow-up + +A release A/B run on the Apple M4 measured the same 131,072-row prepared Calc with +zero passthrough string columns and a varying timestamp. Direct numeric formatting +reduced the native median from 30.43 ms to 19.78 ms (35%). The stock Flink, previous +native, and optimized native runs produced the same checksum. The complete Paimon job +and individual samples are recorded in the [log-sink follow-up](paimon-log-sink.md#removing-redundant-formatting-and-batch-copies). + ## Correctness evidence The JDK 11 regression selection passes on both supported Flink lines: competing failures, diff --git a/docs/benchmarks/paimon-log-sink.md b/docs/benchmarks/paimon-log-sink.md index c5c0e3bee..faf49b1f5 100644 --- a/docs/benchmarks/paimon-log-sink.md +++ b/docs/benchmarks/paimon-log-sink.md @@ -136,3 +136,52 @@ The checked-in runtime uses the existing redistribution when writer parallelism The [structured trial data](results/paimon-log-sink-20261130.csv) include warmups, diagnostics, file counts, and physical sizes alongside the unprofiled measurements. + +## Removing redundant formatting and batch copies + +The follow-up compares the benchmark checkout `7482da583` with three changes inside +the same execution path. `FROM_UNIXTIME` formats ordinary date digits directly and +uses 64-bit offset addition on the common path. The Paimon router shares the source +arrays when it produces a single destination. The Parquet encoder borrows the original +batch when the requested range covers all its rows. Partition assignment, the Arrow +handoff, and the Paimon checkpoint and commit path still run in each job. + +Each app variant uses two JVMs with one warmup and two timed jobs each. Variant order +is baseline, optimized, optimized, baseline. The host uses the same Apple M4, JDK, +six active JVM processors, heap, native release features, and one-second checkpoints +as above. The tests read every committed record through Paimon and check the graph +and Parquet writer. + +| Active partitions | Rows | Baseline median s (range) | Optimized median s (range) | +| ---: | ---: | ---: | ---: | +| 1 | 4,000,000 | 1.788 (1.731–1.926) | 1.662 (1.611–1.693) | +| 4 | 4,000,000 | 1.872 (1.845–1.946) | 1.806 (1.727–1.837) | +| 24 | 2,000,000 | 1.968 (1.848–2.130) | 1.972 (1.810–2.194) | + +Median elapsed time fell **7.0%** for one active partition and **3.6%** for four. +The 24-partition samples overlap. These figures cover all three changes together. +The complete-job results include local storage and periodic and final commits. + +The isolated date-partition Calc uses the same Flink-exported program and prepared +Arrow input for both native binaries. The program contains three `FROM_UNIXTIME` +calls. Over 131,072 rows, the median dropped from **30.43 ms** (29.20–31.24) to +**19.78 ms** (19.48–19.95), a **35%** reduction. Each native variant had 14 timed +trials across two processes. All Calc outputs had the same checksum as the prepared +stock Flink control, whose median was 77.99 ms across five timed trials. + +In separate async-profiler runs with the four-partition fixture, formatter frames +appeared in 138 of 7,550 baseline task CPU samples and 60 of 7,223 optimized samples. +An isolated Arrow allocation count used 1,024 rows, the 256-byte content column, +and the three partition strings. Gathering the full batch requested 21 allocations +and 291,888 bytes. Reusing the arrays requested one 64-byte allocation for the vector +of column references. A whole-batch slice requested five allocations and 608 bytes, +while borrowing the batch requested zero. These counts cover the removed array +operations. The production router and encoder still carry out their other work. + +The 30 focused Flink/Paimon JVM checks and the Rust Parquet range test passed. +The stateless Rust engine test build hits a RocksDB codec error in an unrelated +TopN test module on both revisions. All 10 targeted formatter and routing tests +passed with that test module temporarily excluded from the local build. Timings +used the production release libraries built from the benchmarked source. + +[Follow-up trial data](results/paimon-log-sink-followup.csv) diff --git a/docs/benchmarks/results/paimon-log-sink-followup.csv b/docs/benchmarks/results/paimon-log-sink-followup.csv new file mode 100644 index 000000000..9ee0c1815 --- /dev/null +++ b/docs/benchmarks/results/paimon-log-sink-followup.csv @@ -0,0 +1,95 @@ +component,variant,fork,trial,warmup,seconds,rows,partitions,checksum,snapshots,files,bytes,native_calc,round_robin +prepared-calc,base,1,0,true,0.03130025,131072,,176289882473389012,,,,, +prepared-calc,base,1,1,true,0.029994333,131072,,176289882473389012,,,,, +prepared-calc,base,1,2,true,0.0292825,131072,,176289882473389012,,,,, +prepared-calc,base,1,3,true,0.029672583,131072,,176289882473389012,,,,, +prepared-calc,base,1,4,false,0.029195334,131072,,176289882473389012,,,,, +prepared-calc,base,1,5,false,0.029682708,131072,,176289882473389012,,,,, +prepared-calc,base,1,6,false,0.029396958,131072,,176289882473389012,,,,, +prepared-calc,base,1,7,false,0.029706458,131072,,176289882473389012,,,,, +prepared-calc,base,1,8,false,0.029745417,131072,,176289882473389012,,,,, +prepared-calc,base,1,9,false,0.029723458,131072,,176289882473389012,,,,, +prepared-calc,base,1,10,false,0.031236084,131072,,176289882473389012,,,,, +prepared-calc,base,2,0,true,0.031275042,131072,,176289882473389012,,,,, +prepared-calc,base,2,1,true,0.030794291,131072,,176289882473389012,,,,, +prepared-calc,base,2,2,true,0.030716625,131072,,176289882473389012,,,,, +prepared-calc,base,2,3,true,0.030641417,131072,,176289882473389012,,,,, +prepared-calc,base,2,4,false,0.030781709,131072,,176289882473389012,,,,, +prepared-calc,base,2,5,false,0.030447875,131072,,176289882473389012,,,,, +prepared-calc,base,2,6,false,0.030625458,131072,,176289882473389012,,,,, +prepared-calc,base,2,7,false,0.030539542,131072,,176289882473389012,,,,, +prepared-calc,base,2,8,false,0.03057825,131072,,176289882473389012,,,,, +prepared-calc,base,2,9,false,0.030444666,131072,,176289882473389012,,,,, +prepared-calc,base,2,10,false,0.030423,131072,,176289882473389012,,,,, +prepared-calc,optimized,1,0,true,0.035159791,131072,,176289882473389012,,,,, +prepared-calc,optimized,1,1,true,0.023287791,131072,,176289882473389012,,,,, +prepared-calc,optimized,1,2,true,0.020173625,131072,,176289882473389012,,,,, +prepared-calc,optimized,1,3,true,0.019840458,131072,,176289882473389012,,,,, +prepared-calc,optimized,1,4,false,0.019907959,131072,,176289882473389012,,,,, +prepared-calc,optimized,1,5,false,0.019947917,131072,,176289882473389012,,,,, +prepared-calc,optimized,1,6,false,0.019932208,131072,,176289882473389012,,,,, +prepared-calc,optimized,1,7,false,0.019843917,131072,,176289882473389012,,,,, +prepared-calc,optimized,1,8,false,0.019869125,131072,,176289882473389012,,,,, +prepared-calc,optimized,1,9,false,0.019747125,131072,,176289882473389012,,,,, +prepared-calc,optimized,1,10,false,0.019793333,131072,,176289882473389012,,,,, +prepared-calc,optimized,2,0,true,0.019353084,131072,,176289882473389012,,,,, +prepared-calc,optimized,2,1,true,0.019708666,131072,,176289882473389012,,,,, +prepared-calc,optimized,2,2,true,0.019728834,131072,,176289882473389012,,,,, +prepared-calc,optimized,2,3,true,0.019746,131072,,176289882473389012,,,,, +prepared-calc,optimized,2,4,false,0.019800833,131072,,176289882473389012,,,,, +prepared-calc,optimized,2,5,false,0.0197485,131072,,176289882473389012,,,,, +prepared-calc,optimized,2,6,false,0.019477125,131072,,176289882473389012,,,,, +prepared-calc,optimized,2,7,false,0.019710458,131072,,176289882473389012,,,,, +prepared-calc,optimized,2,8,false,0.019693,131072,,176289882473389012,,,,, +prepared-calc,optimized,2,9,false,0.019678958,131072,,176289882473389012,,,,, +prepared-calc,optimized,2,10,false,0.019763,131072,,176289882473389012,,,,, +prepared-calc,stock,1,0,true,0.135557084,131072,,176289882473389012,,,,, +prepared-calc,stock,1,1,true,0.088016041,131072,,176289882473389012,,,,, +prepared-calc,stock,1,2,true,0.075816167,131072,,176289882473389012,,,,, +prepared-calc,stock,1,3,false,0.082188459,131072,,176289882473389012,,,,, +prepared-calc,stock,1,4,false,0.075023458,131072,,176289882473389012,,,,, +prepared-calc,stock,1,5,false,0.075579541,131072,,176289882473389012,,,,, +prepared-calc,stock,1,6,false,0.082099584,131072,,176289882473389012,,,,, +prepared-calc,stock,1,7,false,0.077990583,131072,,176289882473389012,,,,, +paimon-job,base,1,-1,true,2.929884,4000000,1,,3,12,775395527,true,false +paimon-job,base,1,0,false,1.825551,4000000,1,,2,8,775366549,true,false +paimon-job,base,1,1,false,1.750980,4000000,1,,2,8,775363117,true,false +paimon-job,base,2,-1,true,2.849773,4000000,1,,3,9,775371843,true,false +paimon-job,base,2,0,false,1.926239,4000000,1,,2,8,775365038,true,false +paimon-job,base,2,1,false,1.730507,4000000,1,,2,8,775364867,true,false +paimon-job,base,1,-1,true,2.900811,4000000,4,,3,48,774560319,true,false +paimon-job,base,1,0,false,1.844765,4000000,4,,2,32,774446018,true,false +paimon-job,base,1,1,false,1.880163,4000000,4,,3,48,774559897,true,false +paimon-job,base,2,-1,true,3.001948,4000000,4,,3,48,774561565,true,false +paimon-job,base,2,0,false,1.864513,4000000,4,,2,32,774446733,true,false +paimon-job,base,2,1,false,1.945563,4000000,4,,2,32,774442927,true,false +paimon-job,base,1,-1,true,3.325087,2000000,24,,3,256,388889628,true,false +paimon-job,base,1,0,false,2.130477,2000000,24,,2,232,388816417,true,false +paimon-job,base,1,1,false,2.049271,2000000,24,,2,232,388840316,true,false +paimon-job,base,2,-1,true,3.155834,2000000,24,,3,328,388852606,true,false +paimon-job,base,2,0,false,1.886844,2000000,24,,2,232,388833365,true,false +paimon-job,base,2,1,false,1.847517,2000000,24,,2,232,388680891,true,false +profiled-paimon-job,base,1,-1,true,3.048590,4000000,4,,3,48,774552407,true,false +profiled-paimon-job,base,1,0,false,1.979204,4000000,4,,3,48,774563376,true,false +profiled-paimon-job,base,1,1,false,1.825512,4000000,4,,2,32,774447592,true,false +paimon-job,optimized,1,-1,true,2.659834,4000000,1,,3,12,775409845,true,false +paimon-job,optimized,1,0,false,1.692757,4000000,1,,2,8,775387073,true,false +paimon-job,optimized,1,1,false,1.611005,4000000,1,,2,8,775394286,true,false +paimon-job,optimized,2,-1,true,2.756127,4000000,1,,2,8,775390859,true,false +paimon-job,optimized,2,0,false,1.658041,4000000,1,,3,12,775424935,true,false +paimon-job,optimized,2,1,false,1.666604,4000000,1,,2,8,775363701,true,false +paimon-job,optimized,1,-1,true,2.865130,4000000,4,,3,48,774551726,true,false +paimon-job,optimized,1,0,false,1.836650,4000000,4,,3,48,774484522,true,false +paimon-job,optimized,1,1,false,1.726681,4000000,4,,2,32,774447437,true,false +paimon-job,optimized,2,-1,true,2.785499,4000000,4,,3,48,774477409,true,false +paimon-job,optimized,2,0,false,1.781005,4000000,4,,2,32,774445446,true,false +paimon-job,optimized,2,1,false,1.830562,4000000,4,,3,48,774561970,true,false +paimon-job,optimized,1,-1,true,3.330528,2000000,24,,3,328,389108929,true,false +paimon-job,optimized,1,0,false,2.194176,2000000,24,,2,232,388780928,true,false +paimon-job,optimized,1,1,false,2.012396,2000000,24,,2,232,388856467,true,false +paimon-job,optimized,2,-1,true,3.264545,2000000,24,,2,232,388860571,true,false +paimon-job,optimized,2,0,false,1.930860,2000000,24,,1,136,388182577,true,false +paimon-job,optimized,2,1,false,1.809647,2000000,24,,2,232,388527791,true,false +profiled-paimon-job,optimized,1,-1,true,3.012284,4000000,4,,3,48,774527790,true,false +profiled-paimon-job,optimized,1,0,false,1.920228,4000000,4,,2,32,774444585,true,false +profiled-paimon-job,optimized,1,1,false,1.943726,4000000,4,,3,48,774493388,true,false diff --git a/docs/optimizations/paimon-local-append.md b/docs/optimizations/paimon-local-append.md index b80d9ce97..dea1bbc69 100644 --- a/docs/optimizations/paimon-local-append.md +++ b/docs/optimizations/paimon-local-append.md @@ -4,7 +4,9 @@ Bucket-unaware append tables have no key-to-writer ownership requirement. Releas default append topology writes locally when input and writer parallelism match. StreamFusion preserves that behavior by feeding partition-grouped Arrow batches directly to the native writer. It avoids row/channel reassignment, a custom network edge, and its channel-stripping map. -The native file encoder and Paimon's checkpoint, commit and compaction lifecycle are unchanged. +The bucket router reuses the input's Arrow buffers when all rows route to one destination. +The Parquet encoder borrows a whole input batch directly and slices only partial row ranges. +These shortcuts use the existing Arrow handoff and Paimon writer and checkpoint lifecycle. Changing `sink.parallelism` still uses the row-level round-robin path. Its router inherits the input parallelism, while the custom shuffle targets the configured writers. Explicit hash and diff --git a/docs/optimizations/scalar-function-kernels.md b/docs/optimizations/scalar-function-kernels.md index f1bf3a322..3dd651585 100644 --- a/docs/optimizations/scalar-function-kernels.md +++ b/docs/optimizations/scalar-function-kernels.md @@ -195,7 +195,10 @@ TimeZone at planning time, including its pre-1900 behavior; native execution doe consult a separate tzdb. A batch reuses formatting scratch space and avoids repeating calendar/number formatting for consecutive equal epoch seconds. This removes the scalar JVM callback and its Arrow export/import from the formatting path. Integer calendar arithmetic preserves Java's historical calendar cutover -and overflow range; unsupported formats and zones with recurring future rules keep the Flink evaluator. +and overflow range. The formatter emits two-digit fields and ordinary four-digit years +directly. Wider years use decimal conversion. Offset arithmetic uses 64-bit addition +and widens on overflow. Unsupported formats and zones with recurring future rules use +the Flink evaluator. For the same two-million-row queries with both transposes, two warmups and five measured runs, switching from the previous JVM bridge to native formatting reduced the default-format @@ -211,6 +214,10 @@ median is 5.48x and 7.48x faster than stock respectively, and about 19.6x faster previous whole-Calc JVM path. These are prepared columnar operator measurements, not remote connector or complete-job throughput. +For the 131,072-row prepared date-partition Calc, direct digit output and narrower +offset arithmetic lowered the median from 30.43 ms to 19.78 ms. The matching checksums +and timing boundaries are recorded with the [date-partition Calc benchmark](../benchmarks/native-sync-calc.md#direct-numeric-formatting-follow-up). + ## LOCATE The two-argument form reverses operands into DataFusion strpos. The three-argument Rust kernel follows DataFusion's batch ASCII detection, one reusable memmem::Finder for literal needles, and memmem searches for column needles. Constant needles/starts stay scalar, following Comet's contains pattern. Shared positioning code preserves Flink's empty-needle and signed-start rules; no JVM callback is added. diff --git a/native/engine/src/bucket_route.rs b/native/engine/src/bucket_route.rs index dfc8a7b94..117965591 100644 --- a/native/engine/src/bucket_route.rs +++ b/native/engine/src/bucket_route.rs @@ -56,6 +56,14 @@ fn route_with_buckets( }); groups[group].2.push(row as u32); } + if groups.len() == 1 { + let (partition, bucket, _) = groups.pop().expect("single route"); + return vec![RoutedBatch { + partition, + bucket, + batch: batch.clone(), + }]; + } groups .into_iter() .map(|(partition, bucket, rows)| { @@ -370,6 +378,9 @@ mod tests { assert_eq!(routed[0].partition, vec![0u8; 8], "BinaryRow.EMPTY_ROW"); assert_eq!(routed[0].bucket, 0); assert_eq!(routed[0].batch.num_rows(), batch.num_rows()); + for (input, output) in batch.columns().iter().zip(routed[0].batch.columns()) { + assert!(Arc::ptr_eq(input, output)); + } } #[test] diff --git a/native/engine/src/flink_functions/date_format.rs b/native/engine/src/flink_functions/date_format.rs index 2570eb4a4..c8b41c231 100644 --- a/native/engine/src/flink_functions/date_format.rs +++ b/native/engine/src/flink_functions/date_format.rs @@ -85,7 +85,7 @@ fn compile(pattern: &str) -> Result> { Ok(segments) } -fn push2(output: &mut String, value: u32) { +pub(super) fn push2(output: &mut String, value: u32) { debug_assert!(value < 100); output.push((b'0' + (value / 10) as u8) as char); output.push((b'0' + (value % 10) as u8) as char); diff --git a/native/engine/src/flink_functions/from_unixtime.rs b/native/engine/src/flink_functions/from_unixtime.rs index cb70f5368..3b4bfeba1 100644 --- a/native/engine/src/flink_functions/from_unixtime.rs +++ b/native/engine/src/flink_functions/from_unixtime.rs @@ -1,12 +1,12 @@ //! Constant numeric SimpleDateFormat patterns with JDK-provided finite offset histories. +use super::date_format::push2; use arrow::array::{ArrayRef, Int64Array, StringBuilder}; use arrow::datatypes::DataType; use datafusion::common::{exec_err, Result}; use datafusion::logical_expr::{ ColumnarValue, ScalarFunctionArgs, ScalarUDF, ScalarUDFImpl, Signature, Volatility, }; -use std::fmt::Write; use std::sync::Arc; pub(crate) fn function(offset_millis: i64, pattern: &str) -> Result { @@ -128,9 +128,16 @@ impl FromUnixTime { } else { self.transitions[index - 1].1 }; - let local = i128::from(millis) + i128::from(offset); - let days = local.div_euclid(86_400_000) as i64; - let time = local.rem_euclid(86_400_000) as i64; + let (days, time) = match millis.checked_add(offset) { + Some(local) => (local.div_euclid(86_400_000), local.rem_euclid(86_400_000)), + None => { + let local = i128::from(millis) + i128::from(offset); + ( + local.div_euclid(86_400_000) as i64, + local.rem_euclid(86_400_000) as i64, + ) + } + }; let (year, month, day) = calendar_date(days); for token in &self.tokens { match token { @@ -151,7 +158,14 @@ impl FromUnixTime { 's' => time / 1000 % 60, _ => unreachable!("compiled numeric field"), }; - write!(output, "{value:0width$}").unwrap(); + if *width == 2 { + push2(output, value as u32); + } else if value <= 9999 { + push2(output, value as u32 / 100); + push2(output, value as u32 % 100); + } else { + output.push_str(itoa::Buffer::new().format(value)); + } } } } diff --git a/native/parquet/src/files.rs b/native/parquet/src/files.rs index dd087e5f5..db6ba4b27 100644 --- a/native/parquet/src/files.rs +++ b/native/parquet/src/files.rs @@ -1080,7 +1080,11 @@ impl ParquetEncoder { row_offset + count <= batch.num_rows(), "Parquet row range exceeded the Arrow batch" ); - self.write(&batch.slice(row_offset, count)); + if row_offset == 0 && count == batch.num_rows() { + self.write(batch); + } else { + self.write(&batch.slice(row_offset, count)); + } } fn estimated_bytes(&self) -> usize { @@ -1585,6 +1589,7 @@ mod parquet_encoder_tests { let mut encoder = ParquetEncoder::new(output.clone(), schema, &[], &[], &[], false); encoder.write_selected_range(&batch, &[], 1, Some(2)); + encoder.write_selected_range(&batch, &[], 0, None); assert!(encoder.estimated_bytes() > 0); encoder.finish(); @@ -1603,7 +1608,7 @@ mod parquet_encoder_tests { .as_any() .downcast_ref::() .unwrap(); - assert_eq!(values.values(), &[20, 30]); + assert_eq!(values.values(), &[20, 30, 10, 20, 30, 40]); } #[test] From 248f593eae565519bfc9c2113c35ffe8db5ad26d Mon Sep 17 00:00:00 2001 From: Jordan Epstein Date: Mon, 30 Nov 2026 23:44:44 -0500 Subject: [PATCH 3/3] Preserve Paimon routed batch ownership Keep routing materialized across the Java allocator boundary. Retain the formatter and Parquet range improvements, and document exact readback controls on the released Paimon path. --- docs/benchmarks/paimon-log-sink.md | 49 +++++++------------ .../results/paimon-log-sink-followup.csv | 42 ---------------- docs/optimizations/paimon-local-append.md | 2 - native/engine/src/bucket_route.rs | 11 ----- .../paimon/PaimonLogSinkBenchmark.java | 2 +- 5 files changed, 18 insertions(+), 88 deletions(-) diff --git a/docs/benchmarks/paimon-log-sink.md b/docs/benchmarks/paimon-log-sink.md index faf49b1f5..7a051fc4f 100644 --- a/docs/benchmarks/paimon-log-sink.md +++ b/docs/benchmarks/paimon-log-sink.md @@ -139,28 +139,9 @@ diagnostics, file counts, and physical sizes alongside the unprofiled measuremen ## Removing redundant formatting and batch copies -The follow-up compares the benchmark checkout `7482da583` with three changes inside -the same execution path. `FROM_UNIXTIME` formats ordinary date digits directly and -uses 64-bit offset addition on the common path. The Paimon router shares the source -arrays when it produces a single destination. The Parquet encoder borrows the original -batch when the requested range covers all its rows. Partition assignment, the Arrow -handoff, and the Paimon checkpoint and commit path still run in each job. - -Each app variant uses two JVMs with one warmup and two timed jobs each. Variant order -is baseline, optimized, optimized, baseline. The host uses the same Apple M4, JDK, -six active JVM processors, heap, native release features, and one-second checkpoints -as above. The tests read every committed record through Paimon and check the graph -and Parquet writer. - -| Active partitions | Rows | Baseline median s (range) | Optimized median s (range) | -| ---: | ---: | ---: | ---: | -| 1 | 4,000,000 | 1.788 (1.731–1.926) | 1.662 (1.611–1.693) | -| 4 | 4,000,000 | 1.872 (1.845–1.946) | 1.806 (1.727–1.837) | -| 24 | 2,000,000 | 1.968 (1.848–2.130) | 1.972 (1.810–2.194) | - -Median elapsed time fell **7.0%** for one active partition and **3.6%** for four. -The 24-partition samples overlap. These figures cover all three changes together. -The complete-job results include local storage and periodic and final commits. +The follow-up reduces work in two places. `FROM_UNIXTIME` formats ordinary date digits +directly and uses 64-bit offset addition on the common path. The Parquet encoder borrows +the original batch when the requested range covers all its rows. The isolated date-partition Calc uses the same Flink-exported program and prepared Arrow input for both native binaries. The program contains three `FROM_UNIXTIME` @@ -169,19 +150,23 @@ calls. Over 131,072 rows, the median dropped from **30.43 ms** (29.20–31.24) t trials across two processes. All Calc outputs had the same checksum as the prepared stock Flink control, whose median was 77.99 ms across five timed trials. -In separate async-profiler runs with the four-partition fixture, formatter frames -appeared in 138 of 7,550 baseline task CPU samples and 60 of 7,223 optimized samples. An isolated Arrow allocation count used 1,024 rows, the 256-byte content column, -and the three partition strings. Gathering the full batch requested 21 allocations -and 291,888 bytes. Reusing the arrays requested one 64-byte allocation for the vector -of column references. A whole-batch slice requested five allocations and 608 bytes, -while borrowing the batch requested zero. These counts cover the removed array -operations. The production router and encoder still carry out their other work. - -The 30 focused Flink/Paimon JVM checks and the Rust Parquet range test passed. +and the three partition strings. A whole-batch slice requested five allocations +and 608 bytes. Borrowing the batch requested zero. These counts cover the removed +array operation. + +In the final four-writer check with four active partitions and one-second checkpoints, +one upstream `a11ca1203` trial read back 3,994,304 of 4,000,000 rows. The next three +upstream native jobs, three stock Flink jobs, and three jobs with both changes passed +exact readback. The readback discrepancy remains unexplained. The follow-up's speed +measurement is the isolated Calc result above. + +The corrected build passed 18 focused Flink 1.18 checks and 46 Flink 2.2 checks, +including dynamic partition routing, append checkpoint recovery, and Parquet writer +parity. The Rust Parquet range test passed. The stateless Rust engine test build hits a RocksDB codec error in an unrelated TopN test module on both revisions. All 10 targeted formatter and routing tests passed with that test module temporarily excluded from the local build. Timings used the production release libraries built from the benchmarked source. -[Follow-up trial data](results/paimon-log-sink-followup.csv) +[Prepared Calc trial data](results/paimon-log-sink-followup.csv) diff --git a/docs/benchmarks/results/paimon-log-sink-followup.csv b/docs/benchmarks/results/paimon-log-sink-followup.csv index 9ee0c1815..4f95ef564 100644 --- a/docs/benchmarks/results/paimon-log-sink-followup.csv +++ b/docs/benchmarks/results/paimon-log-sink-followup.csv @@ -51,45 +51,3 @@ prepared-calc,stock,1,4,false,0.075023458,131072,,176289882473389012,,,,, prepared-calc,stock,1,5,false,0.075579541,131072,,176289882473389012,,,,, prepared-calc,stock,1,6,false,0.082099584,131072,,176289882473389012,,,,, prepared-calc,stock,1,7,false,0.077990583,131072,,176289882473389012,,,,, -paimon-job,base,1,-1,true,2.929884,4000000,1,,3,12,775395527,true,false -paimon-job,base,1,0,false,1.825551,4000000,1,,2,8,775366549,true,false -paimon-job,base,1,1,false,1.750980,4000000,1,,2,8,775363117,true,false -paimon-job,base,2,-1,true,2.849773,4000000,1,,3,9,775371843,true,false -paimon-job,base,2,0,false,1.926239,4000000,1,,2,8,775365038,true,false -paimon-job,base,2,1,false,1.730507,4000000,1,,2,8,775364867,true,false -paimon-job,base,1,-1,true,2.900811,4000000,4,,3,48,774560319,true,false -paimon-job,base,1,0,false,1.844765,4000000,4,,2,32,774446018,true,false -paimon-job,base,1,1,false,1.880163,4000000,4,,3,48,774559897,true,false -paimon-job,base,2,-1,true,3.001948,4000000,4,,3,48,774561565,true,false -paimon-job,base,2,0,false,1.864513,4000000,4,,2,32,774446733,true,false -paimon-job,base,2,1,false,1.945563,4000000,4,,2,32,774442927,true,false -paimon-job,base,1,-1,true,3.325087,2000000,24,,3,256,388889628,true,false -paimon-job,base,1,0,false,2.130477,2000000,24,,2,232,388816417,true,false -paimon-job,base,1,1,false,2.049271,2000000,24,,2,232,388840316,true,false -paimon-job,base,2,-1,true,3.155834,2000000,24,,3,328,388852606,true,false -paimon-job,base,2,0,false,1.886844,2000000,24,,2,232,388833365,true,false -paimon-job,base,2,1,false,1.847517,2000000,24,,2,232,388680891,true,false -profiled-paimon-job,base,1,-1,true,3.048590,4000000,4,,3,48,774552407,true,false -profiled-paimon-job,base,1,0,false,1.979204,4000000,4,,3,48,774563376,true,false -profiled-paimon-job,base,1,1,false,1.825512,4000000,4,,2,32,774447592,true,false -paimon-job,optimized,1,-1,true,2.659834,4000000,1,,3,12,775409845,true,false -paimon-job,optimized,1,0,false,1.692757,4000000,1,,2,8,775387073,true,false -paimon-job,optimized,1,1,false,1.611005,4000000,1,,2,8,775394286,true,false -paimon-job,optimized,2,-1,true,2.756127,4000000,1,,2,8,775390859,true,false -paimon-job,optimized,2,0,false,1.658041,4000000,1,,3,12,775424935,true,false -paimon-job,optimized,2,1,false,1.666604,4000000,1,,2,8,775363701,true,false -paimon-job,optimized,1,-1,true,2.865130,4000000,4,,3,48,774551726,true,false -paimon-job,optimized,1,0,false,1.836650,4000000,4,,3,48,774484522,true,false -paimon-job,optimized,1,1,false,1.726681,4000000,4,,2,32,774447437,true,false -paimon-job,optimized,2,-1,true,2.785499,4000000,4,,3,48,774477409,true,false -paimon-job,optimized,2,0,false,1.781005,4000000,4,,2,32,774445446,true,false -paimon-job,optimized,2,1,false,1.830562,4000000,4,,3,48,774561970,true,false -paimon-job,optimized,1,-1,true,3.330528,2000000,24,,3,328,389108929,true,false -paimon-job,optimized,1,0,false,2.194176,2000000,24,,2,232,388780928,true,false -paimon-job,optimized,1,1,false,2.012396,2000000,24,,2,232,388856467,true,false -paimon-job,optimized,2,-1,true,3.264545,2000000,24,,2,232,388860571,true,false -paimon-job,optimized,2,0,false,1.930860,2000000,24,,1,136,388182577,true,false -paimon-job,optimized,2,1,false,1.809647,2000000,24,,2,232,388527791,true,false -profiled-paimon-job,optimized,1,-1,true,3.012284,4000000,4,,3,48,774527790,true,false -profiled-paimon-job,optimized,1,0,false,1.920228,4000000,4,,2,32,774444585,true,false -profiled-paimon-job,optimized,1,1,false,1.943726,4000000,4,,3,48,774493388,true,false diff --git a/docs/optimizations/paimon-local-append.md b/docs/optimizations/paimon-local-append.md index dea1bbc69..0445e771f 100644 --- a/docs/optimizations/paimon-local-append.md +++ b/docs/optimizations/paimon-local-append.md @@ -4,9 +4,7 @@ Bucket-unaware append tables have no key-to-writer ownership requirement. Releas default append topology writes locally when input and writer parallelism match. StreamFusion preserves that behavior by feeding partition-grouped Arrow batches directly to the native writer. It avoids row/channel reassignment, a custom network edge, and its channel-stripping map. -The bucket router reuses the input's Arrow buffers when all rows route to one destination. The Parquet encoder borrows a whole input batch directly and slices only partial row ranges. -These shortcuts use the existing Arrow handoff and Paimon writer and checkpoint lifecycle. Changing `sink.parallelism` still uses the row-level round-robin path. Its router inherits the input parallelism, while the custom shuffle targets the configured writers. Explicit hash and diff --git a/native/engine/src/bucket_route.rs b/native/engine/src/bucket_route.rs index 117965591..dfc8a7b94 100644 --- a/native/engine/src/bucket_route.rs +++ b/native/engine/src/bucket_route.rs @@ -56,14 +56,6 @@ fn route_with_buckets( }); groups[group].2.push(row as u32); } - if groups.len() == 1 { - let (partition, bucket, _) = groups.pop().expect("single route"); - return vec![RoutedBatch { - partition, - bucket, - batch: batch.clone(), - }]; - } groups .into_iter() .map(|(partition, bucket, rows)| { @@ -378,9 +370,6 @@ mod tests { assert_eq!(routed[0].partition, vec![0u8; 8], "BinaryRow.EMPTY_ROW"); assert_eq!(routed[0].bucket, 0); assert_eq!(routed[0].batch.num_rows(), batch.num_rows()); - for (input, output) in batch.columns().iter().zip(routed[0].batch.columns()) { - assert!(Arc::ptr_eq(input, output)); - } } #[test] diff --git a/streamfusion-paimon/src/benchmark/java/tech/streamfusion/paimon/PaimonLogSinkBenchmark.java b/streamfusion-paimon/src/benchmark/java/tech/streamfusion/paimon/PaimonLogSinkBenchmark.java index 2cc1860db..3dfe2900e 100644 --- a/streamfusion-paimon/src/benchmark/java/tech/streamfusion/paimon/PaimonLogSinkBenchmark.java +++ b/streamfusion-paimon/src/benchmark/java/tech/streamfusion/paimon/PaimonLogSinkBenchmark.java @@ -203,7 +203,7 @@ private static void run(Path output, Engine engine, int trial) throws Exception } } } - assertEquals(ROWS, seen.cardinality()); + assertEquals(ROWS, seen.cardinality(), () -> "first missing input ID " + seen.nextClearBit(0)); long files = 0; long fileBytes = 0; try (var paths = Files.walk(output)) {