-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Description
RxJS version:
5.0.0-rc1
Code to reproduce:
Create a distinct observable with 100k unique items, it will progressively get slower as internally a serial search for the item is used.
var rx = require("rxjs/Rx");
var s = new rx.Subject();
s.distinct()
.count()
.subscribe((n) => {
console.log(n);
});
for (var i = 0; i < 100000; i++) {
s.next(i);
}
s.complete();
Expected behavior:
This code should finish under 1 second.
Actual behavior:
This code takes minutes to run.
Additional information:
The internals of distinct
needs to utilize a set to determine if the item has already been observed. The serial search will not scale. I stumbled upon this issue by not fully understanding how distinct
worked.
Metadata
Metadata
Assignees
Labels
No labels