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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use dotnet 7 regex source generator #568

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dashkan
Copy link

@dashkan dashkan commented Feb 19, 2023

This PR adds support for dotnet 7 regular expression source generators.

Adds significant performance boost.

Since source generators require partial classes, I moved all regular expressions into a single file and wrap the partial methods with a property for simplicity.

I also upgraded all referenced nuget packages to latest.

dotnet 5 is not supported on Apple silicon. I had to also upgrade to dotnet 6.

dotnet 6 benchmark (Not using regex source generator)

// * Summary *

BenchmarkDotNet=v0.13.5, OS=macOS Ventura 13.2.1 (22D68) [Darwin 22.3.0]
Apple M1 Max, 1 CPU, 10 logical and 10 physical cores
.NET SDK=7.0.200
  [Host]     : .NET 6.0.14 (6.0.1423.7309), Arm64 RyuJIT AdvSIMD
  DefaultJob : .NET 6.0.14 (6.0.1423.7309), Arm64 RyuJIT AdvSIMD


|                                                          Method |     Mean |    Error |   StdDev |
|---------------------------------------------------------------- |---------:|---------:|---------:|
|                                                  SingleThreaded | 36.55 ms | 0.712 ms | 0.666 ms |
|                                         ParallelUponDeserialize | 38.59 ms | 0.762 ms | 1.068 ms |
|                                      ParallelUponGetOccurrences | 39.84 ms | 0.700 ms | 0.719 ms |
| ParallelDeserializeSequentialGatherEventsParallelGetOccurrences | 39.17 ms | 0.769 ms | 1.078 ms |

dotnet 7 benchmark (Using regex source generators)

// * Summary *

BenchmarkDotNet=v0.13.5, OS=macOS Ventura 13.2.1 (22D68) [Darwin 22.3.0]
Apple M1 Max, 1 CPU, 10 logical and 10 physical cores
.NET SDK=7.0.200
  [Host]     : .NET 7.0.3 (7.0.323.6910), Arm64 RyuJIT AdvSIMD
  DefaultJob : .NET 7.0.3 (7.0.323.6910), Arm64 RyuJIT AdvSIMD


|                                                          Method |     Mean |    Error |   StdDev |
|---------------------------------------------------------------- |---------:|---------:|---------:|
|                                                  SingleThreaded | 28.01 ms | 0.125 ms | 0.098 ms |
|                                         ParallelUponDeserialize | 33.15 ms | 0.631 ms | 0.751 ms |
|                                      ParallelUponGetOccurrences | 31.07 ms | 0.522 ms | 0.488 ms |
| ParallelDeserializeSequentialGatherEventsParallelGetOccurrences | 32.36 ms | 0.620 ms | 0.806 ms |

@axunonb
Copy link
Collaborator

axunonb commented Oct 8, 2024

@dashkan As you may have noticed we'd like to revitalize ical.net. Appreciate your PR, which looks good. AFAIK, source-generated regular expressions are supported for netstamdard2.1 and later, but they are not supported in .NET Framework. As I read the PR code Ical.Net.Utility already uses conditional compilation. So we could support all currently supported target frameworks, instead of restricting <TargetFrameworks>net6.0;net8.0</TargetFrameworks>. Does this make sense to you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants