belliottsmith commented on code in PR #4324: URL: https://github.com/apache/cassandra/pull/4324#discussion_r2316618463
########## src/java/org/apache/cassandra/metrics/ThreadLocalMeter.java: ########## @@ -0,0 +1,372 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.cassandra.metrics; + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.BitSet; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +import com.google.common.annotations.VisibleForTesting; + +import com.codahale.metrics.Clock; +import org.apache.cassandra.concurrent.ScheduledExecutors; +import org.apache.cassandra.utils.MonotonicClock; +import org.apache.cassandra.utils.ReflectionUtils; + +import static java.lang.Math.exp; + +/** + * An alternative to Dropwizard Meter which implements the same kind of API. + * it has more efficent mark operations and consumes less memory. + * Only exponential decaying moving average is supported for 1/5/15-minutes rate values. + * Tick logic is moved out from a mark operation and always executed in a background thread. + * For better cache locality rate values are extracted to a common non thread-local array + * updated by a background thread in bulk. + * Counter logic inside is implemented using @see ThreadLocalMetrics functionality. + * NOTE: Dropwizard Meter is a class and there is no an interface for Dropwizard Meter logic, + * so we have to create an alternative hierarchy. + */ +public class ThreadLocalMeter extends com.codahale.metrics.Meter implements Meter Review Comment: Ah, great. Apologies for querying this before I had got that far in review. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

