RFR: 8299982: (bf) Buffer.checkIndex(int, int) should use Objects.checkIndex(int, int)
Brian Burkhalter
bpb at openjdk.org
Tue Jan 24 22:18:45 UTC 2023
On Tue, 24 Jan 2023 22:07:51 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
> Replace explicit check of indexes in `Buffer::checkIndex(int,int)` with a call to `Objects::checkIndex(int,int)` in order to improve the throughput of other methods which invoke `Buffer::checkIndex(int,int)`.
Using a microbenchmark derived from the one in [panama-foreign PR 762](https://github.com/openjdk/panama-foreign/pull/762), the following changes in average execution times were observed for `ByteBuffer::getLong` and `ByteBuffer::putLong`.
**Throughput of `ByteBuffer::getLong(int)` in ns/op**
| size | before | after |
|------|--------|-------|
| 1 | 7.532 | 6.034 |
| 2 |8.288 | 6.580 |
| 16 | 15.591 | 12.902 |
| 64 |34.704 | 28.589 |
| 256 | 109.651 | 82.341 |
**Throughput of `ByteBuffer::putLong(int, long)` in ns/op**
| size | before | after |
|------|--------|-------|
| 1 | 4.863 | 3.605 |
| 2 | 5.730 | 4.247 |
| 16 | 13.784 | 10.004 |
| 64 | 32.956 | 26.201 |
| 256 | 144.046 | 80.822 |
-------------
PR: https://git.openjdk.org/jdk/pull/12174
More information about the nio-dev
mailing list