Skip to content

Commit 1b746dd

Browse files
committed
Improve main loop pipeline
Move the new branchless core-heavy number parsing ahead of branchy dictionary lookup so that the pipeline is busy while we are searching for the slot. Note that when using the previous branchy parser in this position the performance drops a lot, while in the previous position after the lookup the perf delta was much smaller.
1 parent 0e1ba26 commit 1b746dd

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

‎1brc/App.cs‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,9 @@ public static unsafe void ProcessSpan(FixedDictionary<Utf8Span, Summary> result,
320320
while (remaining.Length > 0)
321321
{
322322
nuint idx = remaining.IndexOfSemicolon();
323-
324-
result.GetValueRefOrAddDefault(new Utf8Span(remaining.Pointer, idx)).Apply(remaining.ParseIntBranchless(idx, out idx));
325-
326-
remaining = remaining.SliceUnsafe(idx);
323+
nint value = remaining.ParseIntBranchless(idx, out var idx1);
324+
result.GetValueRefOrAddDefault(new Utf8Span(remaining.Pointer, idx)).Apply(value);
325+
remaining = remaining.SliceUnsafe(idx1);
327326
}
328327
}
329328

0 commit comments

Comments
 (0)