You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "OndroMih (via GitHub)" <gi...@apache.org> on 2026/03/28 17:57:13 UTC
[PR] Git: Speed up displaying branches in Select Revision dialog from Cherry pick [netbeans]
OndroMih opened a new pull request, #9305:
URL: https://github.com/apache/netbeans/pull/9305
Defer branch merge status computation in Select Revision dialog
When the Select Revision dialog is opened from Cherry Pick, the branchMergeWith field is set, causing getCommonAncestor() to be called for every branch (120+) before nodes are shown. This blocks the single-threaded RepositoryPanel RequestProcessor for ~10 seconds.
Move the getCommonAncestor loop out of refreshBranches() into a separate background task (computeMergeStatuses) that runs after nodes are already displayed. Nodes initially show with null merge status and are updated incrementally as results arrive via updateBranchMergeStatus/ updateMergeStatus. When a branch node is selected and its merge status is still pending, trigger an immediate single-branch lookup.
### To test:
On Netbeans repository, select Cherry Pick dialog, then click Select Revision.
Old behavior: It takes a few seconds until the branches and tags are displayed (because the merge status is being computed)
New behavior: Branches and tags are displayed immediately, with [merge ? ] behind the name, merge status is computed in the background, and then [merge ? ] is either removed (not merged) or replaced with [merged].
### PR approval and merge checklist:
1. [ ] Was this PR [correctly labeled](https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=240884239#PRsandYouAreviewerGuide-PRtriggeredCIJobs(conditionalCIpipeline)), did the right tests run? When did they run?
2. [ ] Is this PR [squashed](https://cwiki.apache.org/confluence/display/NETBEANS/git%3A+squash+and+merge)?
3. [ ] Are author name / email address correct? Are [co-authors](https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/creating-a-commit-with-multiple-authors#creating-co-authored-commits-on-the-command-line) correctly listed? Do the commit messages need updates?
3. [ ] Does the PR title and description still fit after the Nth iteration? Is the description sufficient to appear in the release notes?
If this PR targets the delivery branch: [don't merge](https://cwiki.apache.org/confluence/display/NETBEANS/Pull+requests+for+delivery). ([full wiki article](https://cwiki.apache.org/confluence/display/NETBEANS/PRs+and+You+-+A+reviewer+Guide))
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Git: Speed up displaying branches in Select Revision dialog from Cherry pick [netbeans]
Posted by "OndroMih (via GitHub)" <gi...@apache.org>.
OndroMih commented on PR #9305:
URL: https://github.com/apache/netbeans/pull/9305#issuecomment-4440314541
Thanks for reviewing, @matthiasblaesing , your comments make sense. When I get to it, I'll review the code once again, I see some potential improvements and cleanup even beyond what you commented.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Git: Speed up displaying branches in Select Revision dialog from Cherry pick [netbeans]
Posted by "matthiasblaesing (via GitHub)" <gi...@apache.org>.
matthiasblaesing commented on code in PR #9305:
URL: https://github.com/apache/netbeans/pull/9305#discussion_r3213709384
##########
ide/git/src/org/netbeans/modules/git/ui/repository/RepositoryBrowserPanel.java:
##########
@@ -339,6 +341,38 @@ private File lookupRepository (Node selectedNode) {
return selectedNode == null ? null : ((RepositoryNode) selectedNode).getRepository();
}
+ private void computeMergeStatusForSelectedNodeIfNotComputedYet () {
+ if (branchMergeWith == null || getExplorerManager().getSelectedNodes().length != 1) {
+ return;
+ }
+ Node selectedNode = getExplorerManager().getSelectedNodes()[0];
+ if (!(selectedNode instanceof BranchNode)) {
+ return;
+ }
+ final BranchNode branchNode = (BranchNode) selectedNode;
+ if (branchNode.mergeStatus != null) {
+ return;
+ }
+ final String mergeWith = branchMergeWith;
+ final String branchName = branchNode.branchName;
+ // Walk up to BranchesTopChildren via parent chain
+ Node parent = branchNode.getParentNode();
+ if (parent != null) {
+ parent = parent.getParentNode();
+ }
Review Comment:
Shouldn't this be a loop? Else you only go one level up.
##########
ide/git/src/org/netbeans/modules/git/ui/repository/RepositoryBrowserPanel.java:
##########
@@ -924,6 +943,64 @@ && equalTracking(newBranchInfo, e.getValue().branch))) {
if (remote != null) {
remote.refresh();
}
+ // Compute merge status in a separate task so node population is not blocked.
+ if (branchMergeWith != null) {
+ final String mergeWith = branchMergeWith;
+ final java.util.Map<String, String> snapshot = new HashMap<String, String>();
+ for (java.util.Map.Entry<String, GitBranchInfo> e : BranchesTopChildren.this.branches.entrySet()) {
+ snapshot.put(e.getKey(), e.getValue().branch.getId());
+ }
+ RP.post(() -> computeMergeStatuses(snapshot, mergeWith));
+ }
+ }
+
+ private void computeMergeStatuses (java.util.Map<String, String> snapshot, String mergeWith) {
+ GitClient client = null;
+ try {
+ client = Git.getInstance().getClient(repository);
+ for (java.util.Map.Entry<String, String> e : snapshot.entrySet()) {
+ GitRevisionInfo commonAncestor = client.getCommonAncestor(
+ new String[] { mergeWith, e.getValue() },
+ GitUtils.NULL_PROGRESS_MONITOR);
+ boolean merged = commonAncestor != null
+ && commonAncestor.getRevision().equals(e.getValue());
+ updateBranchMergeStatus(e.getKey(), merged);
+ }
+ } catch (GitException ex) {
+ LOG.log(Level.INFO, null, ex);
+ } finally {
+ if (client != null) {
+ client.release();
+ }
+ }
+ }
+
+ void computeSingleMergeStatus (String branchName, String mergeWith) {
+ GitBranchInfo info = BranchesTopChildren.this.branches.get(branchName);
+ if (info == null) {
+ return;
+ }
+ java.util.Map<String, String> single = new HashMap<String, String>();
+ single.put(branchName, info.branch.getId());
Review Comment:
Use `Map#of`?
##########
ide/git/src/org/netbeans/modules/git/ui/repository/RepositoryBrowserPanel.java:
##########
@@ -307,13 +307,15 @@ public void propertyChange (PropertyChangeEvent evt) {
currRevision = selectedNode.getLookup().lookup(Revision.class);
currRepository = lookupRepository(selectedNode);
}
- if ((currRevision != null || oldRevision != null) && !(currRevision != null && oldRevision != null
+ if ((currRevision != null || oldRevision != null) && !(currRevision != null && oldRevision != null
&& currRevision.equals(oldRevision))) {
firePropertyChange(PROP_REVISION_CHANGED, oldRevision, currRevision);
}
if (options.contains(Option.DISPLAY_REVISIONS) && currRevision != null) {
revisionsPanel1.updateHistory(currRepository, roots, currRevision);
}
+ // If a branch node with pending merge status is selected, compute it immediately.
+ computeMergeStatusForSelectedNodeIfNotComputedYet();
Review Comment:
This does not work for me. If I see it correctly in may case (git checkout of netbeans with all PR branches) the `RequestProcessor` `RP` has a throughput of 1 and that one place is blocked by the initial merge status determination (`computeMergeStatuses`).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Git: Speed up displaying branches in Select Revision dialog from Cherry pick [netbeans]
Posted by "OndroMih (via GitHub)" <gi...@apache.org>.
OndroMih commented on PR #9305:
URL: https://github.com/apache/netbeans/pull/9305#issuecomment-6099598049
Thank you, @matthiasblaesing . I had no time to move this forward.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Git: Speed up displaying branches in Select Revision dialog from Cherry pick [netbeans]
Posted by "matthiasblaesing (via GitHub)" <gi...@apache.org>.
matthiasblaesing commented on PR #9305:
URL: https://github.com/apache/netbeans/pull/9305#issuecomment-6099575137
@OndroMih NB32 freeze is nearing. As there was no activity on this I'll remove the milestone, feel free to update and readd it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists