Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid recursion in TextChunker.BuildParagraph #1709

Merged

Conversation

stephentoub
Copy link
Member

Motivation and Context

TextChunker.BuildParagraph is unnecessarily recursive and can lead to stack overflows on large inputs.

Description

Fixes #1633

Also happens to make it more efficient with a few tweaks.

Contribution Checklist

@stephentoub stephentoub requested a review from a team as a code owner June 26, 2023 02:31
@github-actions github-actions bot added .NET Issue or Pull requests regarding .NET code kernel Issues or pull requests impacting the core kernel kernel.core labels Jun 26, 2023
dmytrostruk
dmytrostruk previously approved these changes Jun 27, 2023
dotnet/src/SemanticKernel/Text/TextChunker.cs Outdated Show resolved Hide resolved
@dmytrostruk dmytrostruk added the PR: ready to merge PR has been approved by all reviewers, and is ready to merge. label Jun 27, 2023
Copy link
Member

@lemillermicrosoft lemillermicrosoft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@lemillermicrosoft lemillermicrosoft added this pull request to the merge queue Jun 27, 2023
Merged via the queue into microsoft:main with commit 84e6fad Jun 27, 2023
10 checks passed
@evchaki evchaki added this to the Sprint 34 milestone Jun 30, 2023
shawncal pushed a commit to shawncal/semantic-kernel that referenced this pull request Jul 6, 2023
### Motivation and Context

TextChunker.BuildParagraph is unnecessarily recursive and can lead to
stack overflows on large inputs.

### Description

Fixes microsoft#1633

Also happens to make it more efficient with a few tweaks.

### 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`
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 馃槃

---------

Co-authored-by: Dmytro Struk <13853051+dmytrostruk@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kernel Issues or pull requests impacting the core kernel .NET Issue or Pull requests regarding .NET code PR: ready to merge PR has been approved by all reviewers, and is ready to merge.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Large documents cause stack overflow in TextChunker.SplitPlainTextParagraphs()
4 participants