Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions ide/git/src/org/netbeans/modules/git/FileStatusCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
public class FileStatusCache {

public static final String PROP_FILE_STATUS_CHANGED = "status.changed"; // NOI18N
public static final String PROP_FILES_STATUS_CHANGED = "status.changed.batch"; // NOI18N

private final CacheIndex conflictedFiles, modifiedFiles, ignoredFiles;
private static final Logger LOG = Logger.getLogger("org.netbeans.modules.git.status.cache"); //NOI18N
Expand Down Expand Up @@ -562,6 +563,7 @@ private void refreshStatusesBatch (Map<File, GitStatus> interestingFiles) {
boolean fireEvent = true;
current = getInfo(file);
fi = checkForIgnore(fi, current, file);
boolean upToDateOnFirstLoad = current == null && fi.getStatus().equals(EnumSet.of(Status.UPTODATE));
if (equivalent(fi, current)) {
// no need to fire an event
if (Utilities.isWindows() || Utilities.isMac()) {
Expand All @@ -570,6 +572,10 @@ private void refreshStatusesBatch (Map<File, GitStatus> interestingFiles) {
} else {
continue;
}
} else if (upToDateOnFirstLoad) {
// file is up-to-date and not yet in cache: UPTODATE is the implicit default,
// no cache update or event needed
continue;
}
boolean addToIndex = updateCachedValue(fi, file);
indexUpdates.add(new IndexUpdateItem(file, fi, addToIndex));
Expand All @@ -579,8 +585,8 @@ private void refreshStatusesBatch (Map<File, GitStatus> interestingFiles) {
}
updateIndexBatch(indexUpdates);
}
for (ChangedEvent event : events) {
fireFileStatusChanged(event);
if (!events.isEmpty()) {
listenerSupport.firePropertyChange(PROP_FILES_STATUS_CHANGED, null, events);
Comment on lines -582 to +589
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.

good catch. aggregating events can certainly reduce overhead under load. Reminds me a little on #8955 where I saw 1.5mil event handler invocations when a large project group opened.

}
}

Expand Down
9 changes: 9 additions & 0 deletions ide/git/src/org/netbeans/modules/git/GitVCS.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import java.beans.PropertyChangeListener;
import java.util.MissingResourceException;
import java.io.File;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.logging.Logger;
import java.util.prefs.PreferenceChangeEvent;
Expand Down Expand Up @@ -111,6 +113,13 @@ public void propertyChange(PropertyChangeEvent event) {
if (event.getPropertyName().equals(FileStatusCache.PROP_FILE_STATUS_CHANGED)) {
FileStatusCache.ChangedEvent changedEvent = (FileStatusCache.ChangedEvent) event.getNewValue();
fireStatusChanged(changedEvent.getFile());
} else if (event.getPropertyName().equals(FileStatusCache.PROP_FILES_STATUS_CHANGED)) {
List<FileStatusCache.ChangedEvent> changedEvents = (List<FileStatusCache.ChangedEvent>) event.getNewValue();
Set<File> files = new HashSet<>(changedEvents.size());
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.

this is super nitpicky. but the constructor arg isn't for the element count, it is to size the internal table - which sometimes leads to initial sizes which are too small.

if you want you can bump the module to javac.release=21 (see project.properties) and then use the HashSet.newHashSet(numElements) factory which does some math before setting the size of the internal table.

feel free to update the commit and force push in place.

for (FileStatusCache.ChangedEvent e : changedEvents) {
files.add(e.getFile());
}
fireStatusChanged(files);
} else if (event.getPropertyName().equals(Git.PROP_ANNOTATIONS_CHANGED)) {
fireAnnotationsChanged((Set<File>) event.getNewValue());
} else if (event.getPropertyName().equals(Git.PROP_VERSIONED_FILES_CHANGED)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1123,15 +1123,24 @@ public void propertyChange (PropertyChangeEvent evt) {
if (FileStatusCache.PROP_FILE_STATUS_CHANGED.equals(evt.getPropertyName())) {
FileStatusCache.ChangedEvent changedEvent = (FileStatusCache.ChangedEvent) evt.getNewValue();
if (LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, "File status for file {0} changed from {1} to {2}", new Object[] {
changedEvent.getFile(),
LOG.log(Level.FINE, "File status for file {0} changed from {1} to {2}", new Object[] {
changedEvent.getFile(),
changedEvent.getOldInfo(),
changedEvent.getNewInfo() } );
}
if (revisionLeft == Revision.HEAD // remove when we're able to refresh single file changes for Local vs. any revision
if (revisionLeft == Revision.HEAD // remove when we're able to refresh single file changes for Local vs. any revision
&& revisionRight == Revision.LOCAL && affectsView(changedEvent)) {
applyChange(changedEvent);
}
} else if (FileStatusCache.PROP_FILES_STATUS_CHANGED.equals(evt.getPropertyName())) {
@SuppressWarnings("unchecked")
List<FileStatusCache.ChangedEvent> changedEvents = (List<FileStatusCache.ChangedEvent>) evt.getNewValue();
for (FileStatusCache.ChangedEvent changedEvent : changedEvents) {
if (revisionLeft == Revision.HEAD // remove when we're able to refresh single file changes for Local vs. any revision
&& revisionRight == Revision.LOCAL && affectsView(changedEvent)) {
Comment on lines +1138 to +1140
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.

could the revisionLeft/Right check be moved before the loop?

applyChange(changedEvent);
}
}
} else if (DiffController.PROP_DIFFERENCES.equals(evt.getPropertyName())) {
// something has changed
Setup setup = currentSetup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,14 @@ public void propertyChange (PropertyChangeEvent evt) {
if (affectsView((FileStatusCache.ChangedEvent) evt.getNewValue())) {
applyChange(changedEvent);
}
} else if (FileStatusCache.PROP_FILES_STATUS_CHANGED.equals(evt.getPropertyName())) {
@SuppressWarnings("unchecked")
List<FileStatusCache.ChangedEvent> changedEvents = (List<FileStatusCache.ChangedEvent>) evt.getNewValue();
for (FileStatusCache.ChangedEvent changedEvent : changedEvents) {
if (affectsView(changedEvent)) {
applyChange(changedEvent);
}
}
}
}

Expand Down
Loading