/* * Copyright (c) 2014, 2015, Dynatrace and/or its affiliates. All rights reserved. * * This file is part of the Lock Contention Tracing Subsystem for the HotSpot * Virtual Machine, which is developed at Christian Doppler Laboratory on * Monitoring and Evolution of Very-Large-Scale Software Systems. Please * contact us at if you need additional information * or have any questions. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code 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 * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work. If not, see . * */ package sun.evtracing.processing.statistics.aggregator; import sun.evtracing.processing.Sanity; import sun.evtracing.processing.statistics.metadata.Contention; public class NegativeDurationContentionFilter implements ContentionProcessor { private final ContentionProcessor delegate; public NegativeDurationContentionFilter(ContentionProcessor delegate) { this.delegate = delegate; } @Override public void submit(Contention c) { if (c.duration >= 0) { delegate.submit(c); } else { // The participating threads typically execute on different CPUs. The // clocks of different CPUs are always slightly out of sync, which // results in some error. In some cases, this causes small durations to // become negative. // TODO: filtering negative durations is ok for computing sums, but for // correct counts and averages, we need to find a way to deal with them. if (c.duration < -1000000) { Sanity.warn("dropped contention with negative duration above 1ms: %.3f ms", c.duration / (1000.f * 1000)); } else { Sanity.warn("dropped contention with negative duration in sub-millisecond range: %.3f us", c.duration); } } } @Override public void merge() { delegate.merge(); } }