Skip to content
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.

Fix the eval component cache #629

Merged
merged 8 commits into from Oct 24, 2014

Conversation

mdekstrand
Copy link
Member

The eval component cache wasn't instantiating components when it wasn't in heavy use, totally messing up the build vs. eval phase distinctions.

@kluver, this may also have been causing the caching problems experienced by the MovieLens team.

@mdekstrand mdekstrand added this to the 2.2 milestone Oct 21, 2014
@@ -122,18 +123,7 @@ public void registerSharedNodes(Iterable<DAGNode<Component, Dependency>> nodes)
* @param node A node that should be cached.
*/
public void registerSharedNode(DAGNode<Component, Dependency> node) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as this is a convienace method wrapper anyways, why not make it varagrs?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose there isn't a good reason not to, although this method is very rarely used.

@mdekstrand
Copy link
Member Author

Newest changes (dfad719) should make it pass the tests.

@@ -161,7 +151,7 @@ Object instantiate(@Nonnull DAGNode<Component, Dependency> node) throws Injectio
entry = cache.get(original);
}
if (entry == null) {
return node;
entry = new CacheEntry(node);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to check if I understand the impact of this correctly, as this seems to be the important change:

There appear to be two code paths for object sharing through this class. The first uses the register node functions to explicitly ask for cacheing. This does exactly what it says on the tin. (where does this code path get used?)

The second code path is done by asking it to process a graph (or set of nodes) in the past if those nodes were not registered previously you did nothing. (just returned the nodes unmodified). This code change allows these nodes to go through CacheEntries attempted instantiation (if necissary) (where were these nodes otherwise being instantiated if they wern't being instantiated here?)
By doing this you 1) have to make a throwaway cache entry which feels a little weird because it isn't actually entered into the cache from what I can tell
and 2) get to try to load the object from disk in case the only sharing happens between executions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct.

Previously, the no-op meant that the node did not get instantiated until test time, since the only build-time instantiation happened through the cache. The cache's interface is kind of broken, but this dummy entry hack lets it actually instantiate nodes so that build-time is really build-time.

There might be an issue here with undesired saving-to-disk. Things should only be saved to disk if they were registered.

@kluver
Copy link
Contributor

kluver commented Oct 23, 2014

Before reviewing it I probably should have checked: did you want a code review here?

@mdekstrand mdekstrand force-pushed the feature/elehack-fix-eval-cache branch from dfad719 to 678e35b Compare October 24, 2014 17:24
@mdekstrand
Copy link
Member Author

I have updated this pull request to fix the little issues, and to not include the fast iteration changes.

@kluver
Copy link
Contributor

kluver commented Oct 24, 2014

Im probably not going to be able to look at this more until monday.

@mdekstrand
Copy link
Member Author

@kluver That's fine. I think I've addressed your concerns, albeit with another ugly hack to fix the problem with my ugly hack. Since tests now pass, I think I'll go ahead and merge (unless you protest).

mdekstrand added a commit that referenced this pull request Oct 24, 2014
Fix the eval component cache and some other improvements.
@mdekstrand mdekstrand merged commit fb3aec9 into lenskit:master Oct 24, 2014
@mdekstrand mdekstrand deleted the feature/elehack-fix-eval-cache branch October 24, 2014 19:55
@mdekstrand mdekstrand restored the feature/elehack-fix-eval-cache branch October 24, 2014 22:57
@mdekstrand mdekstrand deleted the feature/elehack-fix-eval-cache branch October 24, 2014 22:58
mdekstrand pushed a commit to lenskit/lenskit.github.io that referenced this pull request Feb 10, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants