Skip to content

Instantly share code, notes, and snippets.

@apangin
Last active April 27, 2020 01:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apangin/cc13fcc6e94957db454b7d32694042e8 to your computer and use it in GitHub Desktop.
Save apangin/cc13fcc6e94957db454b7d32694042e8 to your computer and use it in GitHub Desktop.
DirectByteBuffer benchmark: absolute vs. relative
# JMH 1.13 (released 43 days ago)
# VM version: JDK 1.8.0_92, VM 25.92-b14
# VM invoker: C:\Program Files\Java\jdk1.8.0_92\jre\bin\java.exe
# VM options: -Didea.launcher.port=7534 -Didea.launcher.bin.path=C:\Program Files (x86)\IDEA 2016.2.2\bin -Dfile.encoding=UTF-8
# Warmup: 5 iterations, 1 s each
# Measurement: 10 iterations, 1 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Throughput, ops/time
# Benchmark: bench.DirectByteBufferRead.absolute
# Run progress: 0,00% complete, ETA 00:00:30
# Fork: 1 of 1
# Preparing profilers: WinPerfAsmProfiler
# Profilers consume stdout and stderr from target VM, use -v EXTRA to copy to console
# Warmup Iteration 1: 80,017 ops/s
# Warmup Iteration 2: 97,958 ops/s
# Warmup Iteration 3: 99,617 ops/s
# Warmup Iteration 4: 98,887 ops/s
# Warmup Iteration 5: 96,968 ops/s
Iteration 1: 92,439 ops/s
Iteration 2: 96,468 ops/s
Iteration 3: 98,576 ops/s
Iteration 4: 98,360 ops/s
Iteration 5: 90,061 ops/s
Iteration 6: 99,117 ops/s
Iteration 7: 97,510 ops/s
Iteration 8: 98,876 ops/s
Iteration 9: 98,913 ops/s
Iteration 10: 98,941 ops/s
# Processing profiler results: WinPerfAsmProfiler
Result "absolute":
96,926 ±(99.9%) 4,760 ops/s [Average]
(min, avg, max) = (90,061, 96,926, 99,117), stdev = 3,148
CI (99.9%): [92,166, 101,686] (assumes normal distribution)
Secondary result "·asm":
PrintAssembly processed: 176570 total address lines.
Perf output processed (skipped 5,688 seconds):
Column 1: SampledProfile (18291 events)
Hottest code regions (>10,00% "SampledProfile" events):
....[Hottest Region 1]..............................................................................
C2, level 4, bench.DirectByteBufferRead::absolute, version 569 (290 bytes)
0x0000000002d25593: cmp %r11d,%ecx
0x0000000002d25596: cmovl %r10d,%r11d
0x0000000002d2559a: cmp %r11d,%r8d
0x0000000002d2559d: jge 0x0000000002d25751
0x0000000002d255a3: vmovq %rdi,%xmm0
0x0000000002d255a8: vmovd %esi,%xmm6
0x0000000002d255ac: mov %r11d,(%rsp)
0x0000000002d255b0: vmovq %rdx,%xmm7
╭ 0x0000000002d255b5: jmp 0x0000000002d255c6
│ 0x0000000002d255b7: nopw 0x0(%rax,%rax,1)
0,27% │↗ 0x0000000002d255c0: mov %rax,%r14
1,24% ││ 0x0000000002d255c3: mov %r10d,%r8d ;*bipush
││ ; - bench.DirectByteBufferRead::absolute@17 (line 34)
0,15% ↘│ 0x0000000002d255c6: vmovd %r8d,%xmm2
0,07% │ 0x0000000002d255cb: imul $0xd,%r8d,%r11d
0,22% │ 0x0000000002d255cf: movslq %r11d,%r10
1,23% │ 0x0000000002d255d2: vmovq %xmm7,%r11
0,10% │ 0x0000000002d255d7: mov %r11,%rbp
0,08% │ 0x0000000002d255da: add %r10,%rbp ;*invokevirtual getLong
│ ; - java.nio.DirectByteBuffer::getLong@10 (line 765)
│ ; - java.nio.DirectByteBuffer::getLong@12 (line 776)
│ ; - bench.DirectByteBufferRead::absolute@28 (line 35)
0,16% │ 0x0000000002d255dd: mov 0x0(%rbp),%r13
4,00% │ 0x0000000002d255e1: mov 0xd(%rbp),%r10
2,51% │ 0x0000000002d255e5: mov 0xc3(%rbp),%rax
17,27% │ 0x0000000002d255ec: mov 0xb6(%rbp),%r11
1,09% │ 0x0000000002d255f3: vmovq %r11,%xmm1
1,07% │ 0x0000000002d255f8: mov 0xa9(%rbp),%r11
0,96% │ 0x0000000002d255ff: vmovq %r11,%xmm3
0,59% │ 0x0000000002d25604: mov 0x9c(%rbp),%r11
2,22% │ 0x0000000002d2560b: vmovq %r11,%xmm4
1,20% │ 0x0000000002d25610: mov 0x8f(%rbp),%r11
1,69% │ 0x0000000002d25617: vmovq %r11,%xmm5
0,57% │ 0x0000000002d2561c: mov 0x82(%rbp),%r11
1,31% │ 0x0000000002d25623: mov 0x75(%rbp),%r8
0,82% │ 0x0000000002d25627: mov 0x68(%rbp),%r9
0,47% │ 0x0000000002d2562b: mov 0x5b(%rbp),%rcx
0,90% │ 0x0000000002d2562f: mov 0x4e(%rbp),%rbx
1,24% │ 0x0000000002d25633: mov 0x41(%rbp),%rdi
1,54% │ 0x0000000002d25637: mov 0x34(%rbp),%rdx
0,11% │ 0x0000000002d2563b: mov 0x27(%rbp),%rsi
0,42% │ 0x0000000002d2563f: mov 0x1a(%rbp),%rbp
0,49% │ 0x0000000002d25643: bswap %r13
0,90% │ 0x0000000002d25646: add %r14,%r13
0,31% │ 0x0000000002d25649: bswap %rbp
1,34% │ 0x0000000002d2564c: bswap %rsi
0,44% │ 0x0000000002d2564f: bswap %rdx
1,20% │ 0x0000000002d25652: bswap %rdi
0,53% │ 0x0000000002d25655: bswap %rbx
1,33% │ 0x0000000002d25658: bswap %rcx
0,55% │ 0x0000000002d2565b: bswap %r9
1,33% │ 0x0000000002d2565e: bswap %r8
0,63% │ 0x0000000002d25661: bswap %r11
1,28% │ 0x0000000002d25664: vmovq %xmm5,%r14
0,07% │ 0x0000000002d25669: bswap %r14
0,83% │ 0x0000000002d2566c: vmovq %r14,%xmm5
0,89% │ 0x0000000002d25671: vmovq %xmm4,%r14
0,08% │ 0x0000000002d25676: bswap %r14
0,92% │ 0x0000000002d25679: vmovq %r14,%xmm4
0,83% │ 0x0000000002d2567e: vmovq %xmm3,%r14
0,06% │ 0x0000000002d25683: bswap %r14
0,90% │ 0x0000000002d25686: vmovq %r14,%xmm3
0,87% │ 0x0000000002d2568b: vmovq %xmm1,%r14
0,05% │ 0x0000000002d25690: bswap %r14
0,92% │ 0x0000000002d25693: bswap %rax
0,69% │ 0x0000000002d25696: bswap %r10 ;*invokestatic reverseBytes
│ ; - java.nio.Bits::swap@1 (line 61)
│ ; - java.nio.DirectByteBuffer::getLong@26 (line 766)
│ ; - java.nio.DirectByteBuffer::getLong@12 (line 776)
│ ; - bench.DirectByteBufferRead::absolute@28 (line 35)
0,91% │ 0x0000000002d25699: add %r13,%r10
0,92% │ 0x0000000002d2569c: add %r10,%rbp
0,63% │ 0x0000000002d2569f: add %rbp,%rsi
1,05% │ 0x0000000002d256a2: add %rsi,%rdx
1,08% │ 0x0000000002d256a5: add %rdx,%rdi
1,13% │ 0x0000000002d256a8: add %rdi,%rbx
1,07% │ 0x0000000002d256ab: add %rbx,%rcx
1,28% │ 0x0000000002d256ae: add %rcx,%r9
1,32% │ 0x0000000002d256b1: add %r9,%r8
1,27% │ 0x0000000002d256b4: add %r8,%r11
1,32% │ 0x0000000002d256b7: vmovq %xmm5,%r10
0,13% │ 0x0000000002d256bc: add %r11,%r10
1,31% │ 0x0000000002d256bf: vmovq %xmm4,%r11
0,20% │ 0x0000000002d256c4: add %r10,%r11
1,12% │ 0x0000000002d256c7: vmovq %xmm3,%r10
0,16% │ 0x0000000002d256cc: add %r11,%r10
1,26% │ 0x0000000002d256cf: add %r10,%r14
1,45% │ 0x0000000002d256d2: add %r14,%rax ;*ladd
│ ; - bench.DirectByteBufferRead::absolute@31 (line 35)
1,24% │ 0x0000000002d256d5: vmovd %xmm2,%r10d
0,15% │ 0x0000000002d256da: add $0x10,%r10d ;*iinc
│ ; - bench.DirectByteBufferRead::absolute@53 (line 33)
0,09% │ 0x0000000002d256de: cmp (%rsp),%r10d
0,01% ╰ 0x0000000002d256e2: jl 0x0000000002d255c0 ;*if_icmpge
; - bench.DirectByteBufferRead::absolute@14 (line 33)
0x0000000002d256e8: vmovq %xmm0,%rdi
0x0000000002d256ed: vmovd %xmm6,%esi
0x0000000002d256f1: mov %r10d,%r8d
0x0000000002d256f4: vmovq %xmm7,%rdx
0x0000000002d256f9: cmp $0x989680,%r8d
0x0000000002d25700: jge 0x0000000002d25745
0x0000000002d25702: xchg %ax,%ax ;*bipush
; - bench.DirectByteBufferRead::absolute@17 (line 34)
0x0000000002d25704: imul $0xd,%r8d,%ecx ;*imul
....................................................................................................
80,03% <total for region 1>
....[Hottest Region 2]..............................................................................
, <unknown> (0 bytes)
<no assembly is recorded, native region>
....................................................................................................
10,32% <total for region 2>
....[Hottest Regions]...............................................................................
80,03% C2, level 4 bench.DirectByteBufferRead::absolute, version 569 (290 bytes)
10,32% <unknown> (0 bytes)
0,20% ntdll.dll 0x00007ff8c8b70610 (31 bytes)
0,19% jvm.dll 0x0000000067c1866a (42 bytes)
0,19% jvm.dll 0x0000000067d07a7b (17 bytes)
0,19% ntdll.dll 0x00007ff8c8b70882 (48 bytes)
0,17% msvcr100.dll 0x00000000678c31c0 (109 bytes)
0,16% msvcr100.dll 0x00000000678c3c50 (69 bytes)
0,15% jvm.dll 0x0000000067b2dfaa (40 bytes)
0,14% jvm.dll 0x0000000067d0e614 (132 bytes)
0,13% jvm.dll 0x0000000067d07c49 (64 bytes)
0,11% msvcr100.dll 0x00000000678dcf89 (55 bytes)
0,11% jvm.dll 0x0000000067d0a1dc (102 bytes)
0,10% C2, level 4 bench.DirectByteBufferRead::setup, version 545 (161 bytes)
0,10% runtime stub StubRoutines::atomic_cmpxchg_long (35 bytes)
0,10% msvcr100.dll 0x00000000678ad788 (68 bytes)
0,10% jvm.dll 0x0000000067d07a20 (52 bytes)
0,10% kernel32.dll 0x00007ff8c60f52d0 (25 bytes)
0,10% ntdll.dll 0x00007ff8c8be4f40 (20 bytes)
0,09% C1, level 3 bench.DirectByteBufferRead::setup, version 542 (86 bytes)
7,20% <...other 619 warm regions...>
....................................................................................................
99,99% <totals>
....[Hottest Methods (after inlining)]..............................................................
80,04% C2, level 4 bench.DirectByteBufferRead::absolute, version 569
10,32% <unknown>
0,22% C1, level 3 bench.DirectByteBufferRead::setup, version 542
0,20% C2, level 4 bench.DirectByteBufferRead::absolute, version 568
0,20% ntdll.dll 0x00007ff8c8b70610
0,19% C2, level 4 bench.DirectByteBufferRead::setup, version 545
0,19% ntdll.dll 0x00007ff8c8b70882
0,19% jvm.dll 0x0000000067c1866a
0,19% jvm.dll 0x0000000067d07a7b
0,17% msvcr100.dll 0x00000000678c31c0
0,16% msvcr100.dll 0x00000000678c3c50
0,16% interpreter invokevirtual 182 invokevirtual
0,15% jvm.dll 0x0000000067b2dfaa
0,15% C1, level 3 bench.DirectByteBufferRead::absolute, version 566
0,14% jvm.dll 0x0000000067d0e614
0,14% interpreter invoke return entry points
0,13% C1, level 3 bench.DirectByteBufferRead::absolute, version 564
0,13% jvm.dll 0x0000000067d07c49
0,11% msvcr100.dll 0x00000000678dcf89
0,11% jvm.dll 0x0000000067d0a1dc
6,70% <...other 567 warm methods...>
....................................................................................................
99,99% <totals>
....[Distribution by Source]........................................................................
80,79% C2, level 4
10,32%
3,25% jvm.dll
2,11% msvcr100.dll
0,69% interpreter
0,66% ntdll.dll
0,61% hsdis-amd64.dll
0,54% C1, level 3
0,34% msvcrt.dll
0,22% kernel32.dll
0,18% KernelBase.dll
0,10% runtime stub
0,06% "Unknown"
0,03% zip.dll
0,03% rpcrt4.dll
0,02% verify.dll
0,01% C1, level 2
0,01% Unknown, level 0
0,01% IPHLPAPI.DLL
0,01% nsi.dll
....................................................................................................
99,99% <totals>
# JMH 1.13 (released 43 days ago)
# VM version: JDK 1.8.0_92, VM 25.92-b14
# VM invoker: C:\Program Files\Java\jdk1.8.0_92\jre\bin\java.exe
# VM options: -Didea.launcher.port=7534 -Didea.launcher.bin.path=C:\Program Files (x86)\IDEA 2016.2.2\bin -Dfile.encoding=UTF-8
# Warmup: 5 iterations, 1 s each
# Measurement: 10 iterations, 1 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Throughput, ops/time
# Benchmark: bench.DirectByteBufferRead.relative
# Run progress: 50,00% complete, ETA 00:00:28
# Fork: 1 of 1
# Preparing profilers: WinPerfAsmProfiler
# Profilers consume stdout and stderr from target VM, use -v EXTRA to copy to console
# Warmup Iteration 1: 37,608 ops/s
# Warmup Iteration 2: 45,991 ops/s
# Warmup Iteration 3: 46,504 ops/s
# Warmup Iteration 4: 46,526 ops/s
# Warmup Iteration 5: 46,198 ops/s
Iteration 1: 44,435 ops/s
Iteration 2: 45,172 ops/s
Iteration 3: 46,656 ops/s
Iteration 4: 46,397 ops/s
Iteration 5: 45,495 ops/s
Iteration 6: 46,281 ops/s
Iteration 7: 46,902 ops/s
Iteration 8: 46,859 ops/s
Iteration 9: 46,848 ops/s
Iteration 10: 38,955 ops/s
# Processing profiler results: WinPerfAsmProfiler
Result "relative":
45,400 ±(99.9%) 3,647 ops/s [Average]
(min, avg, max) = (38,955, 45,400, 46,902), stdev = 2,412
CI (99.9%): [41,753, 49,047] (assumes normal distribution)
Secondary result "·asm":
PrintAssembly processed: 176291 total address lines.
Perf output processed (skipped 5,719 seconds):
Column 1: SampledProfile (17995 events)
Hottest code regions (>10,00% "SampledProfile" events):
....[Hottest Region 1]..............................................................................
C2, level 4, bench.DirectByteBufferRead::relative, version 559 (188 bytes)
; - java.nio.DirectByteBuffer::get@5 (line 249)
; - bench.DirectByteBufferRead::relative@35 (line 52)
0x000000000354025e: mov %r13d,%r8d
0x0000000003540261: add $0xd,%r8d
0x0000000003540265: mov %r8d,0x18(%rbp) ;*putfield position
; - java.nio.Buffer::nextGetIndex@27 (line 501)
; - java.nio.DirectByteBuffer::get@5 (line 249)
; - bench.DirectByteBufferRead::relative@35 (line 52)
0x0000000003540269: mov $0x1,%ecx
0x000000000354026e: xchg %ax,%ax
2,02% ↗ 0x0000000003540270: imul $0xd,%ecx,%ebx ;*lload_2
│ ; - bench.DirectByteBufferRead::relative@22 (line 50)
1,67% │ 0x0000000003540273: mov %r9d,%edi
1,58% │ 0x0000000003540276: sub %ebx,%edi ;*isub
│ ; - java.nio.Buffer::nextGetIndex@8 (line 505)
│ ; - java.nio.DirectByteBuffer::getLong@5 (line 772)
│ ; - bench.DirectByteBufferRead::relative@24 (line 50)
1,37% │ 0x0000000003540278: cmp $0x8,%edi
0,01% │ 0x000000000354027b: jl 0x00000000035403c3 ;*if_icmpge
│ ; - java.nio.Buffer::nextGetIndex@10 (line 505)
│ ; - java.nio.DirectByteBuffer::getLong@5 (line 772)
│ ; - bench.DirectByteBufferRead::relative@24 (line 50)
1,99% │ 0x0000000003540281: add %r13d,%ebx ;*getfield position
│ ; - java.nio.Buffer::nextGetIndex@5 (line 505)
│ ; - java.nio.DirectByteBuffer::getLong@5 (line 772)
│ ; - bench.DirectByteBufferRead::relative@24 (line 50)
1,48% │ 0x0000000003540284: mov %edi,%r11d
1,62% │ 0x0000000003540287: add $0xfffffff8,%r11d ;*isub
│ ; - java.nio.Buffer::nextGetIndex@8 (line 505)
│ ; - java.nio.DirectByteBuffer::getInt@4 (line 681)
│ ; - bench.DirectByteBufferRead::relative@30 (line 51)
1,58% │ 0x000000000354028b: mov %ebx,%r8d
2,13% │ 0x000000000354028e: add $0x8,%r8d
1,48% │ 0x0000000003540292: mov %r8d,0x18(%rbp) ;*putfield position
│ ; - java.nio.Buffer::nextGetIndex@33 (line 508)
│ ; - java.nio.DirectByteBuffer::getLong@5 (line 772)
│ ; - bench.DirectByteBufferRead::relative@24 (line 50)
1,84% │ 0x0000000003540296: movslq %ebx,%r8
1,22% │ 0x0000000003540299: mov (%rdx,%r8,1),%rsi
3,85% │ 0x000000000354029d: bswap %rsi ;*invokestatic reverseBytes
│ ; - java.nio.Bits::swap@1 (line 61)
│ ; - java.nio.DirectByteBuffer::getLong@26 (line 766)
│ ; - java.nio.DirectByteBuffer::getLong@11 (line 772)
│ ; - bench.DirectByteBufferRead::relative@24 (line 50)
3,82% │ 0x00000000035402a0: add %rax,%rsi ;*ladd
│ ; - bench.DirectByteBufferRead::relative@27 (line 50)
1,90% │ 0x00000000035402a3: cmp $0x4,%r11d
0,01% │ 0x00000000035402a7: jl 0x00000000035403e5 ;*if_icmpge
│ ; - java.nio.Buffer::nextGetIndex@10 (line 505)
│ ; - java.nio.DirectByteBuffer::getInt@4 (line 681)
│ ; - bench.DirectByteBufferRead::relative@30 (line 51)
1,48% │ 0x00000000035402ad: mov %ebx,%r11d
1,35% │ 0x00000000035402b0: add $0xc,%r11d ;*iadd
│ ; - java.nio.Buffer::nextGetIndex@32 (line 508)
│ ; - java.nio.DirectByteBuffer::getInt@4 (line 681)
│ ; - bench.DirectByteBufferRead::relative@30 (line 51)
1,52% │ 0x00000000035402b4: mov %r11d,0x18(%rbp) ;*putfield position
│ ; - java.nio.Buffer::nextGetIndex@33 (line 508)
│ ; - java.nio.DirectByteBuffer::getInt@4 (line 681)
│ ; - bench.DirectByteBufferRead::relative@30 (line 51)
2,01% │ 0x00000000035402b8: cmp %r10d,%r11d
0,01% │ 0x00000000035402bb: jge 0x0000000003540409 ;*if_icmplt
│ ; - java.nio.Buffer::nextGetIndex@8 (line 499)
│ ; - java.nio.DirectByteBuffer::get@5 (line 249)
│ ; - bench.DirectByteBufferRead::relative@35 (line 52)
1,72% │ 0x00000000035402c1: mov %edi,%r11d
1,38% │ 0x00000000035402c4: add $0xfffffff3,%r11d ;*isub
│ ; - java.nio.Buffer::nextGetIndex@8 (line 505)
│ ; - java.nio.DirectByteBuffer::getLong@5 (line 772)
│ ; - bench.DirectByteBufferRead::relative@24 (line 50)
1,63% │ 0x00000000035402c8: mov %ecx,%r8d
1,92% │ 0x00000000035402cb: inc %r8d ;*iinc
│ ; - bench.DirectByteBufferRead::relative@39 (line 49)
1,53% │ 0x00000000035402ce: mov %ebx,%eax
1,58% │ 0x00000000035402d0: add $0xd,%eax ;*iadd
│ ; - java.nio.Buffer::nextGetIndex@26 (line 501)
│ ; - java.nio.DirectByteBuffer::get@5 (line 249)
│ ; - bench.DirectByteBufferRead::relative@35 (line 52)
1,51% │ 0x00000000035402d3: mov %eax,0x18(%rbp) ;*putfield position
│ ; - java.nio.Buffer::nextGetIndex@27 (line 501)
│ ; - java.nio.DirectByteBuffer::get@5 (line 249)
│ ; - bench.DirectByteBufferRead::relative@35 (line 52)
2,17% │ 0x00000000035402d6: cmp $0x8,%r11d
│ 0x00000000035402da: jl 0x00000000035403cc ;*if_icmpge
│ ; - java.nio.Buffer::nextGetIndex@10 (line 505)
│ ; - java.nio.DirectByteBuffer::getLong@5 (line 772)
│ ; - bench.DirectByteBufferRead::relative@24 (line 50)
1,52% │ 0x00000000035402e0: add $0xffffffeb,%edi ;*isub
│ ; - java.nio.Buffer::nextGetIndex@8 (line 505)
│ ; - java.nio.DirectByteBuffer::getInt@4 (line 681)
│ ; - bench.DirectByteBufferRead::relative@30 (line 51)
1,38% │ 0x00000000035402e3: mov %ebx,%r11d
1,43% │ 0x00000000035402e6: add $0x15,%r11d
2,20% │ 0x00000000035402ea: mov %r11d,0x18(%rbp) ;*putfield position
│ ; - java.nio.Buffer::nextGetIndex@33 (line 508)
│ ; - java.nio.DirectByteBuffer::getLong@5 (line 772)
│ ; - bench.DirectByteBufferRead::relative@24 (line 50)
1,76% │ 0x00000000035402ee: movslq %eax,%r11
1,33% │ 0x00000000035402f1: mov (%rdx,%r11,1),%rax
2,57% │ 0x00000000035402f5: bswap %rax ;*invokestatic reverseBytes
│ ; - java.nio.Bits::swap@1 (line 61)
│ ; - java.nio.DirectByteBuffer::getLong@26 (line 766)
│ ; - java.nio.DirectByteBuffer::getLong@11 (line 772)
│ ; - bench.DirectByteBufferRead::relative@24 (line 50)
3,91% │ 0x00000000035402f8: add %rsi,%rax ;*ladd
│ ; - bench.DirectByteBufferRead::relative@27 (line 50)
1,78% │ 0x00000000035402fb: cmp $0x4,%edi
│ 0x00000000035402fe: jl 0x00000000035403ee ;*if_icmpge
│ ; - java.nio.Buffer::nextGetIndex@10 (line 505)
│ ; - java.nio.DirectByteBuffer::getInt@4 (line 681)
│ ; - bench.DirectByteBufferRead::relative@30 (line 51)
1,41% │ 0x0000000003540304: mov %ebx,%r11d
1,98% │ 0x0000000003540307: add $0x19,%r11d ;*iadd
│ ; - java.nio.Buffer::nextGetIndex@32 (line 508)
│ ; - java.nio.DirectByteBuffer::getInt@4 (line 681)
│ ; - bench.DirectByteBufferRead::relative@30 (line 51)
1,59% │ 0x000000000354030b: mov %r11d,0x18(%rbp) ;*putfield position
│ ; - java.nio.Buffer::nextGetIndex@33 (line 508)
│ ; - java.nio.DirectByteBuffer::getInt@4 (line 681)
│ ; - bench.DirectByteBufferRead::relative@30 (line 51)
1,84% │ 0x000000000354030f: cmp %r10d,%r11d
│ 0x0000000003540312: jge 0x000000000354040f ;*if_icmplt
│ ; - java.nio.Buffer::nextGetIndex@8 (line 499)
│ ; - java.nio.DirectByteBuffer::get@5 (line 249)
│ ; - bench.DirectByteBufferRead::relative@35 (line 52)
1,41% │ 0x0000000003540318: mov %ebx,%r8d
1,95% │ 0x000000000354031b: add $0x1a,%r8d
1,45% │ 0x000000000354031f: mov %r8d,0x18(%rbp) ;*putfield position
│ ; - java.nio.Buffer::nextGetIndex@27 (line 501)
│ ; - java.nio.DirectByteBuffer::get@5 (line 249)
│ ; - bench.DirectByteBufferRead::relative@35 (line 52)
1,66% │ 0x0000000003540323: add $0x2,%ecx ;*iinc
│ ; - bench.DirectByteBufferRead::relative@39 (line 49)
1,24% │ 0x0000000003540326: cmp $0x98967f,%ecx
0,02% ╰ 0x000000000354032c: jl 0x0000000003540270 ;*if_icmpge
; - bench.DirectByteBufferRead::relative@19 (line 49)
0x0000000003540332: cmp $0x989680,%ecx
0x0000000003540338: jge 0x00000000035403b7
0x000000000354033a: imul $0xd,%ecx,%r11d
0x000000000354033e: sub %r11d,%ebx
0x0000000003540341: mov %r10d,%r13d
0x0000000003540344: sub %ebx,%r13d
0x0000000003540347: nop
0x0000000003540348: imul $0xd,%ecx,%r9d ;*lload_2
; - bench.DirectByteBufferRead::relative@22 (line 50)
....................................................................................................
81,84% <total for region 1>
....[Hottest Regions]...............................................................................
81,84% C2, level 4 bench.DirectByteBufferRead::relative, version 559 (188 bytes)
9,11% <unknown> (0 bytes)
0,29% C2, level 4 bench.DirectByteBufferRead::relative, version 558 (201 bytes)
0,20% jvm.dll 0x0000000067d07bc0 (199 bytes)
0,17% jvm.dll 0x0000000067d07a7b (7 bytes)
0,16% ntdll.dll 0x00007ff8c8b70880 (50 bytes)
0,16% jvm.dll 0x0000000067b2dfaa (57 bytes)
0,15% msvcr100.dll 0x00000000678c31c0 (151 bytes)
0,15% msvcr100.dll 0x00000000678c3c50 (69 bytes)
0,13% msvcr100.dll 0x00000000678c4dd9 (198 bytes)
0,13% jvm.dll 0x0000000067c18675 (31 bytes)
0,12% jvm.dll 0x0000000067d0e640 (88 bytes)
0,11% msvcr100.dll 0x00000000678abf63 (128 bytes)
0,11% C2, level 4 java.nio.DirectByteBuffer::getInt, version 552 (94 bytes)
0,11% msvcr100.dll 0x00000000678dcf89 (50 bytes)
0,10% C2, level 4 java.nio.DirectByteBuffer::putLong, version 528 (102 bytes)
0,10% C2, level 4 java.nio.DirectByteBuffer::getLong, version 550 (91 bytes)
0,10% C1, level 3 bench.DirectByteBufferRead::relative, version 554 (124 bytes)
0,09% ntdll.dll 0x00007ff8c8b70610 (31 bytes)
0,09% ntdll.dll 0x00007ff8c8be4f40 (20 bytes)
6,57% <...other 534 warm regions...>
....................................................................................................
99,99% <totals>
....[Hottest Methods (after inlining)]..............................................................
81,84% C2, level 4 bench.DirectByteBufferRead::relative, version 559
9,11% <unknown>
0,29% C2, level 4 bench.DirectByteBufferRead::relative, version 558
0,20% jvm.dll 0x0000000067d07bc0
0,19% C1, level 3 bench.DirectByteBufferRead::relative, version 554
0,18% C2, level 4 bench.DirectByteBufferRead::setup, version 535
0,17% jvm.dll 0x0000000067d07a7b
0,16% ntdll.dll 0x00007ff8c8b70880
0,16% C1, level 3 bench.DirectByteBufferRead::setup, version 532
0,16% jvm.dll 0x0000000067b2dfaa
0,15% interpreter invoke return entry points
0,15% msvcr100.dll 0x00000000678c3c50
0,15% msvcr100.dll 0x00000000678c31c0
0,13% msvcr100.dll 0x00000000678c4dd9
0,13% jvm.dll 0x0000000067c18675
0,12% jvm.dll 0x0000000067d0e640
0,11% msvcr100.dll 0x00000000678abf63
0,11% msvcr100.dll 0x00000000678dcf89
0,11% C2, level 4 java.nio.DirectByteBuffer::getInt, version 552
0,10% C2, level 4 java.nio.DirectByteBuffer::getLong, version 550
6,27% <...other 490 warm methods...>
....................................................................................................
99,99% <totals>
....[Distribution by Source]........................................................................
82,84% C2, level 4
9,11%
2,90% jvm.dll
2,15% msvcr100.dll
0,63% interpreter
0,55% ntdll.dll
0,53% hsdis-amd64.dll
0,46% C1, level 3
0,29% msvcrt.dll
0,18% KernelBase.dll
0,14% kernel32.dll
0,09% runtime stub
0,04% "Unknown"
0,03% rpcrt4.dll
0,02% C1, level 2
0,02% zip.dll
0,01% verify.dll
0,01% IPHLPAPI.DLL
0,01% Unknown, level 0
....................................................................................................
99,99% <totals>
# Run complete. Total time: 00:00:54
Benchmark Mode Cnt Score Error Units
DirectByteBufferRead.absolute thrpt 10 96,926 ± 4,760 ops/s
DirectByteBufferRead.absolute:·asm thrpt NaN ---
DirectByteBufferRead.relative thrpt 10 45,400 ± 3,647 ops/s
DirectByteBufferRead.relative:·asm thrpt NaN ---
Process finished with exit code 0
package bench;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import java.nio.ByteBuffer;
@State(Scope.Benchmark)
public class DirectByteBufferRead {
private static final int OBJ_SIZE = 8 + 4 + 1;
private static final int NUM_ELEM = 10_000_000;
private ByteBuffer bb;
@Setup
public void setup() {
bb = ByteBuffer.allocateDirect(OBJ_SIZE * NUM_ELEM);
for (int i = 0; i < NUM_ELEM; i++) {
bb.putLong(i);
bb.putInt(i);
bb.put((byte) (i & 1));
}
}
@Benchmark
public long absolute() throws InterruptedException {
ByteBuffer directByteBuffer = this.bb;
long val = 0;
for (int i = 0; i < NUM_ELEM; i++) {
int index = OBJ_SIZE * i;
val += directByteBuffer.getLong(index);
directByteBuffer.getInt(index + 8);
directByteBuffer.get(index + 12);
}
return val;
}
@Benchmark
public long relative() throws InterruptedException {
ByteBuffer directByteBuffer = this.bb;
directByteBuffer.rewind();
long val = 0;
for (int i = 0; i < NUM_ELEM; i++) {
val += directByteBuffer.getLong();
directByteBuffer.getInt();
directByteBuffer.get();
}
return val;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment