Skip to content

Commit

Permalink
Implement new VM pause monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Koval committed Feb 16, 2018
1 parent 25aa603 commit 386ee31
Show file tree
Hide file tree
Showing 7 changed files with 278 additions and 178 deletions.
47 changes: 47 additions & 0 deletions community/common/src/main/java/org/neo4j/util/Preconditions.java
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2002-2018 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package org.neo4j.util;

public final class Preconditions
{
private Preconditions()
{
// util class
}

public static long requireNonNegative( long value )
{
if ( value < 0 )
{
throw new IllegalArgumentException( "Expected non-negative integer value, got " + value );
}
return value;
}

public static long requirePositive( long value )
{
if ( value < 1 )
{
throw new IllegalArgumentException( "Expected positive integer value, got " + value );
}
return value;
}
}
Expand Up @@ -43,7 +43,6 @@
import org.neo4j.kernel.configuration.Settings;
import org.neo4j.kernel.configuration.Title;
import org.neo4j.kernel.configuration.ssl.SslPolicyConfigValidator;
import org.neo4j.kernel.impl.cache.MonitorGc;
import org.neo4j.logging.Level;
import org.neo4j.logging.LogTimeZone;

Expand Down Expand Up @@ -617,16 +616,13 @@ public class GraphDatabaseSettings implements LoadableConfig
public static final Setting<String> forced_kernel_id = buildSetting( "unsupported.dbms.kernel_id", STRING, NO_DEFAULT ).constraint(
illegalValueMessage( "has to be a valid kernel identifier", matches( "[a-zA-Z0-9]*" ) ) ).build();

@SuppressWarnings( "unused" )
@Description( "Amount of time in ms the GC monitor thread will wait before taking another measurement." )
@Internal
public static final Setting<Duration> gc_monitor_interval = MonitorGc.Configuration.gc_monitor_wait_time;
public static final Setting<Duration> vm_pause_monitor_measurement_duration =
setting( "unsupported.vm_pause_monitor.measurement_duration", DURATION, "100ms" );

@SuppressWarnings( "unused" )
@Description( "The amount of time in ms the monitor thread has to be blocked before logging a message it was " +
"blocked." )
@Internal
public static final Setting<Duration> gc_monitor_block_threshold = MonitorGc.Configuration.gc_monitor_threshold;
public static final Setting<Duration> vm_pause_monitor_stall_alert_threshold =
setting( "unsupported.vm_pause_monitor.stall_alert_threshold", DURATION, "100ms" );

@Description( "Relationship count threshold for considering a node to be dense" )
public static final Setting<Integer> dense_node_threshold =
Expand Down

This file was deleted.

Expand Up @@ -19,32 +19,19 @@
*/
package org.neo4j.kernel.impl.cache;

import java.time.Duration;

import org.neo4j.graphdb.config.Setting;
import org.neo4j.graphdb.factory.GraphDatabaseSettings;
import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.lifecycle.Lifecycle;
import org.neo4j.kernel.monitoring.VmPauseMonitor;
import org.neo4j.logging.Log;

import static org.neo4j.kernel.configuration.Settings.DURATION;
import static org.neo4j.kernel.configuration.Settings.setting;
import static org.neo4j.kernel.impl.cache.MeasureDoNothing.loggingMonitor;

public class MonitorGc implements Lifecycle
public class VmPauseMonitorComponent implements Lifecycle
{
public static class Configuration
{
public static final Setting<Duration> gc_monitor_wait_time = setting( "unsupported.dbms.gc_monitor_wait_time",
DURATION, "100ms" );
public static final Setting<Duration> gc_monitor_threshold = setting("unsupported.dbms.gc_monitor_threshold",
DURATION, "200ms" );
}

private final Config config;
private final Log log;
private volatile MeasureDoNothing monitorGc;
private volatile VmPauseMonitor vmPauseMonitor;

public MonitorGc( Config config, Log log )
public VmPauseMonitorComponent( Config config, Log log )
{
this.config = config;
this.log = log;
Expand All @@ -58,17 +45,19 @@ public void init()
@Override
public void start()
{
monitorGc = new MeasureDoNothing( "neo4j.PauseMonitor", loggingMonitor( log ),
config.get( Configuration.gc_monitor_wait_time ).toMillis(),
config.get( Configuration.gc_monitor_threshold ).toMillis() );
monitorGc.start();
vmPauseMonitor = new VmPauseMonitor(
config.get( GraphDatabaseSettings.vm_pause_monitor_measurement_duration ).toMillis(),
config.get( GraphDatabaseSettings.vm_pause_monitor_stall_alert_threshold ).toMillis(),
log, vmPauseInfo -> log.debug( "Detected VM stop-the-world pause: {}", vmPauseInfo )
);
vmPauseMonitor.start();
}

@Override
public void stop()
{
monitorGc.stopMeasuring();
monitorGc = null;
vmPauseMonitor.stop();
vmPauseMonitor = null;
}

@Override
Expand Down
Expand Up @@ -50,11 +50,9 @@
import org.neo4j.kernel.impl.api.dbms.NonTransactionalDbmsOperations;
import org.neo4j.kernel.impl.api.explicitindex.InternalAutoIndexing;
import org.neo4j.kernel.impl.api.index.IndexingService;
import org.neo4j.kernel.impl.cache.MonitorGc;
import org.neo4j.kernel.impl.cache.VmPauseMonitorComponent;
import org.neo4j.kernel.impl.core.DatabasePanicEventGenerator;
import org.neo4j.kernel.impl.core.EmbeddedProxySPI;
import org.neo4j.kernel.impl.core.NodeProxy;
import org.neo4j.kernel.impl.core.RelationshipProxy;
import org.neo4j.kernel.impl.core.RelationshipTypeTokenHolder;
import org.neo4j.kernel.impl.core.StartupStatisticsProvider;
import org.neo4j.kernel.impl.core.ThreadToStatementContextBridge;
Expand All @@ -65,7 +63,6 @@
import org.neo4j.kernel.impl.proc.ProcedureTransactionProvider;
import org.neo4j.kernel.impl.proc.Procedures;
import org.neo4j.kernel.impl.proc.TerminationGuardProvider;
import org.neo4j.kernel.impl.proc.TypeMappers.DefaultValueConverter;
import org.neo4j.kernel.impl.query.QueryExecutionEngine;
import org.neo4j.kernel.impl.store.StoreId;
import org.neo4j.kernel.impl.transaction.log.files.LogFileCreationMonitor;
Expand Down Expand Up @@ -209,7 +206,7 @@ public DataSourceModule( final PlatformModule platformModule, EditionModule edit

dataSourceManager.register( neoStoreDataSource );

life.add( new MonitorGc( config, logging.getInternalLog( MonitorGc.class ) ) );
life.add( new VmPauseMonitorComponent( config, logging.getInternalLog( VmPauseMonitorComponent.class ) ) );

life.add( new PublishPageCacheTracerMetricsAfterStart( platformModule.tracers.pageCursorTracerSupplier ) );

Expand Down

0 comments on commit 386ee31

Please sign in to comment.