Repository navigation
Sort same-nested projects by display name - #9834
Conversation
jtulach
commented
Nov 28, 2026
- fixes Make projects view "sort by path" optional #9813 ...
- ... while keeping the nesting of projects on
- as a result the Apache Maven deep project hierarchy still sorts properly nested
- while NetBeans sorts alphabetically as there is no nesting among the projects (yet - pending Nesting Projects by their Cluster #9624 or co.)
- CCing @mclaborn, @neilcsmith-net, @ramiswailem as those who commented on Make projects view "sort by path" optional #9813
| var children = parentship.get(parent); | ||
| if (children == null) { | ||
| children = new TreeSet<>(byProjectDisplayName); | ||
| parentship.put(parent, children); | ||
| } | ||
| children.add(info); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
- 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
There was a problem hiding this comment.
parentship.computeIfAbsent(parent, k -> new TreeSet<>(byProjectDisplayName))
.add(info);There was a problem hiding this comment.
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
computeIfAbsentmethod accepts a lambda- lambda is handled via
LambdaMetaFactoryand 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
- lambda is handled via
- as far as peak performance (the top most speed after all JIT compilations are done)...
- then it is very likely the
computeIfAbsentwill be on par with my plainifcode - current JIT compilers are pretty good at inlining and can "crack the lambda"
- however inspecting the compiler graph will show a huge difference:
- while
ifversion is a small graph with nodes representing 1:1 the Java code - the
computeIfAbsentgraph 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
computeIfAbsentapproach - e.g. the time to get to the peak performance is longer in
computeIfAbsentcase
- while
- then it is very likely the
- moreover the run in interpreter (needed before the JIT compilation is over) is fully depending on the amount of code
- here the plain
ifvariant clearly outperforms the ... - lambda approach (with the behind the scene generated byte code lambda class)
- here the plain
computeIfAbstractis slower to get to top speed and even then it is on par with plainifsolution!
...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.
There was a problem hiding this comment.
... 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).
There was a problem hiding this comment.
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.
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.
1191e97 to
39e29d1
Compare
|
eppleton
left a comment
There was a problem hiding this comment.
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.
1de837c to
f699caa
Compare
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. |
Thanks. I assumed that when merging.
I have commented on the performant aspect here. |
|
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?
I commented on the performance bit elsewhere too, but why mention Claude specifically on here? |
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.
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):
Avoid Gnome TrapWe 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. |
|
@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! 😉 |
|
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? |
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. Gnome today are Gnome + 3 forks (Cinnamon, MATE, Budgie, ..). Each of them happened when the pendulum swung.
+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 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
same, but its one of the forks in my case. (+ I am too lazy to switch to something else, it works great) |
@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. |