Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
.Net: Use static Regex for ActionPlanner.CreatePlanAsync (#1954)
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? To ensure best performance for Semantic Kernel apps. 2. What problem does it solve? Excessive CPU and memory usage when creating plans via ActionPlanner. 4. What scenario does it contribute to? 5. If it fixes an open issue, please link to the issue here. Related to this issue (which may already be fixed but not released): #1919 --> Creating and executing plans will be a common activity for apps using the Semantic Kernel / Action Planner. The regular expression used with a constant pattern string should be allocated once and compiled to maximize performance for server applications. This will save both CPU and memory. ### Description Move the Regex allocation to a static field and consumed it from there. ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [ X] The code builds clean without any errors or warnings - [ X] The PR follows SK Contribution Guidelines (https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) - [ X] The code follows the .NET coding conventions (https://learn.microsoft.com/dotnet/csharp/fundamentals/coding-style/coding-conventions) verified with `dotnet format` - [ ] All unit tests pass, and I have added new tests where possible Logic should be identical, however the tests in main don't currently pass locally so there is no base line. - [x ] I didn't break anyone 😄 --------- Co-authored-by: Dmytro Struk <13853051+dmytrostruk@users.noreply.github.com>
- Loading branch information