-
Notifications
You must be signed in to change notification settings - Fork 18
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
547 Static classes and libraries on 1.0 #548
Conversation
…ve the required initialization
What does the code generated files look like now? Could you include this? |
And what is the performance if only the lazy initialization is removed while keeping classes non-static? I'd like to see an example of the performance test itself too. |
Per the screenshot in the initial bug, the time sink was due to the numerous class initializations and calling all of the constructors. Removing all of that reduces the impact. The Lazy was used for caching and not recalculating the value of a define. |
I have included the changes in 2.0 just to look at the changes in the generated libraries. Will have to discuss with @ewoutkramer if this is the right approach |
Just some thoughts
I discussed with @ewoutkramer and he'll reach out to @EvanMachusak on this too |
so if you look at AAB from the DQIC project you will notice that when you initialize the AAB_Reporting_2023_0_1 class it will initialize the libraries being used and the libraries used inside of those, etc. This chews up time having to initialize everything. In the 1.0 branch, which we are currently using, swapping to static improves runtime drastically thus improving time and saving memory. A 60% performance boost is a massive savings in time and money over the current process for the 1.0 branch being used in our software.
|
Problem is when you have to initialize the context for each patient because the bundle exists in the context and you cannot just swap out the bundle to reuse everything else. If you could then you would have to remove the Lazy or reset them. Thus initializing each class causes a drastic hit to performance. I have not looked at the 2.0 branch as I am doing performance tuning for our measures and uncovering that the engine is the worst offender. |
I have updated the 2.0 implementation This still has to be discussed with @ewoutkramer and @EvanMachusak
The DQIC branch which uses the service provider to create libraries is available here. |
updated with the requested changes |
There is some performance benefit by using static invocations over instance ones, but it is not clear what that is. The trick with CQL in particular is that it is run on large data sets - in our case many 10m+ patients - and even small performance changes can save many minutes on large runs. I think the DI solution should make approximately the same gains as everything being pure static and is more harmonious with the rest of the 2.0 SDK. It would be interesting to run a test where everything is equal except the 1.0 vs. 2.0 SDK to see which performs better on the same measure and same patient set. I would hope we don't go backward in performance. |
Could you test the performance on singleton libraries? My expectation is that it should be comparable to static libraries. |
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.
else return "__" + methodName; | ||
} | ||
private string PrivateMethodNameFor(string methodName) => methodName + "_Value"; | ||
|
||
private void WriteMemoizedInstanceMethod(string libraryName, TextWriter writer, int indentLevel, |
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.
Rename to WriteMemoizedInstanceMethod to WriteMethod. See review comment above first
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.
Tested the singleton approach and it produced similar results so either works
closing this using static to use the singleton PR |
Out of curiosity, was there any difference in performance? |
I had previously mentioned here and in your PR that it was comparable and said to just use your PR because it had all the test updates but nothing has been merged so I am in the process of pulling your changes in for the tests so we can get this finally merged in to see those massive performance gains. |
@ewoutkramer this is the PR we spoke about this past weekend. Can we get this reviewed and merged into the 1.0 branch? |
Out of curiosity again, what are the performance gains on .NET 9? Microsoft has made huuuuge improvements in performance and much less memory allocation on LINQ |
Observed performance gains
Performance gains of almost 60% by removing the Lazy loading/caching and moving to just static classes and passing the context around.
Fix for #547