-
-
Notifications
You must be signed in to change notification settings - Fork 111
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(dcs): optimize decorate models #857
feat(dcs): optimize decorate models #857
Conversation
Signed-off-by: Sanket Shevkar <[email protected]>
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.
It looks like you're on the right track, @sanketshevkar. I look forward to seeing the perf numbers!
Signed-off-by: sanketshevkar <[email protected]>
Signed-off-by: sanketshevkar <[email protected]>
Signed-off-by: sanketshevkar <[email protected]>
…d to decorate models Signed-off-by: sanketshevkar <[email protected]>
Signed-off-by: sanketshevkar <[email protected]>
Signed-off-by: sanketshevkar <[email protected]>
Signed-off-by: sanketshevkar <[email protected]>
Signed-off-by: sanketshevkar <[email protected]>
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.
Couple of minor changes. Looks good.
/** | ||
* Creates five different maps to index decorator command sets by target type and returns them | ||
* @param {*} decoratorCommandSet the DecoratorCommandSet object | ||
* @returns {Object} a new model manager with the decorations applied |
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.
Incorrect JSDoc.
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.
Corrected
|
||
decoratorCommandSet.commands.map((decoratorCommand, index) => { | ||
const dcsWithIndex = new DcsIndexWrapper(decoratorCommand, index); | ||
switch (true) { |
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.
Is this switch supposed to be exhaustive? If yes, add a default case and throw an exception.
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 was under the assumption that if we pass a invalid dcs, it will only get caught if validation is enabled. In the case of a malformed decorator, if we pass (in this case target is undefined, falsy, null or does not match with any of the switch statements) that decorator won't get applied.
This is the older behavior: https://replit.com/@sanketshevkar/Decorator-malformed-dcs#index.js
This differs a bit, I think is was a bug as well. shouldn't target: false
be invalid dcs, but its passing the syntax validation. In either case, if we validate or not, it just applies the decorator on top of all the declarations, which should be a bug?
* @param {string} namespace the namespace for the declaration | ||
* @param {*} declaration the class declaration | ||
* @param {*} command the Command object from the dcs | ||
* @param {boolean} [enableDcsNamespaceTarget] - flag to control applying namespace targeted decorators on top of the namespace instead of all declarations in that namespace | ||
* @param {*} property the property |
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.
Looks like property is now an optional argument? Would be good to document that.
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.
Yes corrected
* [DecoratorCommandSet](https://models.accordproject.org/concerto/decorators.cto) | ||
* @memberof module:concerto-core | ||
*/ | ||
class DcsIndexWrapper { |
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.
Private?
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.
Should not be exported? Private?
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.
Yes made the method private
*/ | ||
private static getDecoratorMaps; | ||
/** | ||
* Migrate or validate the DecoratorCommandSet object if the options are set as true |
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.
Migrate AND validate?
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.
It can also do either of the operation if parameters for the arguments are passed so. It can only validate or it might only migrate and can do both if the parameters are true for both.
The only reason I moved this out of decorateModels
is to reduce the code in the decorateModels
method, so is a private method just used in decorateModels
method.
Signed-off-by: sanketshevkar <[email protected]>
Signed-off-by: sanketshevkar <[email protected]>
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.
Bravo!
Closes #856
Proposal for optimizing decorate models. More details on #856
Changes
executeCommand
but are not a breaking change in nature.executeCommand
has changed a bit anddecorateModels
has changed significantly. New private methods have been introduced to support these.Performance and Memory Impact.
Performance
time: 6696.545083999634 ms
to apply autogenerated vocabulary to the model with the older implementation.Execution time: 44.81274998188019 ms
for the same operation.Memory
total_heap_size
total_heap_size
recorded after an auto-generated model of size 1.6MB was applied autogenerated vocabulary to the model with the older implementation was58261504
total_heap_size
as61571072
total_heap_size
used_heap_size
used_heap_size
recorded after an auto-generated model of size 1.6MB was applied autogenerated vocabulary to the model with the older implementation was6541360
used_heap_size
as13041876
used_heap_space
used_heap_size
Author Checklist
--signoff
option of git commit.main
fromfork:branchname