Skip to content

Sort same-nested projects by display name - #9834

Merged
jtulach merged 1 commit into
apache:masterfrom
jtulach:jtulach/SortByNameWhenNotNested
Nov 29, 2026
Merged

jtulach merged 1 commit into
apache:masterfrom
jtulach:jtulach/SortByNameWhenNotNested

Conversation

@jtulach

@jtulach jtulach commented Nov 28, 2026

Copy link
Copy Markdown
Contributor
Nested Maven Alphabetical NetBeans

@eppleton eppleton left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, keeping the nesting and sorting siblings by name is a nice way to fix #9813. From reading the code (I haven't run it), there is one real problem and two smaller points; details inline.

Comment on lines +130 to +135
var children = parentship.get(parent);
if (children == null) {
children = new TreeSet<>(byProjectDisplayName);
parentship.put(parent, children);
}
children.add(info);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like parentship.computeIfAbsent(...).add(...) from the distance

if you like using jackpot hints, there is a rule for that somewhere in https://github.com/mbien/jackpot-inspections.

@jtulach jtulach Nov 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I tried to use the “lambda style”, but then resorted back to old good if…
  • the old style isn't slower and I can read it just fine

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

            parentship.computeIfAbsent(parent, k -> new TreeSet<>(byProjectDisplayName))
                      .add(info);

@jtulach jtulach Nov 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if @mbien requires use of computeIfAbsent, I'll do it. Otherwise I stick with old good if

obviously I don't require that. its just more concise and more performant.

  • my reply is built on 10+ years of working on JVM compilers
  • the computeIfAbsent method accepts a lambda
    • lambda is handled via LambdaMetaFactory and involves ...
    • ... bytecode generation during first execution
    • that's a lot of work
    • btw. it is well known that JDK8 was 30% slower on startup than JDK7
      • that was due to this bytecode generation ...
      • ... that regression couldn't be fixed and at the end ...
      • ... the startup regression had to be mitigated by other speedups
  • as far as peak performance (the top most speed after all JIT compilations are done)...
    • then it is very likely the computeIfAbsent will be on par with my plain if code
    • current JIT compilers are pretty good at inlining and can "crack the lambda"
    • however inspecting the compiler graph will show a huge difference:
      • while if version is a small graph with nodes representing 1:1 the Java code
      • the computeIfAbsent graph is going to be much bigger than its Java code would indicate
        • as it has to inline all the libraries up to the lambda callback
      • hence the time spend in the JIT compiler will be different and certainly not in favor of computeIfAbsent approach
      • e.g. the time to get to the peak performance is longer in computeIfAbsent case
  • moreover the run in interpreter (needed before the JIT compilation is over) is fully depending on the amount of code
    • here the plain if variant clearly outperforms the ...
    • lambda approach (with the behind the scene generated byte code lambda class)
  • computeIfAbstract is slower to get to top speed and even then it is on par with plain if solution!

...more performant...

So, @mbien, there is no performance aspect I can think of where the computeIfAbsent variant would be more performant. If we want to be sure, we can perform some (JMH) benchmarking, but I bet tuple of beer, that my claims are accurate.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... there is no performance aspect I can think of where the computeIfAbsent variant would be more performant.

Very expensive hash code! 😆 There's certainly potential for performance improvement when other operations can be optimized or short-circuited. There's certainly no hard and fast rule either way without contextual information.

TL;DR - Merged code looks fine to me. (aside from var which makes reviewing harder).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my reply is built on 10+ years of working on JVM compilers

your reply to my code simplification comment was, and i quote:

I tried to use the “lambda style”, but then resorted back to old good if…

thats it. I could guess what this meant but tbh I didn't really know. It sounded like you tried to implement it but then something happened and you reverted - i have no crystal ball. I pasted a snippet and tried again. You edited the post afterwards.

image

This clarifies your comment. You don't care about code simplifications as long you can still read it.

Regarding performance: firstly this was not the reason I posted the comment, secondly: benchmarking this in a micro benchmark is almost pointless here since the situation changes based on how the hash code is computed, if the lambda actually captures anything and what path is actually the hot path (e.g in caches data wouldn't be absent anymore after a while). But I actually collect JMH benchmarks, so if you come up with one for Maps which I don't have yet, please share.

@jtulach
jtulach force-pushed the jtulach/SortByNameWhenNotNested branch from 1191e97 to 39e29d1 Compare November 29, 2026 05:54
@jtulach
jtulach requested a review from mbien November 29, 2026 06:12
@jtulach

jtulach commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author
  • consider this done, please review
  • if I get approvals I squash and integrate
  • if @mbien requires use of computeIfAbsent, I'll do it. Otherwise I stick with old good if

@eppleton eppleton left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, all three points are resolved in 39e29d1: equal display names now fall back to the path order (and testDuplicatedNames covers it), the comparison uses Collator with cached names again, and the imports are gone. Tiny nit, no need to change it before merging: in the n2 == null branch the warning logs i1.project(), while the original comparator logged the project whose name is null (p2). Approving.

@jtulach
jtulach force-pushed the jtulach/SortByNameWhenNotNested branch from 1de837c to f699caa Compare November 29, 2026 15:52
@jtulach

jtulach commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

in the n2 == null branch the warning logs i1.project(),

@jtulach
jtulach merged commit df6bd37 into apache:master Nov 29, 2026
29 checks passed
@jtulach jtulach added this to the NB33 milestone Nov 29, 2026
@mbien

mbien commented Nov 29, 2026

Copy link
Copy Markdown
Member

if @mbien requires use of computeIfAbsent, I'll do it. Otherwise I stick with old good if

obviously I don't require that. its just more concise and more performant. I only mentioned it since claude typically doesn't pick up on things like that. Maybe it will generate review comments for it one day once it was fed more modern java code, but even if it is: LLMs adapt to the codebase, so it might already know better but decide to not bring it up.

@jtulach

jtulach commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

obviously I don't require that.

Thanks. I assumed that when merging.

...more concise and more performant ...

I have commented on the performant aspect here.

@neilcsmith-net

neilcsmith-net commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Does this actually make the sort-by-path optional as the issue stated?! I'm not happy that we've gone from discussion of options for sorting, to no-one needs options other than path as display name sorting is a bug (NB32), to actually, path was a bug let's go back to display names (NB33?)

I'll reiterate something I said on an earlier change around this - we care too much about API compatibility, and too little about behavioural compatibility, for both end users and platform developers. The fact that this change would cause friction was obvious, and we've only just released. Who'd have thought faking a tree in a tree could become a problem?! This change is probably the right compromise now (at least fine for my use cases), but can we please not change fundamentals people have built around without switches in future?

its just more concise and more performant. I only mentioned it since claude typically doesn't pick up on things like that.

I commented on the performance bit elsewhere too, but why mention Claude specifically on here?

@jtulach

jtulach commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

This change is probably the right compromise now (at least fine for my use cases),

It is good to hear we are approaching the right compromise and sorry for making the "waves". Hopefully the NBM offered here is an acceptable mitigation of the necessary ripples.

but can we please not change fundamentals people have built around without switches in future?

If we followed that path, we'd never get to the current compromise! Let me quote some of the twenty years old thoughts:

The Core Philosophy: "Swing the Pendulum"

In open-source UX, developers noticed a common trap: people rarely give feedback on incremental changes or theoretical mockups, nor do they complain until a change breaks their muscle memory. If a designer proposed a modest compromise upfront, nobody tested it seriously, or the design got watered down by bikeshedding before anyone even used it.

Instead, several GNOME designers and maintainers defended a "pendulum" or "shock-the-system" approach during odd-numbered unstable releases (like GNOME 2.5, 2.7, and 2.9):

  • Why make a radical change first. Pushing a bold, uncompromised version of a new design into an early unstable snapshot forced testers and early adopters to actually experience the new workflow rather than debating it in the abstract.
  • Generating high-signal feedback. A radical change immediately exposed real-world edge cases, missing workflows, and genuine pain points—separating knee-jerk resistance to change from actual functional blockers.
  • Moderating for the final release. Once the real pain points surfaced during the development cycle, developers could selectively add back essential affordances or soften the behavior before the UI freeze, resulting in a cleaner, better-tested compromise than if they had started timidly.

Avoid Gnome Trap

We all know where gnome ended up, right? Thus I am sorry for creating the ripples. Let's hope the final outcome (represented by this PR) worth it. I am sorry I couldn't come up with this design before making NetBeans 32, but the user feedback was essential. Without it I wouldn't be able to make the next step.

@neilcsmith-net

neilcsmith-net commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

@jtulach nothing wrong with swinging the pendulum if you provide opt-outs to revert to previous behaviour in releases. Not necessarily in UI, but somewhere that's accessible to users and platform devs. We've done this multiple times with major changes and should try to do so in future.

And GNOME remains my desktop of choice! 😉

@mclaborn

Copy link
Copy Markdown

My $0.02 (prefaced by the fact that I am ignorant of the change management process): The whole process feels very netbeans-developer-focused rather than netbeans-user-focused. Is there any step in the decision making process that gathers user input? If I had been asked I would certainly have voted vigorously against any mandatory change in the current sorting.

@jtulach you mentioned above "necessary ripples". What makes any changes here "necessary"? How is that determination made?

@mbien

mbien commented Nov 30, 2026

Copy link
Copy Markdown
Member

GNOME

the fun thing about gnome is that you can pick a gnome lesson and take it in any direction. Just because gnome shell didn't kill gnome does not mean everyone should try the same approach of rolling out features. <insert survivor bias story>

Gnome today are Gnome + 3 forks (Cinnamon, MATE, Budgie, ..). Each of them happened when the pendulum swung.

nothing wrong with swinging the pendulum if you provide opt-outs to revert to previous behaviour in releases.

+1 I remember updating gnome a few days before a seminar and it moved the window close button from right to left (that was a long time ago, before gnome shell). There was no option to change it back (it was added weeks later). Choices like that already caused some backslash but yet gnome shell happened which triggered an exodus - it took a while till it recovered.

I commented on the performance bit elsewhere too, but why mention Claude specifically on here?

I could have said LLM I suppose but I risked it since I think i am still pretty good at distinguishing some of the larger models (but it is getting harder since they converge). Let me try again: LLMs when asked to review PRs (and this PR was already reviewed by one when i looked at it), will generally not comment on things they already see in surrounding code. They assume that this got triaged and omit the comment - unless you explicitly ask. (that is also how they format code btw, they look at sibling files). That is esp true for repos without AGENTS.md. Thats why I left the computeIfAbsent simplification comment which the LLM review didn't pick up on since some of the code in the codebase is still barely java 5 (see generics cleanup PRs etc).

And GNOME remains my desktop of choice! 😉

same, but its one of the forks in my case. (+ I am too lazy to switch to something else, it works great)

@neilcsmith-net

Copy link
Copy Markdown
Member

The whole process feels very netbeans-developer-focused rather than netbeans-user-focused. Is there any step in the decision making process that gathers user input?

@mclaborn there is at least 3 weeks of release candidates that offers some chance to get this input before release each quarter. Although we suffered from FoAN failing to provide installers for these, which meant we had maybe 500 less end user testers for NB32.

Other than that, the best thing is to push such changes to users in releases, as long as there's opt out. We're a small team of volunteer maintainers, so big user input exercises are not really feasible. And we're all users, too - jump on the dev@ list and take part in discussions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make projects view "sort by path" optional

5 participants