-
Notifications
You must be signed in to change notification settings - Fork 479
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
Optimize performance of LG evaluation #3327
Conversation
Pull Request Test Coverage Report for Build 103269
💛 - Coveralls |
✔️ No Binary Compatibility issues for Microsoft.Bot.Builder.dll compared against version 4.6.3 |
libraries/Microsoft.Bot.Builder.LanguageGeneration/CustomizedMemory.cs
Outdated
Show resolved
Hide resolved
Looks good, one more thing i have is can we measure\profile this change, see how much we improved. Some suggestions to profile
|
✔️ No Binary Compatibility issues for Microsoft.Bot.Builder.dll compared against version 4.6.3 |
|
Looks good. One more thing is, it would be great if we put more context in 'Description' of this PR, for example,
Anyhow, more context help both you and reviewers to have a better context |
|
||
var newLgFile = LGParser.ParseText(newContent, lgFile.Id, lgFile.ImportResolver); | ||
return newLgFile.EvaluateTemplate(fakeTemplateId, scope); | ||
|
||
var allTemplates = lgFile.AllTemplates.Union(newLgFile.AllTemplates).ToList(); |
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.
couldn't you precompute this and only redo when new templates are added?
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 newLgFile is computed from the parameter inlineStr
, so we can't pre-compute it. What we can do is to cache this string, to avoid re-compute, but based on the profiling result, not much improvement here, because the inlineStr is very small. So this is good enough for now.
close: #3297
Today, every time a free LG text like "@{welcome}" is evaluated by creating a new "anonymous template" to wrap this free text, and create a temporary LG file with the new content = original content + new anonymous template, for evaluation.
This is not performance friendly. In this pr, we just parse the additional part, so that there is no need to reparse the original content.