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

[BUGFIX beta] [PERF] Cache FactoryManagers #15009

Merged
merged 3 commits into from
Mar 14, 2017
Merged

[BUGFIX beta] [PERF] Cache FactoryManagers #15009

merged 3 commits into from
Mar 14, 2017

Conversation

stefanpenner
Copy link
Member

@stefanpenner stefanpenner commented Mar 14, 2017

  • 1 FactoryManager per container/normalizeFullName
  • cache madeToString per factoryManager

[fixes #15007]

* 1 FactoryManager per container/normalizeFullName
* cache madeToString per factoryManager
let factory = this.registry.resolve(normalizedName);

if (factory === undefined) { return; }
if (factory === undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

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

should misses not cache?

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 thought so, but there where test failures and I'm tired :P Maybe i can convince @chadhietala to investigate?

Copy link
Member Author

Choose a reason for hiding this comment

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

resolve does also cache so its not the end of the world either..

@chadhietala
Copy link
Contributor

Added tests to make sure the FactoryManager instances are the same on a cache hit and are not equal on a cache miss.

@@ -38,6 +38,7 @@ export default function Container(registry, options) {
this.owner = options && options.owner ? options.owner : null;
this.cache = dictionary(options && options.cache ? options.cache : null);
this.factoryCache = dictionary(options && options.factoryCache ? options.factoryCache : null);
this.factoryManagerCache = dictionary(options && options.factoryCache ? options.factoryCache : null);
Copy link
Member

Choose a reason for hiding this comment

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

This should not share the same cache as this.factoryCache. I suspect this should be:

this.factoryManagerCache = dictionary(options && options.factoryManagerCache ? options.factoryManagerCache : null);

Copy link
Member

Choose a reason for hiding this comment

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

Pushed a commit fixing this

@rwjblue rwjblue merged commit f787b0d into master Mar 14, 2017
@rwjblue rwjblue deleted the factory-manager branch March 14, 2017 14:35
@stefanpenner
Copy link
Member Author

Thanks @chadhietala

@stefanpenner
Copy link
Member Author

benchmarks (4.7x improvement):

node factory/factory-for.js                                                                                                 (1) (432ms)
testing
- factoryFor (new)
- factoryFor (old)
running first test, please wait...
  factoryFor (new) .... 4,342,542.07 op/s
  factoryFor (old) ...... 915,862.86 op/s

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

Successfully merging this pull request may close these issues.

cache FactoryManager instances
4 participants