-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Map transducing #1323
Map transducing #1323
Conversation
attn @trxcllnt (for sanity). attn @benjamingr, @robwormald and @jeffbcross as this relates to discussion in https://github.com/angular/http/issues/56. |
Awesome! Thanks so much for exploring this, %20 performance boost for map operators collapsing sounds like a useful optimization. What about Optimally this optimization for single subscriber is something that should be done more generally. |
@benjamingr if this PR passes the smell test then Another possibility is collapsing resultSelectors from operators like |
In the case of |
@Blesh Did you see if there is any significant change in performance when |
@luisgabriel I did not... but the map perf test was already chaining them. Given that it's really just a quick assertion at the moment |
@luisgabriel looking at the source code change - when no chain collapsing is performed the same path is hit - it should perform exactly the same. I'm not sure if these two extra variables are needed but realistically the runtime can take care of that for us. |
@Blesh is there a method we can add to the |
@trxcllnt definitely. Perhaps |
@Blesh It could, but don't the operators need to know about each other? I'm thinking something like: export function map(project) {
return this.lift(this.operator.transduce(new MapOperator(project)));
} And the class Operator {
call(subscriber) { return subscriber; }
transduce(operator) {
return operator; // return the operator we were given if we can't collapse it with ourself.
}
} |
@Blesh though I'm not sure about how much I like the word |
+1 for collapse but for the opposite reason, transduce is well understood enough to trigger bikeshed later on. |
@Blesh @benjamingr Hmm. Makes sense. |
Looking at this design, I think it falls apart a bit with operators like |
Ping @Blesh status? |
@benjamingr I've been working on other things, but there's a new design in the works for this that (hopefully) will be able to collapse almost all sync map-type operations in a chain. |
@Blesh Is there an issue where you're discussing/tracking this? |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
As a PoC, I've implemented transducing on map!
In this PR:
map().mergeAll()
will flatten to.mergeMap()
via magic. This results in about a 20% perf improvement over using.map().mergeAll()
prior to this commit, and is ~15x faster than .map().mergeAll() in Rx4.While I think we can land this here in master, this is a PoC to see what needs to be done.
One thing I learned while working on this is the
thisArg
makes creating this a little uncomfortable. As if I needed another reason to hate thethisArg
s.