-
Notifications
You must be signed in to change notification settings - Fork 215
Conversation
…haker), replaced access to _mojitDetails with _resolveMojit() method that resolves and caches resources at runtime, the 'chosen' member of the resources is not irrelevant since we don't chose any of them. It might overload the Y instance with a few useless addons
…n the plugin and its host when the config is later modified by another plugin
added JSON chached resources on the first request transformed for in loops to index based loops
… have been loaded do we want to reload the resources
…s merely a dead-easy way to support that
…at allows to trigger lazy resolution of resources only if it is truthy
Just a note from the description of this PR: "It also introduces the ability for plugins to alter configurations". This is part of a previous PR: |
…ource_store Conflicts: lib/app/addons/rs/selector.js lib/app/autoload/store.server.js
This looks good to me. I think some of these changes should be the new default behavior (not a separate code path + config), but drewfish is back tomorrow. We'll get his input before proceeding. |
I tried this approach and found that it caused mojito to be slower. The interpretation is that I'll look at the details later. |
I see, did you try stringifying the mojitRVs like you do for the cache? |
also how much slower? |
OK, I found the experiment I did earlier. It's from March 21st this year. Here's what I did:
Alas, it only captured the GC events of the scripts, not the total runtime. Here are the results:
From this I surmised that keeping the source data ( (I had written all these results into a trello card but alas I can't find it.) |
Trello Card 432: https://trello.com/c/Cz5hCgj6/432-search-perf-0-gc-profiling |
Just moved the card to the right board, so it's now located at: |
this test would be interesting to repeat in node 0.10.x. Before then node would trigger GC "whenever the event loop was idle." But the behavior was removed because in practice, V8 was better at deciding when to GC. http://blog.nodejs.org/2013/03/11/node-v0-10-0-stable/ (search for "idle garbage collection") I think the count of GC events would not mean GC was required more often, for pre 0.10 versions.. |
@@ -191,6 +192,10 @@ YUI.add('mojito-resource-store', function(Y, NAME) { | |||
this._appPkg = null; // metadata about the applicaions's NPM package | |||
this._specPaths = {}; // spec name: full path | |||
|
|||
// Let's try to be more efficient | |||
this._smarterDetails = {}; // MojitType: selector: environment: non-stringified details |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This structure is useful for the new algorithm, but should be called something else. It contains resource versions and is used by _resolveVersions()
so perhaps it should be called _mojitDetailRVs
.
this._appPkg = null; // metadata about the applicaions's NPM package | ||
this._specPaths = {}; // spec name: full path | ||
|
||
this._mojitDetails = {}; // mojitType: selector: environment: non-stringified details | ||
this._mojitDetailsCache = {}; // mojitType+poslString+env : resolved resources |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For both of these "environment" is really "affinity" no? If so it'd be clearer to say "affinity" instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
semantically, it is environment: a request has an environment and goes there to look for resources which have affinities, but are indexed by environment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Environment" is traditionally (in mojito code and docs) as things like "development", "production", "staging", etc. "Runtime" is used to describe the client vs. server. "Affinity" is used to describe which runtime a particular piece of code is intended for.
Unless there's a strongly compelling reason to use different semantics here, it is strongly recommended to stay with the existing semantics. (If we want to change it, we should change it everywhere: all code and documentation.) That work (and discussion with the whole mojito team about the value of that work) is beyond the scope of this pull request, so please stick to existing semantics. Consistency aids clarity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh hmm... excepts a lot of places in the resource store "env"/"environment" is used for runtime (that is "client" or "server"). However, each resource has an "affinity" ("client", "server", or "common") for a particular "environment". If a field contains the affinity of a resource it should be labelled as "affinity".
Looks like travis build failed due to environmental issues (bad network) and not anything to do with code quality. |
…yui resources too
* @method resolveResourceVersions | ||
* @return {nothing} | ||
* @return {[type]} [description] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm... this @return
is confusing. What is the intended return value of this resolveResourceVersions()
method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nothing, dead code
/** | ||
* Find a mojit details in the resource store at runtime | ||
* @param {String} type the mojit type | ||
* @param {String} env the environment: {'client', 'server', 'common'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think "environment" here is just "client" or "server".
+1 |
Looks like travis build failed due to environmental issues (bad network) and not anything to do with code quality. |
Oh, still need test(s) to make sure that app.json resourceStore.lazyLoad (a) actually causes a lazy load, and (b) an app still works with lazy load. |
…, affinity has higher priority over shallowness
One last task. Please add a note in the HISTORY.md file mentioning the new feature. You could add something like this in the "Features" section:
|
+1 |
lgtm +1 |
This pull request implements an optional lazy resolution of resources that potentially makes the resource store creation independent of the number of dimensions and linear with the number of resources.
It also introduces the ability for plugins to alter configurations