[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-4952?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Li Wang updated ZOOKEEPER-4952:
-------------------------------
    Description: 
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 implementing a 
PrometheusRejectExceptionHandler to override the rejectedExecution() API.

{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}


  was:
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}



> 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
>            Priority: Critical
>
> 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 implementing a 
> PrometheusRejectExceptionHandler to override the rejectedExecution() API.
> {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)

Reply via email to