-
Notifications
You must be signed in to change notification settings - Fork 922
Speed up loading file statuses in Git commit dialog by batching events and skipping events for up-to-date files #9324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
|
@@ -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()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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)) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could the |
||
| applyChange(changedEvent); | ||
| } | ||
| } | ||
| } else if (DiffController.PROP_DIFFERENCES.equals(evt.getPropertyName())) { | ||
| // something has changed | ||
| Setup setup = currentSetup; | ||
|
|
||
There was a problem hiding this comment.
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.