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 — JMH: assertion should be disabled by default when doing JMH test · Issue #14876 · netty/netty

JMH: assertion should be disabled by default when doing JMH test #14876

New issue
Copy link
New issue
Copy link
Closed
#14878
Closed
JMH: assertion should be disabled by default when doing JMH test#14876
#14878
Copy link

Description

@laosijikaichele
laosijikaichele
opened on Feb 28, 2025
Issue body actions

Currently, assertion is enabled by default when doing JMH test, by the AbstractMicrobenchmark's default constructor:

netty/microbench/src/main/java/io/netty/microbench/util/AbstractMicrobenchmark.java

Lines 109 to 111 in 24479a0

public AbstractMicrobenchmark() {
this(false, false);
}

But some assertion code may hurt performance, which may jitter the JMH results, for example:

netty/buffer/src/main/java/io/netty/buffer/PoolChunkList.java

Lines 129 to 131 in 24479a0

private boolean move(PoolChunk<T> chunk) {
assert chunk.usage() < maxUsage;

The chunk.usage() calls ReentrantLock.lock() internally, which may hurt performance, thus will not reflect the real performance.

Assertion is commonly disabled in production to avoid performance penalty.
Since the JMH tests are mainly aimed to evaluate the performance, rather than logic correctness(which assertion does), so the JMH tests should do the same as the production, to exclude the noise introduced by assertion.

I noticed there is another constructor method in AbstractMicrobenchmark which can disable assertion, but only a few JMH tests use it, so I suggest we make the assertion disabled in the default constructor.

Activity

  1. normanmaurer commented on Feb 28, 2025

    @normanmaurer
    normanmaurer
    on Feb 28, 2025
    Member
    More actions

    @laosijikaichele I agree to change the default.. Please submit a PR.

  2. laosijikaichele commented on Feb 28, 2025

    @laosijikaichele
    laosijikaichele
    on Feb 28, 2025
    ContributorAuthor
    More actions

    @laosijikaichele I agree to change the default.. Please submit a PR.

    PR submitted. #14878.

  3. franz1981 commented on Mar 4, 2025

    @franz1981
    franz1981
    on Mar 4, 2025
    Contributor
    More actions

    @laosijikaichele in some other issue you posted results from the pooled allocator without assertion (I usually run benchmarks using JMH benchmark.jar and assertions are not enabled there) - and I noticed a great variance similar to what I found at #14757 ; can you post there the intermediate running results? 🙏

  4. normanmaurer
    closed this as completedin #14878on Mar 4, 2025
  5. normanmaurer
    closed this as completedin be8c9f2on Mar 4, 2025
  6. laosijikaichele commented on Mar 4, 2025

    @laosijikaichele
    laosijikaichele
    on Mar 4, 2025
    ContributorAuthor
    More actions

    @laosijikaichele in some other issue you posted results from the pooled allocator without assertion (I usually run benchmarks using JMH benchmark.jar and assertions are not enabled there) - and I noticed a great variance similar to what I found at #14757 ; can you post there the intermediate running results? 🙏

    Sure, will take a look.

  7. pull
    added a commit that references this issue on Mar 4, 2025

    Disable assertion by default in JMH tests (netty#14878)

    This issue will close once commit be8c9f2 is merged into the '4.1' branch.
    be8c9f2
  8. normanmaurer
    added 2 commits that reference this issue on Mar 4, 2025

    Disable assertion by default in JMH tests (#14878)

    This issue will close once commit c88e4a0 is merged into the '4.2' branch.
    c88e4a0

    Disable assertion by default in JMH tests (#14878) (#14885)

    This issue will close once commit f92a33c is merged into the '4.2' branch.
    f92a33c
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.