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

   <!--
   
   Thank you for contributing to SeaTunnel! Please make sure that your code 
changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   ## Contribution Checklist
     - Make sure that the pull request corresponds to a GITHUB issue.
     - Name the pull request in the form "[Feature] [component] Title of the 
pull request".
   -->
   
   ### Purpose of this pull request
   
   This SeaTunnel change reduces retained-history transfer during job-count 
collection for `/metrics`, `/openmetrics` and coordinator diagnostic logging.
   
   Related to #12123; implements the remaining scrape-path work described in 
https://github.com/apache/seatunnel/issues/12123#issuecomment-5554351184. The 
listing optimization in #12130 is unchanged.
   
   - Aggregate retained statuses on their owning Hazelcast members instead of 
fetching full `JobState` records onto the coordinator.
   - Merge the existing running/pending snapshots, preserving status fallback, 
retained-attempt exclusion and overlap behavior.
   - Preserve the nine exported counters, history TTL, listing results and 
failure propagation. No cached counters or write-side state are added.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No functional/API change. Metrics names, labels, configuration, retention 
and stored formats remain unchanged; no migration is required. Counts remain 
weakly consistent.
   
   Previously, each count fetched retained records, including task/pipeline 
details and diagnostics. This patch returns aggregated statuses instead. It 
still scans and deserializes retained records on members; it does not make 
counting constant-time. The UI overview uses a separate path and is unchanged.
   
   **Trade-offs:** empty/very small histories have extra fixed aggregation 
overhead. The active-ID exclusion set is serialized in requests and responses, 
so traffic grows with active jobs and member count.
   
   ### How was this patch tested?
   
   Validation with Java 11.0.32.1 and Maven 3.9.16:
   
   ```sh
   mvn -B -pl seatunnel-engine/seatunnel-engine-server -am \
     -DskipTests -Dskip.ui=true -Dlicense.skipAddThirdParty=true install
   
   mvn -B -pl seatunnel-engine/seatunnel-engine-server \
     
-Dtest=JobHistoryServiceJobCountTest,JobHistoryServiceTest,TelemetryCollectorCoordinatorGuardTest,EngineStateStoreMetricExportsTest,EngineStateStoreLogicalMetricExportsTest,RestApiHttpsTest
 \
     -Dskip.ui=true verify
   ```
   
   - Scoped dependency-reactor build and formatting verification passed.
   - 38 tests passed, with no failures, errors or skips.
   - Added three-member tests for every status, remote partitions, 
active/pending precedence and overlap, retained attempts, unchanged stored 
records, empty/uninitialized counts, TTL under repeated reads, member 
loss/rejoin after convergence and query failure propagation.
   - Extended the existing real-engine history test to compare finished-job 
listing and count results.
   - Adjacent telemetry guards, metrics exports and REST/HTTPS tests pass.
   
   #### Local measurements
   
   A standalone probe called the production count method with a real history 
service and distributed maps, using three separate Hazelcast 5.1 JVMs, native 
Java 11, loopback TCP, 512 MiB heaps, BINARY maps and one backup. Retained 
states contain two pipelines with 16 task entries each.
   
   Fixture construction and expected-count checks are outside timing. 
Allocation covers live JVM threads across all members; invalid allocation 
samples are excluded, with timing samples retained.
   
   - Baseline: `886eb632fd278683bf4dc989d848ee4d14252b82`.
   - Published candidate: `7057a96a5c0c85a2b7fe9bd202515d7e62816344`, based on 
`d676f91b3d6aaa2cca693816697a211e4d384805`.
   
   The measurements used this five-file source patch before rebasing onto the 
3.1.0 version bump. All five affected files are unchanged by the rebase; these 
are not measurements of the rebased packaging.
   
   With **10,000 retained jobs and 128 active jobs**, two fresh 
baseline/candidate pairs, reversed execution order, at least five seconds of 
warm-up and six blocks per fork produced these medians per count:
   
   - Latency: **232.0 → 142.9 ms** — 38% lower.
   - Coordinator allocation: **260.2 → 78.6 MiB** — 70% lower.
   - Total cluster allocation: **307.8 → 231.8 MiB** — 25% lower.
   - Cluster CPU: **315.0 → 250.3 ms**.
   - Cluster TCP bytes sent: **14.84 MiB → 20.57 KiB**.
   
   Benefit held in both pairs: fork latency medians were **230.9 → 141.0 ms** 
and **256.2 → 149.0 ms**. At 1,000 retained jobs with the same active-job 
controls, median latency was **39.5 → 31.0 ms**.
   
   A separate three-pair series without active jobs showed **196.1 → 129.9 ms** 
at 10,000 retained jobs. Its small-history results show the fixed overhead:
   
   - Empty history: **1.24 → 2.00 ms**.
   - Ten retained records: **1.81 → 2.61 ms**.
   
   That shorter-warmup series also showed increased cluster CPU at 1,000 
records (**33.9 → 60.1 ms**); no uniform CPU improvement is claimed. An earlier 
active-job series had noisy 1,000-record latency (**44.5 → 60.9 ms**), which 
prompted the controlled warm-up and ownership reruns above.
   
   #### Pending validation and limitations
   
   - These are local production-method probes with injected 
coordinator/active-job dependencies, not full HTTP scrapes, end-to-end 
throughput measurements or production workload results.
   - The probe harness/raw results are not included in this patch. Shared 
benchmark integration and the hosted `Benchmarks` comparison described in the 
performance contribution guide remain pending before optimization submission.
   - Hosted CI remains pending.
   - Member-loss tests check counts after cluster convergence; in-flight 
scrape/coordinator failover is not established.
   - Nondefault parallel query evaluation and larger active-job/cluster scales 
were not measured. Parallel evaluation can clone the active-ID set per 
partition.
   
   ### Check list
   
   * [ ] If any new Jar binary package adding in your PR, please add License 
Notice according
     [New License 
Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/developer/new-license.md)
   * [ ] If necessary, please update the documentation to describe the new 
feature. https://github.com/apache/seatunnel/tree/dev/docs
   * [ ] If necessary, please update `incompatible-changes.md` to describe the 
incompatibility caused by this PR.
   * [ ] If you are contributing the connector code, please check that the 
following files are updated:
     1. Update 
[plugin-mapping.properties](https://github.com/apache/seatunnel/blob/dev/plugin-mapping.properties)
 and add new connector information in it
     2. Update the pom file of 
[seatunnel-dist](https://github.com/apache/seatunnel/blob/dev/seatunnel-dist/pom.xml)
     3. Add ci label in 
[label-scope-conf](https://github.com/apache/seatunnel/blob/dev/.github/workflows/labeler/label-scope-conf.yml)
     4. Add e2e testcase in 
[seatunnel-e2e](https://github.com/apache/seatunnel/tree/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/)
     5. Update connector 
[plugin_config](https://github.com/apache/seatunnel/blob/dev/config/plugin_config)
   
   Checklist applicability: no new binary packages, connector changes, 
configuration or incompatible behavior. No documentation migration is required.


-- 
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