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

feat(ivy): support deep queries through view boundaries #21700

Conversation

pkozlowski-opensource
Copy link
Member

@pkozlowski-opensource pkozlowski-opensource commented Jan 22, 2018

@mhevery this is still WIP (requires rebase, proper description and more tests), but opening it early on so we can discuss data structure / impl choices.

The general idea is that both a container (LContainer) and a view (LView) have a pointer to all queries "active" for a given container / view. When encountering a container and view instructions, we are cloning LQuery predicates (queries) to have new place (arrays) to store matching nodes from sub-views.

I feel like I've missed millions of use-cases here, but at the same time feel like I'm digging a deeper and deeper rabbit hole, so opening early PR so we can have discussion about exact data structures and algs.

@pkozlowski-opensource pkozlowski-opensource force-pushed the queries_in_embed_views_with_predicate branch from 6b8c4b8 to 3e026d8 Compare January 22, 2018 16:50
@pkozlowski-opensource pkozlowski-opensource added the target: major This PR is targeted for the next major release label Jan 22, 2018
@mhevery mhevery added the area: core Issues related to the framework runtime label Jan 22, 2018
@mhevery mhevery self-requested a review January 22, 2018 20:41
Copy link
Contributor

@mhevery mhevery left a comment

Choose a reason for hiding this comment

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

I left few minor perf concerns, but overall It is what I had in mind so I think you are on a right track.

@@ -97,17 +97,75 @@ export class LQuery_ implements LQuery {
}
}

container(): LQuery|null {
return this._clonePredicates((predicate: QueryPredicate<any>) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

could we solve it without closer (perf reasons)?

Copy link
Member Author

Choose a reason for hiding this comment

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

After spending quite a but of time on it I'm not sure I can think of anything better. I'm at a bottom of a rabbit hole here and if there is a simple solution I just can't see it :-/

My current understanding is that we need to, for each container / view and each query:

  • create a new array for results;
  • make sure that views / nodes created in views are added to this new array.

Essentially we need to have a new combination of existing predicate + metdata + queryList with a new array. Cloning current predicate is the simplest I could think of... It might be that it is hard to see other solutions due to the current naming that we are using, so here is a doc describing proposed renaming: https://docs.google.com/document/d/1QOTC1pyy_WA4WT4J-xgLQhkG554SyXxBwyzUcXbc6h0/edit?usp=sharing

@@ -240,6 +303,13 @@ function createPredicate<T>(
};
}

function flatten<T>(list: Array<T|T[]>): T[] {
return list.reduce((flat: any[], item: T | T[]): T[] => {
Copy link
Contributor

Choose a reason for hiding this comment

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

let's not use reduce and friends. Negative perf impact.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed.

@@ -240,6 +303,13 @@ function createPredicate<T>(
};
}

function flatten<T>(list: Array<T|T[]>): T[] {
return list.reduce((flat: any[], item: T | T[]): T[] => {
const flatItem = Array.isArray(item) ? flatten(item) : item;
Copy link
Contributor

Choose a reason for hiding this comment

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

recursive functions are perf issue since they prevent inlining.

Copy link
Member Author

Choose a reason for hiding this comment

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

Created a non-recursive version, although I'm not sure how much better (perf-wise) this one is... Review appreciated.

@pkozlowski-opensource pkozlowski-opensource added comp: ivy and removed area: core Issues related to the framework runtime labels Jan 23, 2018
@pkozlowski-opensource pkozlowski-opensource force-pushed the queries_in_embed_views_with_predicate branch from 3e026d8 to 0b4d8b3 Compare January 23, 2018 16:34
@pkozlowski-opensource pkozlowski-opensource added action: review The PR is still awaiting reviews from at least one requested reviewer and removed state: WIP labels Jan 23, 2018
@ngbot
Copy link

ngbot bot commented Jan 23, 2018

Hi @pkozlowski-opensource! This PR has merge conflicts due to recent upstream merges.
Please help to unblock it by resolving these conflicts. Thanks!

@pkozlowski-opensource pkozlowski-opensource force-pushed the queries_in_embed_views_with_predicate branch from 0b4d8b3 to c187560 Compare January 24, 2018 11:12
@pkozlowski-opensource pkozlowski-opensource changed the title WIP: feat(ivy): support deep queries through view boundaries feat(ivy): support deep queries through view boundaries Jan 24, 2018
@pkozlowski-opensource pkozlowski-opensource force-pushed the queries_in_embed_views_with_predicate branch from c187560 to 064a6ef Compare January 24, 2018 12:53
@pkozlowski-opensource
Copy link
Member Author

@mhevery all the perf-related issues were addressed, please have another look

@mhevery mhevery added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jan 25, 2018
@mhevery
Copy link
Contributor

mhevery commented Jan 25, 2018

@mhevery mhevery closed this in 5269ce2 Jan 25, 2018
jbogarthyde pushed a commit to jbogarthyde/angular that referenced this pull request Feb 23, 2018
leo6104 pushed a commit to leo6104/angular that referenced this pull request Mar 25, 2018
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants