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 — [java] Deprecate rule SimplifyStartsWith · Issue #2740 · pmd/pmd

[java] Deprecate rule SimplifyStartsWith #2740

New issue
Copy link
New issue
Copy link
Closed
#3072
Closed
[java] Deprecate rule SimplifyStartsWith#2740
#3072
Copy link
Labels
is:deprecationThe main focus is deprecating public APIs or rules, eg to make them internal, or removing them
Milestone
6.31.0

Description

@oowekyala
oowekyala
opened on Aug 25, 2020
Issue body actions

Rule: SimplifyStartsWith

From #1868:

But I'm wondering, whether this performance improvement is still valid with today's VMs...

We can probably write a JMH test to make sure of it before we make a decision, as we did for ConsecutiveAppendShouldReuse https://stackoverflow.com/questions/37672785/how-can-i-improve-performance-if-append-is-called-on-stringbuffer-or-stringb/41839223#41839223

Activity

  1. oowekyala
    added
    a:questionRequest for information that doesn't necessarily entail changes to the code base
    on Aug 25, 2020
  2. oowekyala
    added a commit that references this issue on Dec 15, 2020

    Benchmark for pmd/pmd#2740

    a045b6e
  3. oowekyala commented on Dec 15, 2020

    @oowekyala
    oowekyala
    on Dec 15, 2020
    MemberAuthor
    More actions

    I wrote a small benchmark for that, and it appears there is a slight difference in performance, but no earlier than jdk 15:

    https://github.com/oowekyala/pmd-jmh/blob/a045b6ef3337858d7541f41b19e34895d64a0286/src/main/java/net/sourceforge/pmd/MyBenchmark.java#L62-L91

    Regardless, I don't think PMD should recommend micro-optimisations like this, especially when they decrease readability.


    Edit: actually I wouldn't trust at all the jdk 15 result. I didn't notice JMH does not support that vm so the result may be completely wrong. I've observed absurd measurements with the same vm on other benchmarks.

    Ignoring this JDK 15 benchmark, we can probably conclude that it's actually slightly faster to use startsWith with a string (possibly because of the lack of branch), and so since at least jdk 8 - which is still the most used java version. Which means the rule should be removed.

  4. adangel commented on Jan 7, 2021

    @adangel
    adangel
    on Jan 7, 2021
    Member
    More actions

    Thanks for looking into this.

    Regardless, I don't think PMD should recommend micro-optimisations like this, especially when they decrease readability.

    I fully agree. These micro-optimisations should be left to the JVM.

    I change the title of the issue to deprecate the rule and then we can remove it with PMD 7.

  5. adangel
    changed the title [-][java] Is SimplifyStartsWith still relevant?[/-] [+][java] Deprecate rule SimplifyStartsWith[/+] on Jan 7, 2021
  6. adangel
    added
    is:deprecationThe main focus is deprecating public APIs or rules, eg to make them internal, or removing them
    and removed
    a:questionRequest for information that doesn't necessarily entail changes to the code base
    on Jan 7, 2021
  7. adangel
    added this to the 6.31.0 milestone on Jan 7, 2021
  8. oowekyala
    added a commit that references this issue on Jan 18, 2021

    Deprecate performance.xml/SimplifyStartsWith

    This issue will close once commit 9fe90d4 is merged into the 'main' branch.
    9fe90d4
  9. oowekyala
    linked a pull request that will close this issue[java] Deprecate some performance rules #3072on Jan 20, 2021
  10. adangel
    closed this as completedin #3072on Jan 22, 2021
  11. adangel
    closed this as completedin 9fe90d4on Jan 22, 2021
  12. adangel
    added a commit that references this issue on Jan 22, 2021

    [doc] Update release notes (pmd#2295, pmd#2740)

    635cdd7
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

    is:deprecationThe main focus is deprecating public APIs or rules, eg to make them internal, or removing them

    Type

    No type

    Projects

    No projects

      Milestone

      • 6.31.0

      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.