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
Improve performance of parsing repeated fixed sized types #7412
Improve performance of parsing repeated fixed sized types #7412
Conversation
#7351 was merged, please rebase. |
d0d576e
to
578aa1d
Compare
@@ -50,9 +50,9 @@ public static ReadOnlySequence<byte> CreateWithContent(byte[] data, int segmentS | |||
while (currentIndex < data.Length) | |||
{ | |||
var segment = new List<byte>(); | |||
for (; currentIndex < Math.Min(currentIndex + segmentSize, data.Length); currentIndex++) | |||
while (segment.Count < segmentSize && currentIndex < data.Length) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI there was a bug here that created a sequence that started and ended with empty segments, but the actual content was a single segment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this is looking good, but left a few comments.
Thanks for the contribution!
csharp/src/Google.Protobuf.Benchmarks/ParseMessagesBenchmark.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Mergable now that #7490 is resolved? @jtattermusch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a very minor nit in the tests.
@@ -50,9 +50,9 @@ public static ReadOnlySequence<byte> CreateWithContent(byte[] data, int segmentS | |||
while (currentIndex < data.Length) | |||
{ | |||
var segment = new List<byte>(); | |||
for (; currentIndex < Math.Min(currentIndex + segmentSize, data.Length); currentIndex++) | |||
while (segment.Count < segmentSize && currentIndex < data.Length) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix!
ba2bc4e
to
acc49aa
Compare
e5de912
to
921bdaa
Compare
Based on #7351. Will rebase on master once it is merged.
Actual changes: JamesNK@d0d576e
@jtattermusch
Before:
After: