Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-23890

CepOperator may create a large number of timers and cause performance problems

    XMLWordPrintableJSON

Details

    Description

       There are two situations in the CepOperator that may register the time when dealing with EventTime.
      when the processElement will buffer the data first, and then register a timer with a timestamp of watermark+1.

      if (timestamp > timerService.currentWatermark()) {
       // we have an event with a valid timestamp, so
       // we buffer it until we receive the proper watermark.
       saveRegisterWatermarkTimer();
       bufferEvent(value, timestamp);
      }

      The other is when the EventTimer is triggered, if sortedTimestamps or partialMatches are not empty, a timer will also be registered.

      if (!sortedTimestamps.isEmpty() || !partialMatches.isEmpty()) {
       saveRegisterWatermarkTimer();
      }

       
      The problem is, if the partialMatches corresponding to each of my keys are not empty. Then every time the watermark advances, the timers of all keys will be triggered, and then a new EventTimer is re-registered under each key. When the number of task keys is very large, this operation greatly affects performance.

      I think it is unnecessary to register EventTimer frequently like this and can we make the following changes?

      When an event comes, the timestamp of the EventTimer we registered is equal to the EventTime of this event instead of watermark + 1.
      When a new ComputionState with window is created (like withIn pattern ),  we use the timeout of this window to create EventTimer (EventTime + WindowTime). 

      After making such an attempt in our test environment, the number of registered timers has been greatly reduced, and the performance has been greatly improved.

       
       

      Attachments

        1. image-2021-08-20-13-59-05-977.png
          0.3 kB
          Yue Ma
        2. image-2022-06-07-21-27-03-814.png
          0.3 kB
          Yue Ma
        3. image-2022-06-07-21-40-58-781.png
          0.3 kB
          Yue Ma

        Issue Links

          Activity

            People

              mayuehappy Yue Ma
              mayuehappy Yue Ma
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: