-
Notifications
You must be signed in to change notification settings - Fork 12
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
Use Emitter (or a variant) instead of Events #490
Comments
Adding developer-meeting tag to get approval for changes. It will be a beneficial refactoring for Scenery itself, and will increase performance. |
This sounds good to me. |
Consensus at 11/12/2015 design meeting - Yes, we should move forward with this. @jonathanolson will do it, and will update existing simulations to use this style once it's ready. This will also require the ability in some cases to observe when listeners are added or removed from a given emitter so that it can efficiently validate bounds. |
It looks like Emitter now gets a mandatory Tandem copy and everything from PhetioObject, so it weighs in at ~200 bytes. This probably means it is too heavyweight for event notification (since we'd want to create a whole bunch of them for every Node). Also I'll want to check how emit() re-entrance works (not just changing listeners during an emit()). |
Using a lightweight version of Emitter without all of the tandem/phet-io functionality would be great for this purpose. |
Maybe AXON/Emitter would leverage the lightweight emitter (by composition) so we don't end up duplicating code or ending up with different behavior. |
Would the new LightweightEmitter have type and predicate checking? If so, would we want this stripped out on builds (even storing those predicates), to go easy on the heap? If we do that, it could lead to a large divergence between heap size in requirejs vs built. I'd like to pursue this, but I think it would be best to synchronize efforts with @jonathanolson either through collaboration or discussion and planning. I'll put on hold for now until we get a few more sims published. |
If it would have checking, it would need to be stripped. The require.js heap usage doesn't really bug me. I haven't ever had a particular need for the type/predicate checking, particularly since in Scenery most emitters will have exactly 1 place they are emitted. |
That sounds great. |
Today as part of phetsims/axon#222 @samreid and @zepumph added |
For memory, is it possible to only provide I'm also interested in what Are there objections for moving event handling over to this? |
This does not bother me, |
I believe that is the commit e187f51 for phetsims/joist#608, unrelated to this. This allows attempting e.g. a |
Yes, it was helpful during the development. |
This is specifically because if we had e.g. 7 more Emitters per Node, this would add a large chunk of memory and take up a lot of processing time. Fields on these common types are at such a premium (especially internal fields) that the lack of flexibility (in this case for Scenery internally) is WELL worth the memory/performance effects. |
No, I'm updating the docs to "When ANY hint changes, we refresh everything currently (for safety, this may be possible to make more specific in the future, but hint changes are not particularly common performance bottleneck)." |
That is a really good question. Because we are inheriting from Node all the time, it complicates the hidden class question (so intuitively I think the minimization of Node keys might be better for performance/memory, but I haven't investigated that). Sounds like something good to test, to see what effect it would have. UPDATE from MK: see #1055 |
Looks like it does, but it was emptied in phetsims/axon@ac530d0. I'll be adding that back in. |
Constructor super was being called twice, noticed somehow in the conversion. |
Because |
I believe I've handled or responded to everything. @zepumph can you verify my changes? |
I also went back to phetsims/chipper#875 and saw that axon was a fluke, and other main.js files seemed to not be altered. |
@jonathanolson, I have gone through everything, it all looks good. Feel free to close. |
At least for Instance, but also consider Node changes.
Expecting something like
instead of
If converting Node, may need to keep in place some compatibility with the old Events API, and find places which were relying on Node "extending" Events.
The text was updated successfully, but these errors were encountered: