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

refactor(ivy): generatePropertyAliases #22082

Closed
wants to merge 4 commits into from
Closed

Conversation

vicb
Copy link
Contributor

@vicb vicb commented Feb 8, 2018

No description provided.

@vicb vicb added aio: preview target: major This PR is targeted for the next major release comp: ivy action: review The PR is still awaiting reviews from at least one requested reviewer labels Feb 8, 2018
@angular angular deleted a comment from mary-poppins Feb 8, 2018
*
* @param index Index where data should be stored in tData
* @param number lNodeFlags node flags of the logical node
* @param Direction direction wheter to consider inputs or outputs
Copy link
Contributor

Choose a reason for hiding this comment

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

whether?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks

@mary-poppins
Copy link

You can preview ee65c12 at https://pr22082-ee65c12.ngbuilds.io/.

@@ -501,11 +506,11 @@ export function createTView(): TView {

function setUpAttributes(native: RElement, attrs: string[]): void {
ngDevMode && assertEqual(attrs.length % 2, 0, 'attrs.length % 2');
const isProceduralRenderer = (renderer as ProceduralRenderer3).setAttribute;

const isProc = isProceduralRenderer(renderer);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I'm not sure we're getting much benefit out of taking this out into a variable. The variable name is a bit obscure and it will minify slightly less well than if it were inlined.

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe most minifiers are smart enough to inline it back in. So I think it is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The call is here because the usage is inside a for loop (do not want the fn call to be repeated).

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, that makes sense.

@@ -113,6 +113,11 @@ let bindingIndex: number;
*/
let cleanup: any[]|null;

const enum Direction {
Copy link
Contributor

Choose a reason for hiding this comment

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

Add comment?

Copy link
Contributor Author

@vicb vicb Feb 8, 2018

Choose a reason for hiding this comment

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

What kind of comments would you add here ? (anything I could think of would actually bring more noise or confusion - probably easier for a native speaker)

Copy link
Contributor

Choose a reason for hiding this comment

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

Without context (and esp floating here at the top), Direction could be anything. Might help to know where it is used and why.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't want to restrict the meaning of this to its current usage.
ie you can use this anywhere you need a Direction that could be input or output.

My XP is that when you name things / add comment about what a thing is for it will become outdated faster. I prefer to comment/name things according to what they do.

Concrete exemple in the code base:

/**
 * Returns the first DOM node following the given logical node in the same parent DOM element.
 *
 * ...
 */
function findBeforeNode(node: LNode | null, stopNode: LNode | null): RElement|RText|null {
  //
}

Here the comment is right, this function returns the next node but IMO the name is misleading. It assumes that you will call this fn to get the next node so that you can insert before. I think it is too restrictive, I might call this fn in some other context and the name will be completely meaningless then.

*
* - `undefined` means that the prop has not been initialized yet,
* - `null` means that the prop has been initialized but no outputs have been found.
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, thanks for fleshing this out 👍

const start = lNodeFlags >> LNodeFlags.INDX_SHIFT;
const size = (lNodeFlags & LNodeFlags.SIZE_MASK) >> LNodeFlags.SIZE_SHIFT;
const isInput = direction === Direction.Input;
const propStore: PropertyAliases = {};
Copy link
Contributor

@kara kara Feb 8, 2018

Choose a reason for hiding this comment

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

I like the direction of this refactor, but I'm concerned it might be a tad slower because of unnecessary object creation (and thus increased GC pressure).

It was originally configured this way so that property alias objects were only created if a node had a directive with at least one input or at least one output defined. In this implementation, we will create a new property alias object for every node that has a binding or a listener, regardless of whether it has a directive or any inputs or outputs. So if you have a template with 10 nodes and 0 directives, you will still create 10 unnecessary objects for mapping directive inputs/outputs.

One optimization might be to check whether the size is greater than 0 before creating the object so they are only created on nodes that actually have directives. But we will still be creating wasted objects for directives that have no inputs/outputs. Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

+1 to initialize the store only when there is actually directives.

I often favor semantic over speed if there are no tests to prove that the speedy implementation is actually faster.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed on adding performance tests, but in their absence, I think it's pretty well-established that creating objects unnecessarily will eventually hurt performance.

@mary-poppins
Copy link

You can preview bec0d06 at https://pr22082-bec0d06.ngbuilds.io/.

@vicb vicb removed the aio: preview label Feb 8, 2018
@mary-poppins
Copy link

You can preview 00ef46d at https://pr22082-00ef46d.ngbuilds.io/.

Copy link
Contributor

@kara kara left a comment

Choose a reason for hiding this comment

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

LGTM

@vicb vicb 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 Feb 10, 2018
@ngbot
Copy link

ngbot bot commented Feb 10, 2018

I see that you just added the PR action: merge label, but the following checks are still failing:
    failure conflicts with base branch "master"
    pending status "google3" is pending
    pending status "continuous-integration/travis-ci/pr" is pending
    pending status "code-review/pullapprove" is pending

If you want your PR to be merged, it has to pass all the CI checks.

If you can't get the PR to a green state due to flakes or broken master, please try rebasing to master and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

@mhevery mhevery closed this in 61341b2 Feb 12, 2018
mhevery pushed a commit that referenced this pull request Feb 12, 2018
jbogarthyde pushed a commit to jbogarthyde/angular that referenced this pull request Feb 23, 2018
jbogarthyde pushed a commit to jbogarthyde/angular that referenced this pull request Feb 23, 2018
@vicb vicb deleted the 0207-ir branch March 6, 2018 22:25
leo6104 pushed a commit to leo6104/angular that referenced this pull request Mar 25, 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

6 participants