Class PagesWriteSpeedBasedThrottle

  • All Implemented Interfaces:
    PagesWriteThrottlePolicy

    public class PagesWriteSpeedBasedThrottle
    extends Object
    implements PagesWriteThrottlePolicy
    Throttles threads that generate dirty pages during ongoing checkpoint. Designed to avoid zero dropdowns that can happen if checkpoint buffer is overflowed. When the page in question is not included in the current checkpoint and Checkpoint Buffer is filled over 2/3, uses exponentially growing sleep time to throttle. Otherwise, uses average checkpoint write speed and instant speed of marking pages as dirty.
    See Also:
    Speed-based throttling description
    • Method Detail

      • onMarkDirty

        public void onMarkDirty​(boolean isPageInCheckpoint)
        Callback to apply throttling delay.
        Specified by:
        onMarkDirty in interface PagesWriteThrottlePolicy
        Parameters:
        isPageInCheckpoint - flag indicating if current page is in scope of current checkpoint.
      • doPark

        protected void doPark​(long throttleParkTimeNs)
        Disables the current thread for thread scheduling purposes. May be overriden by subclasses for tests
        Parameters:
        throttleParkTimeNs - the maximum number of nanoseconds to wait
      • throttleParkTime

        public long throttleParkTime()
        Returns:
        Exponential backoff counter.
      • getTargetDirtyRatio

        public double getTargetDirtyRatio()
        Returns:
        Target (maximum) dirty pages ratio, after which throttling will start.
      • getCurrDirtyRatio

        public double getCurrDirtyRatio()
        Returns:
        Current dirty pages ratio.
      • getMarkDirtySpeed

        public long getMarkDirtySpeed()
        Returns:
        Speed of marking pages dirty. Value from past 750-1000 millis only. Pages/second.
      • getCpWriteSpeed

        public long getCpWriteSpeed()
        Returns:
        Speed average checkpoint write speed. Current and 3 past checkpoints used. Pages/second.
      • getLastEstimatedSpeedForMarkAll

        public long getLastEstimatedSpeedForMarkAll()
        Returns:
        last estimated speed for marking all clear pages as dirty till the end of checkpoint.
      • throttleWeight

        public double throttleWeight()
        Measurement shows how much throttling time is involved into average marking time.
        Returns:
        metric started from 0.0 and showing how much throttling is involved into current marking process.
      • wakeupThrottledThreads

        public void wakeupThrottledThreads()
        Callback to wakeup throttled threads. Invoked when the Checkpoint Buffer use drops below a certain threshold.
        Specified by:
        wakeupThrottledThreads in interface PagesWriteThrottlePolicy
      • isCpBufferOverflowThresholdExceeded

        public boolean isCpBufferOverflowThresholdExceeded()
        Whether Checkpoint Buffer is currently close to exhaustion.
        Specified by:
        isCpBufferOverflowThresholdExceeded in interface PagesWriteThrottlePolicy
        Returns:
        true if measures like throttling to protect Checkpoint Buffer should be applied, and false otherwise.