-
Notifications
You must be signed in to change notification settings - Fork 47.5k
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
Add helpful message about pooled classes #1664
Conversation
You could highjack the class's |
@chenglou The issue I see with overloading @spicyj Should be cleared when Althought it feels kind of icky to modify the object like this. |
@syranide It's only set in the destructor which isn't called if .persist() is. I've intentionally created the property even in prod; we try hard to avoid any observable behavioral differences between dev and prod and you could perhaps loop through the properties of an event and somehow get confused. |
👍 Anything you want to change about it @yungsters? |
This is pretty cool, looks good to me. |
Hopefully this will make fewer people confused at all of the null properties. The string won't wrap nicely so I tried to keep it pithy: https://s3.amazonaws.com/uploads.hipchat.com/6574/26709/v8vzKAC784QMkX2/upload.png
Add helpful message about pooled classes
Of course @sebmarkbage wanted some changes right after I merged. (something about deopting hidden classes) |
Well... for what it's worth, we only de-optimize the pooled objects once until the pool gets warm. |
Tips for reducing the hidden class impact here? I made an attempt to set it as soon as possible – does it need to be in the constructor instead? |
It might be possible to add it somewhere else. The problem is that I want to get rid of this pattern of adding additional properties to instances because it becomes incredibly difficult to reason about statically and around performance. It doesn't matter if we can find a case where it wouldn't deopt because it's still difficult to reason about and it still adds memory overhead in PROD. You could potentially use something like |
Reverted in 92d2dcc. |
@sebmarkbage A curious question, do we really need pooled classes for events, can there ever be more than one of the same event type in flight at any one time? |
I vaguely remember us having this discussion some where else, but I think the reasoning is that events get created a lot. If we create new SyntheticEvents all the time, I think we're going to hit GC much more frequently. |
I think what @syranide is asking is if it can just be a single global instead of pooled. Possibly. They may have different signatures though.
|
@sebmarkbage Indeed. Practically, could we replace the use of PooledClass for Synthetic*Event with say ReusedClass, that instead only holds a single reference (rather than an array). Rather off-topic, but it just came to mind when I saw this issue. |
If you call |
@spicyj Imagineable (and interesting!) and I'm not arguing for there being a lot of practical merit to my idea, but I imagine that for your scenario, spawning an additional "non-pooled" event is a non-issue, unless that is true for other events too. |
Hopefully this will make fewer people confused at all of the null properties. The string won't wrap nicely so I tried to keep it pithy:
Better suggestions appreciated.