RFR: 8267943: Improve performance of EventWriter by improving varint encoding implementation

Denghui Dong ddong at openjdk.java.net
Wed Jun 2 09:36:29 UTC 2021


On Wed, 2 Jun 2021 08:10:28 GMT, Denghui Dong <ddong at openjdk.org> wrote:

> Hi @richardstartin ,
> 
> I am not a reviewer. I just want to suggest a potential improvement.
> Maybe we can use `switch` instead of `for`, like this:
> 
> ```
>         switch (length) {
>             case 9:
>                 putUncheckedByte(((byte) ((v & 0x7F) | 0x80)));
>                 v >>>= 7;
>             case 8:
>                 putUncheckedByte(((byte) ((v & 0x7F) | 0x80)));
>                 v >>>= 7;
>             case 7:
>                 putUncheckedByte(((byte) ((v & 0x7F) | 0x80)));
>                 v >>>= 7;
>             ...
>         }
> ```
> 
> I think this can eliminate some jump instructions.
> 
> Best,
> Denghui

Hmm... After doing a preliminary test, I found your version performs better on JDK 16, so please ignore this suggestion.

Denghui

-------------

PR: https://git.openjdk.java.net/jdk/pull/4251


More information about the hotspot-jfr-dev mailing list