Skip to content

String module spannification - #20358

Draft
jwosty wants to merge 9 commits into
dotnet:mainfrom
jwosty:string-module-spannification
Draft

String module spannification#20358
jwosty wants to merge 9 commits into
dotnet:mainfrom
jwosty:string-module-spannification

Conversation

@jwosty

@jwosty jwosty commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Description

Some String module perf improvements (heap allocation reduction) on .NET Standard 2.1+

Part of #20283

Checklist

  • Test cases added
  • Performance benchmarks added in case of performance changes
  • Release notes entry updated: pending

@github-actions

Copy link
Copy Markdown
Contributor

❗ Release notes required

You can open this PR in browser to add release notes: open in github.dev

@jwosty,

Caution

No release notes found for the changed paths (see table below).

Please make sure to add an entry with an informative description of the change as well as link to this pull request, issue and language suggestion if applicable. Release notes for this repository are based on Keep A Changelog format.

The following format is recommended for this repository:

`* . (PR #XXXXX)`

See examples in the files, listed in the table below or in th full documentation at https://fsharp.github.io/fsharp-compiler-docs/release-notes/About.html.

If you believe that release notes are not necessary for this PR, please add NO_RELEASE_NOTES label to the pull request.

Change path Release notes path Description
`src/FSharp.Core` docs/release-notes/.FSharp.Core/11.0.100.md No release notes found or release notes format is not correct

@jwosty

jwosty commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

String.filter seems to be tricky since the output length is unknown and we can't invoke the predicate multiple times.

The best I could come up with after a few attempts is swapping out the intermediate array for a stackalloc, and this indeed tamps down allocations quite a bit, we just need to figure out what a good upper limit (on stackalloc size) would be.

Tried some "clever" approaches with BitArray as a two-pass intermediate but couldn't find any wins there

Honestly not sure how much more clever it can get outside a careful stackalloc -- would love to hear ideas

@jwosty
jwosty force-pushed the string-module-spannification branch from 8634588 to d4c3528 Compare August 28, 2026 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

1 participant