Skip to content
This repository was archived by the owner on Dec 19, 2018. It is now read-only.

Conversation

NTaylorMullen
Copy link

  • Currently the TagHelperScopeManager creates a new TagHelperExecutionContext per TagHelper on a given page. With this change the max number of TagHelperExecutionContexts per page is the number of nested levels that exist.
  • Decided to add two tests validating that specific pieces of TagHelperExecutionContext are updated as expected.

Before:
image

After:
image

Result: 3% overall reduction in allocations.
#674

@NTaylorMullen
Copy link
Author

/cc @rynowak @dougbu

}

// Used to pool TagHelperExecutionContext's. With this we don't always need to recreate TagHelperExecutionContexts.
internal void ClearAndUpdateWith(
Copy link
Member

Choose a reason for hiding this comment

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

Reset(...)?

Copy link
Member

Choose a reason for hiding this comment

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

Why internal? Would user code ever see this type?

Copy link
Author

Choose a reason for hiding this comment

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

Nope, user code wont see this type. As for Reset, that was my first naming of this but felt that the name mislead with what it really did.

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest Reinitialize(). Also suggest public because internal is used only for bits that would be private if not for testing. (All of Microsoft.AspNetCore.Razor.Runtime.TagHelpers could be named .Internal if we wanted.)

@NTaylorMullen NTaylorMullen force-pushed the nimullen/poolthcontexts.674 branch from 65d8462 to 1e73a71 Compare February 18, 2016 22:52
@NTaylorMullen
Copy link
Author

🆙 📅

/// <param name="items">The <see cref="IDictionary{Object, Object}"/> to use.</param>
/// <param name="uniqueId">The unique id to use.</param>
/// <param name="executeChildContentAsync">The <see cref="Func{Task}"/> to use.</param>
public void Reinitialize(
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest removing overlapping parameters from the constructors, requiring a Reinitialize() call for all uses. Alternatively call Reinitialize() from the constructors duplicating this code.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thx

@dougbu
Copy link
Contributor

dougbu commented Feb 18, 2016

⌚ (looking very solid)

@NTaylorMullen
Copy link
Author

🆙 📅

throw new ArgumentNullException(nameof(endTagHelperWritingScope));
}

Reinitialize(tagName, tagMode, items, uniqueId, executeChildContentAsync);
Copy link
Contributor

Choose a reason for hiding this comment

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

Call this after initializing _tagHelpers and just .Clear() that field in Reinitialize().

@dougbu
Copy link
Contributor

dougbu commented Feb 19, 2016

Not urgent to check but am curious whether ExecutionContextPool instances are smaller than the previous Stack<TagHelperExecutionContext> instances.

@dougbu
Copy link
Contributor

dougbu commented Feb 19, 2016

:shipit: w/ a couple of small fixes

- Currently the `TagHelperScopeManager` creates a new `TagHelperExecutionContext` per `TagHelper` on a given page. With this change the max number of `TagHelperExecutionContext`s per page is the number of nested levels that exist.
- Added two tests validating that specific pieces of `TagHelperExecutionContext` are updated as expected.

#674
@NTaylorMullen NTaylorMullen force-pushed the nimullen/poolthcontexts.674 branch from d902fe4 to 78451ef Compare February 19, 2016 18:37
@NTaylorMullen NTaylorMullen merged commit 78451ef into dev Feb 19, 2016
@NTaylorMullen NTaylorMullen deleted the nimullen/poolthcontexts.674 branch February 19, 2016 19:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants