JDK-8342692 : C2: long counted loop/long range checks: don't create loop-nest for short running loops
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 24
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2024-10-21
  • Updated: 2025-07-09
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Relates :  
Description
Maurizio reported:

https://github.com/openjdk/jdk/compare/master...mcimadamore:jdk:manual_mismatch_bench?expand=1

Benchmark                                    (ELEM_SIZE)  Mode  Cnt   Score   Error  Units
HeapMismatchManualLoopTest.array_mismatch              4  avgt   30   4.127 ± 0.348  ns/op
HeapMismatchManualLoopTest.array_mismatch              8  avgt   30   6.853 ± 0.634  ns/op
HeapMismatchManualLoopTest.array_mismatch             16  avgt   30   8.688 ± 0.293  ns/op
HeapMismatchManualLoopTest.array_mismatch             32  avgt   30  14.533 ± 0.499  ns/op
HeapMismatchManualLoopTest.array_mismatch             64  avgt   30  26.003 ± 0.722  ns/op
HeapMismatchManualLoopTest.array_mismatch            128  avgt   30  48.277 ± 2.705  ns/op
HeapMismatchManualLoopTest.buffer_mismatch             4  avgt   30   9.478 ± 1.031  ns/op
HeapMismatchManualLoopTest.buffer_mismatch             8  avgt   30  11.535 ± 0.456  ns/op
HeapMismatchManualLoopTest.buffer_mismatch            16  avgt   30  15.804 ± 0.242  ns/op
HeapMismatchManualLoopTest.buffer_mismatch            32  avgt   30  22.430 ± 1.295  ns/op
HeapMismatchManualLoopTest.buffer_mismatch            64  avgt   30  35.522 ± 0.127  ns/op
HeapMismatchManualLoopTest.buffer_mismatch           128  avgt   30  72.621 ± 2.236  ns/op
HeapMismatchManualLoopTest.segment_mismatch            4  avgt   30  14.222 ± 2.038  ns/op
HeapMismatchManualLoopTest.segment_mismatch            8  avgt   30  16.062 ± 0.271  ns/op
HeapMismatchManualLoopTest.segment_mismatch           16  avgt   30  19.308 ± 0.106  ns/op
HeapMismatchManualLoopTest.segment_mismatch           32  avgt   30  28.064 ± 1.462  ns/op
HeapMismatchManualLoopTest.segment_mismatch           64  avgt   30  39.238 ± 0.434  ns/op
HeapMismatchManualLoopTest.segment_mismatch          128  avgt   30  55.971 ± 0.339  ns/op

For very small sizes, arrays seems much better, but ByteBuffer is also better than MemorySegment.

As the size increase, the gap gets smaller and then, for bigger sizes, MemorySegments overtakes ByteBuffers and gets quite close to the array variant.

Comments
These are also about short running loops.
05-12-2024

Looking at the PR, it seems that it's rather an improvement than a bug fix in existing code. Let's turn it into an RFE.
22-10-2024

Should this rather be an enhancement?
22-10-2024

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/21630 Date: 2024-10-22 07:48:33 +0000
22-10-2024