Repository: ignite Updated Branches: refs/heads/master 0b2f349ff -> 567a8750e
IGNITE-9231 improvement throttle implementation, unpark threads on cpBuf condition. - Fixes #4506. Signed-off-by: Ivan Rakov <ira...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/567a8750 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/567a8750 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/567a8750 Branch: refs/heads/master Commit: 567a8750ee0d4003fa0a387021b34b95b93184c5 Parents: 0b2f349 Author: Evgeny Stanilovskiy <estanilovs...@gridgain.com> Authored: Fri Aug 10 17:47:13 2018 +0300 Committer: Ivan Rakov <ira...@apache.org> Committed: Fri Aug 10 17:47:13 2018 +0300 ---------------------------------------------------------------------- .../apache/ignite/IgniteSystemProperties.java | 5 ++++ .../persistence/pagemem/PagesWriteThrottle.java | 26 +++++++++++++++++--- .../pagemem/PagesWriteThrottlePolicy.java | 7 +++++- 3 files changed, 34 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/567a8750/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java index c4b83e0..3b4aedb 100644 --- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java @@ -937,6 +937,11 @@ public final class IgniteSystemProperties { public static final String IGNITE_UNWIND_THROTTLING_TIMEOUT = "IGNITE_UNWIND_THROTTLING_TIMEOUT"; /** + * Threshold for throttling operations logging. + */ + public static final String IGNITE_THROTTLE_LOG_THRESHOLD = "IGNITE_THROTTLE_LOG_THRESHOLD"; + + /** * Enforces singleton. */ private IgniteSystemProperties() { http://git-wip-us.apache.org/repos/asf/ignite/blob/567a8750/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PagesWriteThrottle.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PagesWriteThrottle.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PagesWriteThrottle.java index d5f4bd5..2828c43 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PagesWriteThrottle.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PagesWriteThrottle.java @@ -16,13 +16,18 @@ */ package org.apache.ignite.internal.processors.cache.persistence.pagemem; +import java.util.Collection; +import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.LockSupport; import org.apache.ignite.IgniteLogger; +import org.apache.ignite.IgniteSystemProperties; import org.apache.ignite.internal.processors.cache.persistence.CheckpointLockStateChecker; import org.apache.ignite.internal.processors.cache.persistence.CheckpointWriteProgressSupplier; import org.apache.ignite.internal.util.typedef.internal.U; +import static org.apache.ignite.IgniteSystemProperties.IGNITE_STARVATION_CHECK_INTERVAL; + /** * Throttles threads that generate dirty pages during ongoing checkpoint. * Designed to avoid zero dropdowns that can happen if checkpoint buffer is overflowed. @@ -46,6 +51,9 @@ public class PagesWriteThrottle implements PagesWriteThrottlePolicy { /** Backoff ratio. Each next park will be this times longer. */ private static final double BACKOFF_RATIO = 1.05; + /** Checkpoint buffer fullfill upper bound. */ + private static final float CP_BUF_FILL_THRESHOLD = 2f / 3; + /** Counter for dirty pages ratio throttling. */ private final AtomicInteger notInCheckpointBackoffCntr = new AtomicInteger(0); @@ -55,6 +63,9 @@ public class PagesWriteThrottle implements PagesWriteThrottlePolicy { /** Logger. */ private IgniteLogger log; + /** Currently parking threads. */ + private final Collection<Thread> parkThrds = new ConcurrentLinkedQueue<>(); + /** * @param pageMemory Page memory. * @param cpProgress Database manager. @@ -85,7 +96,7 @@ public class PagesWriteThrottle implements PagesWriteThrottlePolicy { boolean shouldThrottle = false; if (isPageInCheckpoint) { - int checkpointBufLimit = pageMemory.checkpointBufferPagesSize() * 2 / 3; + int checkpointBufLimit = (int)(pageMemory.checkpointBufferPagesSize() * CP_BUF_FILL_THRESHOLD); shouldThrottle = pageMemory.checkpointBufferPagesCount() > checkpointBufLimit; } @@ -126,10 +137,19 @@ public class PagesWriteThrottle implements PagesWriteThrottlePolicy { + " for timeout(ms)=" + (throttleParkTimeNs / 1_000_000)); } + if (isPageInCheckpoint) + parkThrds.add(Thread.currentThread()); + LockSupport.parkNanos(throttleParkTimeNs); } - else - cntr.set(0); + else { + int oldCntr = cntr.getAndSet(0); + + if (isPageInCheckpoint && oldCntr != 0) { + parkThrds.forEach(LockSupport::unpark); + parkThrds.clear(); + } + } } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/ignite/blob/567a8750/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PagesWriteThrottlePolicy.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PagesWriteThrottlePolicy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PagesWriteThrottlePolicy.java index 53a8017..e6aab79 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PagesWriteThrottlePolicy.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PagesWriteThrottlePolicy.java @@ -17,14 +17,19 @@ package org.apache.ignite.internal.processors.cache.persistence.pagemem; +import org.apache.ignite.IgniteSystemProperties; + import java.util.concurrent.TimeUnit; +import static org.apache.ignite.IgniteSystemProperties.IGNITE_THROTTLE_LOG_THRESHOLD; + /** * Throttling policy, encapsulates logic of delaying write operations. */ public interface PagesWriteThrottlePolicy { /** Max park time. */ - public long LOGGING_THRESHOLD = TimeUnit.SECONDS.toNanos(10); + public long LOGGING_THRESHOLD = TimeUnit.SECONDS.toNanos(IgniteSystemProperties.getInteger + (IGNITE_THROTTLE_LOG_THRESHOLD, 10)); /** * Callback to apply throttling delay.