-
Notifications
You must be signed in to change notification settings - Fork 15.6k
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
[c#] Moved all message allocations to CreateTemplate(), making it easier to e.g. use pools to prevent GC load. #7722
Conversation
Moves all message allocations to CreateTemplate(), making it easier to e.g. use pools to prevent GC load.
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
@googlebot I signed it! |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
@@ -104,7 +104,7 @@ void MessageFieldGenerator::GenerateMergingCode(io::Printer* printer) { | |||
variables_, | |||
"if (other.$has_property_check$) {\n" | |||
" if ($has_not_property_check$) {\n" | |||
" $property_name$ = new $type_name$();\n" | |||
" $property_name$ = $type_name$.Parser.CreateTemplate();\n" |
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.
after changing the codegen, you'd also need to regenerate the code in this repository.
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.
= do a build ?
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.
Build and then run https://github.com/protocolbuffers/protobuf/blob/master/csharp/generate_protos.sh.
The updates to the generated files need to be commited (preferrably as a separate commit)
@@ -60,7 +60,7 @@ internal MessageParser(Func<IMessage> factory, bool discardUnknownFields, Extens | |||
/// Creates a template instance ready for population. | |||
/// </summary> | |||
/// <returns>An empty message.</returns> | |||
internal IMessage CreateTemplate() | |||
public IMessage CreateTemplate() |
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.
👍
@@ -104,7 +104,7 @@ void MessageFieldGenerator::GenerateMergingCode(io::Printer* printer) { | |||
variables_, | |||
"if (other.$has_property_check$) {\n" | |||
" if ($has_not_property_check$) {\n" | |||
" $property_name$ = new $type_name$();\n" | |||
" $property_name$ = $type_name$.Parser.CreateTemplate();\n" |
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.
What is the overhead of using Parser.CreateTemplate?
Is there a good way of checking that we haven't missed any occurrences of |
One potential concern is that if this gets merged, the newly generated code won't be compatible with the older runtimes anymore (there is no public CreateTemplate() method). |
@ManuelKugelmann I am going to close this since there has been no activity in a long time, but please feel free to comment here if you would like to pick this up again. |
@jtattermusch I have issued #19776 to only change the visibility of the CreateTemplate() method. |
fixes #6401