Li Wang created ZOOKEEPER-4952:
----------------------------------
Summary: Reduce the GC overhead of Prometheus reject exception
handling
Key: ZOOKEEPER-4952
URL: https://issues.apache.org/jira/browse/ZOOKEEPER-4952
Project: ZooKeeper
Issue Type: Improvement
Components: metric system
Reporter: Li Wang
The default RejectedExecutionHandler using by ThreadPoolExecutor is
AbortPolicy. It has lots of GC overhead as it performs toString() on both
Runnable object and exception object.
This is to reduce the GC overhead by implements a
PrometheusRejectExceptionHandler.
{code:java}
public static class AbortPolicy implements RejectedExecutionHandler {
/**
* Creates an {@code AbortPolicy}.
*/
public AbortPolicy() { }
/**
* Always throws RejectedExecutionException.
*
* @param r the runnable task requested to be executed
* @param e the executor attempting to execute this task
* @throws RejectedExecutionException always
*/
public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
throw new RejectedExecutionException("Task " + r.toString() +
" rejected from " +
e.toString());
}
}
{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)