RFR: 8267943: Improve performance of EventWriter by improving varint encoding implementation
Denghui Dong
ddong at openjdk.java.net
Wed Jun 2 08:13:27 UTC 2021
On Fri, 28 May 2021 14:42:11 GMT, Richard Startin <github.com+16439049+richardstartin at openjdk.org> wrote:
> This PR improves the performance of committing events with numeric correlation ids by precomputing the number of continuation bytes required by each varint and storing them in a lookup table addressable by the input `long`'s leading zero count. In some rough [benchmarks](https://github.com/richardstartin/jfr-events/blob/master/src/main/java/io/github/richardstartin/jfrevents/CommitEventBenchmark.java), this shows a negligible regression for committing empty events, but a 15% improvement for committing an event with two random 64 bit identifiers.
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
-------------
PR: https://git.openjdk.java.net/jdk/pull/4251
More information about the hotspot-jfr-dev
mailing list