JDK-8103045 : Improve performance of SortedList over FilteredList when FilteredList predicate changes
  • Type: Enhancement
  • Component: javafx
  • Sub-Component: base
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2013-10-10
  • Updated: 2015-06-16
  • Resolved: 2013-10-30
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8Fixed
Related Reports
Relates :  
Relates :  
Description
Filtering a sortedlist in a TableView with 22K rows of data is extremely slow.  It works fine with a few rows.

from javafx forum in OTN https://forums.oracle.com/thread/2589452

private final ObservableList<DataEntry> dataEntries = FXCollections.observableArrayList();
private final FilteredList<DataEntry> filteredDataEntries = new FilteredList(dataEntries);
private final SortedList sl_SortedDataEntries = new SortedList(filteredDataEntries);
private final TableView<DataEntry> dataTableView = new TableView<>();
public static RangeSlider dateRangeSlider = new RangeSlider(0,1,0,1);
 
Then, in my initialize() I set the following
 
dataTableView .setItems( sl_SortedDataEntries );
sl_SortedDataEntries.comparatorProperty().bind(dataTableView .comparatorProperty());
 
dateRangeSlider.lowValueProperty().addListener(new ChangeListener<Number>() {                                                                             >>>> I do this for both the highValueProperty as well
            @Override
            public void changed (ObservableValue<? extends Number> message, Number oldValue, Number newValue) {
                filteredDataEntries.setPredicate( p -> p.getDataEntryInstant().isAfter(Instant.ofEpochMilli(newValue.longValue()))
                        && p.getDataEntryInstant().isBefore(Instant.ofEpochMilli(dateRangeSlider.highValueProperty().longValue())));
     }
});
 
 
If I'm working on a TableView with 22K rows, I can filter the content of the TableView as desired (more or less) if I've not sorted the data.  If the data is sorted, using the slider to filter it takes forever (5-10 min) for the computation to complete.  Doing the filtering in it's own task, obviously takes care of that "app is hung" feeling but the data in the table still takes a while to refresh based on the new predicate.


Comments
Sorry to come to this bug late - for some reason my mail client didn't show me the email. I'm not sure why this is the case in TableView - it does seem odd. I would recommend filing a new bug report and I will investigate it further for a future release. At that point it would seem that Martin can then close this bug as resolved. Thanks!
30-10-2013

Yes, as we reached Zero Bug Bounce for 8.0 on 2013/10/24.
29-10-2013

Unless I'm reading this wrong looks like the fix is set for JDK 9. Is that correct?
27-10-2013

I'm not an expert on TableView, so I'm adding Jonathan to the watch list. @Jonathan - any idea what might cause the difference between ascending/descending sort?
24-10-2013

Hi Martin, looks like my delay has to do with the setCellValueFactory i'm using on the column as it is formatting the data based on another observable value. I will investigate that further separately. What I am seeing however is that sorting in Descending order takes significantly longer than Ascending order (around 5x longer). For 22K rows Asc takes roughly 1sec, Desc takes roughly 5 secs. For 150K rows Asc takes 5-6seconds while Desc takes almost 30 secs. When profiling, I see that getCellObservableValue is invoked roughly 2x times the amount of rows in Ascending, but in Descending is invoked roughly 16x times the amount of rows. Not sure if this data point is useful
24-10-2013

I used the example from the forum, which has 22000 records.
24-10-2013

How many records in the tableview you tested with? I have 22000. It works fine with 50 records.
23-10-2013

I see now the changes in SortedList in b112. However, this issue persists. I even dare say it is worse, though I can't quantify that. I will reopen this issue.
23-10-2013

I wasn't able to fully reproduce this issue, in worst case scenario the predicate change resulted in a 1sec lag. After the fix, the lags were not noticable. I don't understand why it takes such a long time in your case.
23-10-2013

No worries, I'll confirm once b112 gets out.
17-10-2013

Sorry, b111 is from Oct 10, this was pushed on Oct 14, so it's b112.
17-10-2013

Issue is still reproducible with b111. Perhaps it didn't make it in?
17-10-2013

b111 I think.
15-10-2013

What build is this issue fixed in? I can't view RT-12136 or RT-12137. I'm using jdk8 b109.
14-10-2013

Looks like there's also a problem when just sorting the list from the TableView. For each subsequent sort action it takes progressively longer to sort the data. I'm formatting the column like so timeStamp.setCellValueFactory(new PropertyValueFactory<>("dataEntryInstant")); timeStamp.setCellValueFactory(cellDataFeatures -> { Instant dataEntryInstant= cellDataFeatures.getValue().getDataEntryInstant(); return new ReadOnlyObjectWrapper<>(dataEntryInstant.toString()); });
11-10-2013