GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Suspicious performance downgrade when buffer size reaches 123456 · Issue #14550 · netty/netty

Suspicious performance downgrade when buffer size reaches 123456 #14550

New issue
Copy link
New issue
Copy link
Open
Open
Suspicious performance downgrade when buffer size reaches 123456#14550
Copy link

Description

@laosijikaichele
laosijikaichele
opened on Dec 8, 2024
Issue body actions

Actual behavior

For AdaptivePoolingAllocator, this issue was accidentally observed when doing the benchmark for another PR.

The benchmark code for this issue: AdaptiveByteBufAllocatorConcurrentNoCacheNormalThreadsCountBenchmark.

In this class, I set the benchmark threads number to 16(@Threads(16)), which EQUALS to the value of MAX_STRIPES on my computer, I think this is a relative normal case in the real world.

The benchmark results:

Benchmark                       (size)  (tokens) Mode   Cnt      Score         Error     Units
allocateReleaseHeapAdaptive      123         0  thrpt    5   82737748.983 ± 4870271.277  ops/s
allocateReleaseHeapAdaptive      123         5  thrpt    5  106069072.912 ± 4528360.404  ops/s
allocateReleaseHeapAdaptive      123        10  thrpt    5   88477188.141 ± 5263762.981  ops/s
allocateReleaseHeapAdaptive      123       100  thrpt    5   25226679.098 ± 1546860.347  ops/s
allocateReleaseHeapAdaptive     1234         0  thrpt    5   88444657.046 ± 5647089.993  ops/s
allocateReleaseHeapAdaptive     1234         5  thrpt    5   99345120.371 ± 5290886.633  ops/s
allocateReleaseHeapAdaptive     1234        10  thrpt    5   72204692.708 ± 3390164.541  ops/s
allocateReleaseHeapAdaptive     1234       100  thrpt    5   24587533.620 ±  998497.177  ops/s
allocateReleaseHeapAdaptive    12345         0  thrpt    5   73294512.302 ± 2059828.543  ops/s
allocateReleaseHeapAdaptive    12345         5  thrpt    5   57574927.587 ± 6321588.219  ops/s
allocateReleaseHeapAdaptive    12345        10  thrpt    5   47532543.444 ± 3355173.821  ops/s
allocateReleaseHeapAdaptive    12345       100  thrpt    5   20569381.895 ±  850272.322  ops/s
allocateReleaseHeapAdaptive   123456         0  thrpt    5     346563.254 ±   20654.815  ops/s
allocateReleaseHeapAdaptive   123456         5  thrpt    5     348363.059 ±   12033.863  ops/s
allocateReleaseHeapAdaptive   123456        10  thrpt    5     344277.648 ±   34680.226  ops/s
allocateReleaseHeapAdaptive   123456       100  thrpt    5     346703.565 ±   23923.853  ops/s
allocateReleaseHeapAdaptive  1234567         0  thrpt    5   89436286.916 ± 4428920.633  ops/s
allocateReleaseHeapAdaptive  1234567         5  thrpt    5   64879436.176 ± 2071187.313  ops/s
allocateReleaseHeapAdaptive  1234567        10  thrpt    5   54308859.118 ± 2200872.906  ops/s
allocateReleaseHeapAdaptive  1234567       100  thrpt    5   25106043.649 ± 1222776.686  ops/s

As we can see, the 'thrpt' decreased sharply when the 'size' becomes 123456, and backs to a relative normal value when the 'size' becomes 1234567.

This may indicate that the allocation logic(size calculation?) may need to be optimized when the size is around 123456?

Netty version

4.1 branch.

JVM version (e.g. java -version)

JDK-17.

Activity

  1. franz1981 commented on Dec 8, 2024

    @franz1981
    franz1981
    on Dec 8, 2024
    Contributor
    More actions

    Can you profile both using the jmh async profiler plugin?
    Just to make sure what change across the twos?

  2. laosijikaichele commented on Dec 9, 2024

    @laosijikaichele
    laosijikaichele
    on Dec 9, 2024
    ContributorAuthor
    More actions

    I did the benchmark in another computer which has 4 cores, so I changed the benchmark threads number to 8(@Threads(8)), which still equals to the value of MAX_STRIPES.

    The benchmark results:

    Benchmark                            (size)    (tokens) Mode   Cnt   Score          Error       Units
    allocateReleaseHeapAdaptive             123         0  thrpt    5  20123351.382 ± 18339105.987  ops/s
    allocateReleaseHeapAdaptive             123         5  thrpt    5  23167149.879 ±   869915.317  ops/s                ---
    allocateReleaseHeapAdaptive             123        10  thrpt    5  19808807.303 ±   410285.267  ops/s
    allocateReleaseHeapAdaptive             123       100  thrpt    5  10310120.978 ±   345207.570  ops/s
    allocateReleaseHeapAdaptive            1234         0  thrpt    5  19573015.615 ± 15318585.579  ops/s
    allocateReleaseHeapAdaptive            1234         5  thrpt    5  20118822.597 ± 14931322.915  ops/s
    allocateReleaseHeapAdaptive            1234        10  thrpt    5  20860126.921 ±   461359.283  ops/s
    allocateReleaseHeapAdaptive            1234       100  thrpt    5  10238037.351 ±   405855.861  ops/s
    allocateReleaseHeapAdaptive           12345         0  thrpt    5   9773164.550 ± 10974848.245  ops/s
    allocateReleaseHeapAdaptive           12345         5  thrpt    5   4579582.234 ±  4755604.436  ops/s
    allocateReleaseHeapAdaptive           12345        10  thrpt    5  10298391.148 ±  1414980.764  ops/s
    allocateReleaseHeapAdaptive           12345       100  thrpt    5  10134687.259 ±   155063.867  ops/s
    allocateReleaseHeapAdaptive          123456         0  thrpt    5     52465.091 ±    34668.300  ops/s
    allocateReleaseHeapAdaptive          123456         5  thrpt    5     49573.603 ±    43921.145  ops/s
    allocateReleaseHeapAdaptive          123456        10  thrpt    5     60502.728 ±     1935.712  ops/s
    allocateReleaseHeapAdaptive          123456       100  thrpt    5     60804.659 ±     2600.401  ops/s
    allocateReleaseHeapAdaptive         1234567         0  thrpt    5  23193841.909 ±  9671360.945  ops/s
    allocateReleaseHeapAdaptive         1234567         5  thrpt    5  19130445.129 ± 18150191.702  ops/s
    allocateReleaseHeapAdaptive         1234567        10  thrpt    5  20687677.117 ±  2003222.336  ops/s
    allocateReleaseHeapAdaptive         1234567       100  thrpt    5   9968993.203 ±   159256.203  ops/s
    

    The flamegraph of 'size-12345-token-100':
    12345-100

    The flamegraph of 'size-123456-token-0':
    123456-0

    The flamegraph of 'size-123456-token-5':
    123456-5

    The flamegraph of 'size-123456-token-10':
    123456-10

    The flamegraph of 'size-123456-token-100':
    123456-100

    The flamegraph of 'size-1234567-token-0':
    1234567-0

    @franz1981

  3. franz1981 commented on Dec 9, 2024

    @franz1981
    franz1981
    on Dec 9, 2024
    Contributor
    More actions

    Which means that there are allocations which are not supposed (they are?) to happen. You can spot that something is off via -prof GC and check the alloc.norm metric

  4. laosijikaichele commented on Dec 9, 2024

    @laosijikaichele
    laosijikaichele
    on Dec 9, 2024
    ContributorAuthor
    More actions

    Done another benchmark on the default pooled allocator PooledByteBufAllocator.DEFAULT for comparison, with benchmark class BufAllocatorConcurrentCompareBenchmark.

    The benchmark results for the default pooled allocator PooledByteBufAllocator.DEFAULT:

    Benchmark                     (size)  (tokens) Mode    Cnt     Score         Error     Units
    AllocateReleaseHeapDefault      123         0  thrpt    5  52213903.069 ± 4514064.780  ops/s
    AllocateReleaseHeapDefault      123         5  thrpt    5  48592954.222 ± 3129638.136  ops/s
    AllocateReleaseHeapDefault      123        10  thrpt    5  45013745.339 ± 1301816.571  ops/s
    AllocateReleaseHeapDefault      123       100  thrpt    5  19684977.541 ±  274609.697  ops/s
    AllocateReleaseHeapDefault     1234         0  thrpt    5  53171831.137 ±  925559.590  ops/s
    AllocateReleaseHeapDefault     1234         5  thrpt    5  43864748.384 ±  605806.193  ops/s
    AllocateReleaseHeapDefault     1234        10  thrpt    5  44470730.290 ± 1018775.349  ops/s
    AllocateReleaseHeapDefault     1234       100  thrpt    5  19667368.357 ±  350978.638  ops/s
    AllocateReleaseHeapDefault    12345         0  thrpt    5  51768451.779 ±  872988.303  ops/s
    AllocateReleaseHeapDefault    12345         5  thrpt    5  45738398.562 ±  914378.965  ops/s
    AllocateReleaseHeapDefault    12345        10  thrpt    5  43789814.585 ±  754944.040  ops/s
    AllocateReleaseHeapDefault    12345       100  thrpt    5  18896948.508 ± 2594243.534  ops/s
    AllocateReleaseHeapDefault   123456         0  thrpt    5  39006051.110 ± 1335026.366  ops/s
    AllocateReleaseHeapDefault   123456         5  thrpt    5  36198188.967 ±  532697.045  ops/s
    AllocateReleaseHeapDefault   123456        10  thrpt    5  36672390.429 ± 1961680.842  ops/s
    AllocateReleaseHeapDefault   123456       100  thrpt    5  19020760.477 ±  313911.602  ops/s
    AllocateReleaseHeapDefault  1234567         0  thrpt    5  26302623.666 ± 2812892.239  ops/s
    AllocateReleaseHeapDefault  1234567         5  thrpt    5  23614737.501 ±  946286.683  ops/s
    AllocateReleaseHeapDefault  1234567        10  thrpt    5  24895685.794 ± 1149154.762  ops/s
    AllocateReleaseHeapDefault  1234567       100  thrpt    5  14916130.916 ±  375791.027  ops/s
    

    As we can see, for 'size-123456-token-0/5/10/100', there is no sharply decrease on the throughput score.

  5. laosijikaichele commented on Dec 10, 2024

    @laosijikaichele
    laosijikaichele
    on Dec 10, 2024
    ContributorAuthor
    More actions

    Done some quick comparison benchmarks between PooledByteBufAllocator.DEFAULT, adaptiveAllocator-with-cache and adaptiveAllocator-no-cache, using benchmark class: BufAllocatorConcurrentCompareMultiBenchmark. The allocation size starts from 123, and increased 12345 as step size until 7604643(about 7.2M), which means the size range is '[123 byte - 7.2M]' with increased step size 12345.
    The thread counts is 8 on the benchmark method(@Threads(8)), and the AdaptivePoolingAllocator.MAX_STRIPES is 16 on the computer.

    1. The comparison results between PooledByteBufAllocator.DEFAULT and adaptiveAllocator-with-cache:
      JMH-morethan

    2. The comparison results between PooledByteBufAllocator.DEFAULT and adaptiveAllocator-no-cache:
      JMH-morethan

    Overall, the adaptiveAllocator performance improved when the size is in range [1049448-1567938],
    but in the rest size range, the adaptiveAllocator performance declined(mostly, not all) than PooledByteBufAllocator.DEFAULT.

    截屏2024-12-10 下午8 16 13 截屏2024-12-10 下午8 16 01
  6. laosijikaichele commented on Dec 11, 2024

    @laosijikaichele
    laosijikaichele
    on Dec 11, 2024
    ContributorAuthor
    More actions

    Done a smaller grained sized benchmarks, which use 123 as the increased step size, and the size range is '[123 byte - 13284 byte]', the benchmark class: BufAllocatorConcurrentCompareMultiLess12345Benchmark

    The thread counts is 8 on the benchmark method(@threads(8)), and the AdaptivePoolingAllocator.MAX_STRIPES is 16 on the computer.

    1. The comparison results between PooledByteBufAllocator.DEFAULT and adaptiveAllocator-with-cache:
      JMH-morethan

    2. The comparison results between PooledByteBufAllocator.DEFAULT and adaptiveAllocator-no-cache:
      JMH-morethan

    Overall, the adaptiveAllocator performance improved when the size is in range '[123 byte - 4920 byte]',
    but in the range '[5043 byte - 13284 byte]', the adaptiveAllocator shows an unstable(mostly declined) results.

    截屏2024-12-11 上午10 09 07 截屏2024-12-11 上午10 09 15
    Reacted by Chris Vest and Johno Crawford
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.