Uploaded image for project: 'Ratis'
  1. Ratis
  2. RATIS-1730

Optimize RaftLog cache eviction time

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 2.4.1
    • server
    • None

    Description

      Using JProfiler, I found almost 50% of AppendEntriesAsync execution time is spent on checkAndEvictCache, see the attached pic. There's also a TODO[1] suggesting to use a daemon thread to perform checkAndEvictCache. 

      The time are mainly spent on getTotalCacheSize() and countCached(). These two methods will visit every segments. When there are lots of closed segments, visiting them all is indeed a very consuming operation, not to mention that they are performed on every appendEntriesAsync.

      [1]https://github.com/apache/ratis/blob/b8117f41481f5f5861566a68bb1ea4dc7c60320c/ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/SegmentedRaftLog.java#L402 

      Attachments

        1. new_result.png
          396 kB
          Song Ziyang
        2. RATIS-1730.patch
          3 kB
          Tsz-wo Sze
        3. image-20221026020057385.png
          447 kB
          Song Ziyang

        Issue Links

          Activity

            People

              szetszwo Tsz-wo Sze
              William Song Song Ziyang
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m