Skip to content

Commit 703c13a

Browse files
authored
Use generated regex for better error ingestion performance (#4931)
1 parent 13c7852 commit 703c13a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/ServiceControl/Recoverability/Grouping/Groupers/StackTraceParser.g.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ partial class StackTraceParser
3434
const string Space = @"[\x20\t]";
3535
const string NotSpace = @"[^\x20\t]";
3636

37-
static readonly Regex Regex = new Regex(@"
37+
[GeneratedRegex(@"
3838
^
3939
" + Space + @"*
4040
\w+ " + Space + @"+
@@ -71,7 +71,10 @@ partial class StackTraceParser
7171
// fall into the "catastrophic backtracking" trap due to over
7272
// generalization.
7373
// https://github.com/atifaziz/StackTraceParser/issues/4
74-
TimeSpan.FromSeconds(5));
74+
5000)]
75+
private static partial Regex StackTraceRegex();
76+
77+
static readonly Regex StackTraceRegexInstance = StackTraceRegex();
7578

7679
public static IEnumerable<T> Parse<T>(
7780
string text,
@@ -104,7 +107,7 @@ public static IEnumerable<TFrame> Parse<TToken, TMethod, TParameters, TParameter
104107
if (sourceLocationSelector == null) throw new ArgumentNullException("sourceLocationSelector");
105108
if (selector == null) throw new ArgumentNullException("selector");
106109

107-
return from Match m in Regex.Matches(text)
110+
return from Match m in StackTraceRegexInstance.Matches(text)
108111
select m.Groups into groups
109112
let pt = groups["pt"].Captures
110113
let pn = groups["pn"].Captures

0 commit comments

Comments
 (0)