You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ratis.apache.org by "Attila Doroszlai (Jira)" <ji...@apache.org> on 2019/11/10 13:24:00 UTC

[jira] [Comment Edited] (RATIS-749) Create constant for set of not running states

    [ https://issues.apache.org/jira/browse/RATIS-749?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16971126#comment-16971126 ] 

Attila Doroszlai edited comment on RATIS-749 at 11/10/19 1:23 PM:
------------------------------------------------------------------

Attached two patches:

* [^RATIS-749.001.patch] is a trivial change, replaces varargs at the single place mentioned in issue description with an array
*  [^RATIS-749.001b.patch] is a little more involved, it changes {{isOneOf}} and {{assertCurrentState}} to accept {{Set<State>}}, and adds predefined {{Set}} instances for all calls


was (Author: adoroszlai):
Attached two patches:

* [^RATIS-749.001.patch] is a trivial change, replaces varargs at the single place mentioned in issue description with an array
*  [^RATIS-749.001b.patch] is a little more involved, it changes the method to accept {{Set<State>}}, and adds predefined {{Set}} instances for all calls of {{isOneOf}} and {{assertCurrentState}}

> Create constant for set of not running states
> ---------------------------------------------
>
>                 Key: RATIS-749
>                 URL: https://issues.apache.org/jira/browse/RATIS-749
>             Project: Ratis
>          Issue Type: Improvement
>          Components: server
>            Reporter: Attila Doroszlai
>            Priority: Minor
>              Labels: performance
>         Attachments: RATIS-749.001.patch, RATIS-749.001b.patch, allocations.png
>
>
> {{LogAppender$AppenderDaemon#isRunning}} creates a new array for varargs of {{LifeCycle$State#isOneOf}} upon each call:
> {code:title=https://github.com/apache/incubator-ratis/blob/005aa6ab0f7a9051bb4c4a47660bca29ec70aa20/ratis-server/src/main/java/org/apache/ratis/server/impl/LogAppender.java#L98-L100}
>     boolean isRunning() {
>       return !lifeCycle.getCurrentState().isOneOf(CLOSING, CLOSED, EXCEPTION);
>     }
> {code}
> This is frequently called (indirectly) from the main loop:
> {code:title=https://github.com/apache/incubator-ratis/blob/005aa6ab0f7a9051bb4c4a47660bca29ec70aa20/ratis-server/src/main/java/org/apache/ratis/server/impl/LogAppender.java#L450-L451}
>   protected void runAppenderImpl() throws InterruptedException, IOException {
>     while (isAppenderRunning()) {
> {code}
> There should be a constant array defined with these states to reduce GC.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)