-
Notifications
You must be signed in to change notification settings - Fork 141
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
Getter dependencies not being cached #210
Comments
Sorry, I don't see what you mean. That line triggers recursive calls to |
Having said that, I am experiencing problems where it seems that some of my getter functions are being called when no dependencies seem to have changed. |
Well, I found the source of my issue. My
Every time my component mounted,
The values are definitely being cached for me by Nuclear. |
Not sure if this is related to @henrist's reported issue, but I was running on With I'll be looking into what changed between |
That seems concerning. Let me know what you come up with and we will get a On Fri, Feb 12, 2016 at 7:55 PM, Ken Carpenter [email protected]
|
@mindjuice: Line 348 only has a real effect for the last evaluation in the evaluation "chain", as the reactorState (with new cacheValue) from the intermediate evaluations are discarded. reactorState is immutable, so it should be replaced when evaluating each dependency (line 343), but it is not? |
Minor update. version I'll continue to look into this as time permits today. Not sure yet if the issue reported by @henrist is related, but could certainly be the same thing. |
Sorry, I haven't had a chance to look at this again yet. Side note: I'm in SF all week and just drove by your head office (which made me feel guilty about not having time to look into this yet). Looks like a nice office! It's only a few blocks away from the Arista Networks office (near Twitter at Market and Polk). |
Ah no way, let me know if you want to come by and chat. Shoot me an email @ [email protected] On Tuesday, February 16, 2016, Ken Carpenter [email protected]
|
A bit more investigation last night. I found that the entries seem to be getting cached properly, but the code that checks if
Going to keep looking into this, but wanted to post this in case it gives anyone an idea of either what my code could be doing wrong or what the bug might be if it's in Nuclear itself. |
Had a chat with Jordan today about this. Pretty sure the issue (in my case at least -- sorry for hijacking @henrist's issue) is the new When I trigger an action that updates a field of a store, say the field As I discussed with Jordan, I don't think that checking if the store changed to decide if the getters need to be rerun makes sense. The top level store reference can change, but still internally reference (at least some of) the same sub-objects as the previous version of the store. That's a benefit of ImmutableJS' structural sharing/persistent data structures. When checking dependencies for getter functions in For now I will stick with Let me know if you have any thoughts on the above or if you think I am totally wrong. |
@mindjuice Not needing to check |
@loganlinn Oh? How so? You're already caching the last result from each getter, right? When it changes, you replace that reference with the new one, thereby making the old one eligible for garbage collection. |
@mindjuice In addition to a reference to the previous evaluation result, you also need to hold reference to each dependency of getter. But on second thought, it shouldn't be an issue if done carefully. |
Anyone find a good workaround for this issue? |
When evaluating dependencies, the new reactorState from these evaluations are being discarded, causing the updated cache to also be discarded. This causes a cache miss each time the dependency getter is being used, e.g. by other getters, even though no data has changed.
This should be obvious by looking at this line:
nuclear-js/src/reactor/fns.js
Line 343 in 1444ce6
The text was updated successfully, but these errors were encountered: