[Improve][Zeta] Improve job metrics handling with partitioning support#9833
Conversation
|
I was planning to document this new configuration option, but I couldn't find the relevant section for master server config options. Could you please point me to where this should be documented? @Hisoka-X |
|
I am not yet very experienced with performance metrics, so I did not include specific measurements in this PR. However, I can provide benchmarks or metrics if needed—please let me know if you’d like to see them. |
|
By the way, is there a solution for the current issue of runningJobMetrics growing indefinitely? When synchronizing tasks involving several thousand tables, the WAL persisted in OSS frequently reaches hundreds of GB. |
|
Hi @qiaoborui , Thanks for raising this important point! My understanding is that the root cause is With this PR, since metrics are partitioned, lock contention should be significantly reduced, so I’ll keep monitoring this behavior, and if you have further feedback or see this problem persist, please let me know! |
|
Can we provide a best practice to guide customers in configuration, such as recommended calculation formulas |
@qiaoborui We almost fix it in #9696 and #9776. This PR is only to address potential risks in extreme scenarios. |
@zhangshenghang |
@dybyte Thanks, you can include it in the document for reference by others. This makes it more convenient for users to use. |
|
@zhangshenghang Thanks, I've added it to the documentation for everyone’s reference. |
Thank you for pointing this out. I've been keeping an eye on this issue recently as well. However, I previously reviewed these two PRs and noticed that the memory leaks addressed were related to |
| for (Map.Entry<Long, Map<TaskLocation, SeaTunnelMetricsContext>> entry : | ||
| metricsImap.entrySet()) { | ||
| long partition = entry.getKey(); | ||
| List<TaskLocation> tasksToRemove = | ||
| entry.getValue().keySet().stream() | ||
| .filter( | ||
| t -> | ||
| t.getTaskGroupLocation() | ||
| .getPipelineLocation() | ||
| .equals(pipelineLocation)) | ||
| .collect(Collectors.toList()); | ||
| if (!tasksToRemove.isEmpty()) { | ||
| partitionedTasks.put(partition, tasksToRemove); | ||
| } | ||
| } | ||
|
|
||
| List<TaskLocation> taskLocations = getTaskLocations(pipelineLocation, centralMap); | ||
| taskLocations.forEach(centralMap::remove); | ||
| metricsImap.put(Constant.IMAP_RUNNING_JOB_METRICS_KEY, centralMap); | ||
| partitionedTasks | ||
| .entrySet() | ||
| .parallelStream() | ||
| .forEach( |
There was a problem hiding this comment.
Why foreach metricsImap twice? Can we use only once?
There was a problem hiding this comment.
I intentionally separated the logic into two iterations.
The first pass filters tasks outside of metricsImap to minimize the time holding its internal resources,
and the second pass performs only the minimal compute operations inside the metricsImap.
Since write operations are frequent, I believe this approach can help reduce contention.
I’d be happy to adjust the implementation if you feel a single iteration would be more appropriate.
There was a problem hiding this comment.
We are a bit limited by imap, maybe we should switch to rocksdb in the future. #9851
Fixes #9817
Purpose of this pull request
This PR introduces a new configuration option
JOB_METRICS_PARTITION_COUNTwhich controls the number of partitions used to store running job metrics in Hazelcast IMap. This allows distributing metrics across multiple keys to reduce contention and improve performance when multiple tasks report metrics concurrently.If you prefer to use a single key for storing metrics, set
JOB_METRICS_PARTITION_COUNTto1(this is the default, so no configuration is required).For better parallelism under high load, you can increase this value.
However, setting it too high may introduce overhead when aggregating metrics across multiple partitions, which can lead to reduced overall performance.
Does this PR introduce any user-facing change?
Yes. Users can tune
JOB_METRICS_PARTITION_COUNTto balance write contention and aggregation overhead. Default is 1 for backward compatibility.How was this patch tested?
Current tests verify that
metricsImapis updated and cleared with a custom partition configuration.Performance comparison of
updateMetrics:Using multiple partitions significantly reduces lock contention, improving the performance of the
updateMetricsmethod. This demonstrates that the multi-key approach performs better than the single-key approach under high concurrency (in a local test).Check list
New License Guide