Skip to content
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

Make lazy evaluation even faster #906

Closed
cdmihai opened this issue Aug 16, 2016 · 3 comments
Closed

Make lazy evaluation even faster #906

cdmihai opened this issue Aug 16, 2016 · 3 comments

Comments

@cdmihai
Copy link
Contributor

cdmihai commented Aug 16, 2016

There are a couple of optimizations that we can still do on the lazy item evaluator:

@dsplaisted
Copy link
Member

dsplaisted commented Aug 16, 2016

Continuing the discussion from here: #891 (comment)

Hmm, even then, the cache would be per LazyItemList instance. For example, the lists representing [include] and [include;update] would have 2 different GetItems caches because they are 2 objects. So another item pointing to the first list would not get affected by subsequent operations, since those would be in different lazylist objects.

Using your sample, there are three LazyItemLists. We can call the first one i2_1, and it is produced by this:

<i2 Include='a;b;c'>
    <m1>m1_contents</m1>
    <m2>m2_contents</m2>
</i2>

Then we have i, which simply copies the contents of i2_1:

<i Include='@(i2)'/>

Then we have i2_2, which modifies the metadata for the items coming from i2_1:

<i2 Update='a;b;c'>
    <m1>m1_updated</m1>
    <m2>m2_updated</m2>
</i2>

Your comment seems to refer to the fact that i and i2_2 are separate objects with separate caches. That is true, but they both refer to i2_1, which is a single instance. So when i is evaluated, it will call GetItems for i2_1, which is stored in it's _previous field. This will create the items for i2_1 with the correct metadata, and if we implement caching then it will cache that list before returning it for i to use.

Then when i2_2 is evaluated, it will have a reference to the same instance of LazyItemList which represents i2_1. This time it will return the cached value, which will be the same item instances that were used by i. Then the evaluation of i2_2 will update the metadata on those item instances, which will be the same ones that are in the i item list, meaning that it will change the metadata of the unrelated item list.

Hopefully this helps make it more clear. A possible solution is to clone all the items before modifying their metadata.

@rainersigwald
Copy link
Member

@cdmihai You did the second half of this for Update in #2326, right?

@cdmihai
Copy link
Contributor Author

cdmihai commented Jul 20, 2017

Closing as caching was done in #1192 and #2314 is tracking the Update / Remove optimizations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants