Comments (7)
Commenting here at the request of @Blesh.
I can't think of any concrete macro tests, but based on my measurements, perf challenges go in order of: subscribe() cost, currentThreadScheduler on synchronous producers, stack depth. In traces I've also seen a ton of AutoDetachObserver spam, but haven't been able to isolate and measure its impact since it seems cross-cutting.
With respect to subscribe, generally both on the server and client we deal with very small Observables, typically in the range of 1-10 items. That isn't to say that some other consumer won't have a firehose observable, so we should still make sure observer chains remain shallow or even collapsed via deforesting, and schedulers remain lean or even optional. However, in terms of real cases I can only speak to the significant cost of short-lived observables.
When playing with most.js, I found that while most was indeed tens of times faster than Rx for synchronous sources and operators, the following was enough to cause them to converge:
range(0, 1000).flatMap(returnValue).flatMap(returnValue).flatMap(returnValue)
Most's official flatMap tests showed a significant win because they weren't really testing flatMap/subscribe; it was a flatMap of large ranges into large ranges, which ended up being more of a benchmark of onNext, especially since synchronous sources didn't go through a scheduler at all (I don't know if that has since changed).
If we make flatMap over very small observables fast, I think the most common UI/service aggregation cases are covered. The trampolining in currentThreadScheduler is a serious perf hit though, so it's worth trying to bypass/optimize it. However, the majority of real code I've seen doesn't leverage synchronous sources nearly as often as it leverages flatMap-like operators over potentially-async sources.
I'll see if I can find some time to contribute some tests based on these observations.
from rxjs.
From RxJS meeting
Attendees: @Blesh, @trxcllnt, @steveorsomethin, @ktrott
Focus on Macro tests for places where we are creating new observables and subscribing to internal observables: zip and async ones
Macro performance will capture memory footprints: creating objects, garbage collection, etc.
TODO: Identify the list of operators that we want to focus on.
from rxjs.
Really any operator that creates objects internally such as subscriptions or observables... so for example, groupBy
creates Observables internally. flatMap
creates subscriptions internally. concat
creates subscriptions internally.
Likewise, operators that cause any buffering, like buffer
, window
, subscribeOn
, observeOn
, etc. Should probably have accompanying macro perf tests:
- flatMap
- merge
- mergeAll
- concat
- concatAll
- subscribeOn
- observeOn
- groupBy
- groupByUntil
from rxjs.
I'm unsure if Subjects should have macro perf tests. But I think multicast
might be a good idea.
Thoughts? @steveorsomethin?
from rxjs.
@Blesh It's probably wise, though designing the test is interesting. The overhead of Subject.subscribe seems minimal since it's just pushing into an observer array. Instead, I'd expect the macro bottleneck to be cases where subjects are treated as observers since Subject.onNext needs to copy its observers array every time it is invoked. Even then, that seems to only be a serious problem with large numbers of observers and firehose source observables.
from rxjs.
couple of prior arts that include Rx, might be good to see the improvement
https://github.com/spion/async-compare/ (bit out of date)
https://github.com/petkaantonov/bluebird/tree/master/benchmark (newer fork of above)
from http://spion.github.io/posts/why-i-am-switching-to-promises.html
from rxjs.
I think we've identified what we want to test for macro perf and outlined them in #100. Choosing this issue for now.
from rxjs.
Related Issues (20)
- Logo on MPM website points to a 404 HOT 2
- The async generator example in `from` crashes the browser. HOT 1
- Wrong types path HOT 3
- '.now()' is not a function error is thrown when the value of DateTimestampProvider.delegate is not valid HOT 1
- TestScheduler expectObservable not respecting subscription marbles when using toEqual
- pipe expected 0 arguments HOT 5
- Incorrect @deprecated for fromEvent overloads HOT 2
- test issue
- test issue
- rxjs.dev very often inaccessible HOT 10
- export map means node always resolves CJS HOT 7
- RxJs ships generators instead of native async/await HOT 1
- bindCallback: resultSelector destructuring callback argument if it's array HOT 1
- `every` operator sending multiple values when re-entrant HOT 1
- [email protected] has peer deps?! Oops
- ObservableInput<T> should support Thennable<T>, not PromiseLike<T> HOT 1
- Delay, timer and possibly other operators have a maximum milliseconds value, even when date is passsed HOT 1
- lost stacktrace after promise is resolved HOT 1
- Teardown and error/complete messages are out of order HOT 2
- Issue with catchError HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rxjs.