[ 
https://issues.apache.org/jira/browse/FLINK-9107?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16423682#comment-16423682
 ] 

ASF GitHub Bot commented on FLINK-9107:
---------------------------------------

Github user aljoscha commented on a diff in the pull request:

    https://github.com/apache/flink/pull/5790#discussion_r178754487
  
    --- Diff: docs/dev/stream/operators/process_function.md ---
    @@ -269,4 +269,38 @@ override def onTimer(timestamp: Long, ctx: 
OnTimerContext, out: Collector[OUT]):
     }
     {% endhighlight %}
     </div>
    -</div>
    \ No newline at end of file
    +</div>
    +
    +## Optimisations
    +
    +### Timer Coalescing
    +
    +Every timer registered at the `TimerService` via 
`ctx.timerService().registerEventTimeTimer()` will
    +be stored on heap and enqueued for execution. There is, however, a maximum 
of one timer per key and
    +timestamp at a millisecond resolution and thus, in the worst case, every 
key may have a timer for
    +each upcoming millisecond. Even if you do not do any processing for 
outdated timers in `onTimer`
    +(as above), this may put a significant burden on the Flink runtime.
    +
    +Since there is only one timer per key and timestamp, however, you may 
coalesc timers by reducing the
    --- End diff --
    
    typo: coalesc -> coalesce


> Document timer coalescing for ProcessFunctions
> ----------------------------------------------
>
>                 Key: FLINK-9107
>                 URL: https://issues.apache.org/jira/browse/FLINK-9107
>             Project: Flink
>          Issue Type: Improvement
>          Components: Documentation, Streaming
>    Affects Versions: 1.3.0, 1.4.0, 1.5.0, 1.6.0
>            Reporter: Nico Kruber
>            Assignee: Nico Kruber
>            Priority: Major
>             Fix For: 1.5.0, 1.4.3, 1.3.4
>
>
> In a {{ProcessFunction}}, registering timers for each event via 
> {{ctx.timerService().registerEventTimeTimer()}} using times like 
> {{ctx.timestamp() + timeout}} will get a millisecond accuracy and may thus 
> create one timer per millisecond which may lead to some overhead in the 
> {{TimerService}}.
> This problem can be mitigated by using timer coalescing if the desired 
> accuracy of the timer can be larger than 1ms. A timer firing at full seconds 
> only, for example, can be realised like this:
> {code}
> coalescedTime = ((ctx.timestamp() + timeout) / 1000) * 1000;
> ctx.timerService().registerEventTimeTimer(coalescedTime);
> {code}
> As a result, only a single timer may exist for every second since we do not 
> add timers for timestamps that are already there.
> This should be documented in the {{ProcessFunction}} docs.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to