[
https://issues.apache.org/jira/browse/FLINK-24815?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17447466#comment-17447466
]
Piotr Nowojski edited comment on FLINK-24815 at 11/22/21, 3:13 PM:
-------------------------------------------------------------------
I think you are right. It looks like the {{getStateSize()}} is used only for
pretty printing or during snapshotting for metrics/logging/webUI.
Anyway, I don't like the idea of passing an invalid number. An easy change
would be to calculate the state size lazily on demand only, but that would also
be not very nice - it would be misleading for the {{getStateSize()}} method to
actually be doing some intensive computations.
[~Ming Li], how important is this optimisation in the use case that you have in
mind? How long does it take to calculate the state size during recovery?
[~yunta]/[~roman], do you have any thoughts on this one?
was (Author: pnowojski):
I think you are right. It looks like the {{getStateSize()}} is used only for
pretty printing or during snapshotting for metrics/logging/webUI.
Anyway, I don't like the idea of passing an invalid number. An easy change
would be to calculate the state size lazily on demand only, but that would also
be not very nice - it would be misleading for the {{getStateSize()}} method to
actually be doing some intensive computations.
[~yunta]/[~roman], do you have any thoughts on this one?
> Reduce the cpu cost of calculating stateSize during state allocation
> --------------------------------------------------------------------
>
> Key: FLINK-24815
> URL: https://issues.apache.org/jira/browse/FLINK-24815
> Project: Flink
> Issue Type: Improvement
> Components: Runtime / Checkpointing, Runtime / State Backends
> Affects Versions: 1.14.0
> Reporter: ming li
> Priority: Major
>
> When the task failover, we will reassign the state for each subtask and
> create a new {{OperatorSubtaskState}} object. At this time, the {{stateSize}}
> field in the {{OperatorSubtaskState}} will be recalculated. When using
> incremental {{{}Checkpoint{}}}, this field needs to traverse all shared
> states and then accumulate the size of the state.
> Taking a job with 2000 parallelism and 100 share state for each task as an
> example, it needs to traverse 2000 * 100 = 20w times. At this time, the cpu
> of the JM scheduling thread will be full.
> I think we can try to provide a construction method with {{stateSize}} for
> {{OperatorSubtaskState}} or delay the calculation of {{{}stateSize{}}}.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)