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

Switch C# to contextual serializer and deserializer internally #17167

Merged

Conversation

jtattermusch
Copy link
Contributor

contextual (de)serializers have been introduced in #16367.
Serialization performance stays the same, but the switch is a foundation for introduction of more efficient serialization is in progress in #16371

@jtattermusch jtattermusch added lang/C# release notes: no Indicates if PR should not be in release notes labels Nov 9, 2018
@grpc-testing
Copy link

Objective-C binary sizes
*****************STATIC******************
  New size                      Old size
 2,019,040      Total (=)      2,019,040

 No significant differences in binary sizes

***************FRAMEWORKS****************
  New size                      Old size
11,179,730      Total (<)     11,179,733

 No significant differences in binary sizes


Copy link
Contributor

@apolcyn apolcyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks mostly good, a couple of minor nits

public abstract byte[] PayloadAsNewBuffer();
public virtual byte[] PayloadAsNewBuffer()
{
throw new NotImplementedException();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just wondering: why was this switched from abstract to having a default that's just unusable? Any DeserializationContext that doesn't implement this wouldn't work, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been done with the idea that in the future more methods will be added (e.g. to access the payload with more efficiency) and when added, they will be added as virtual methods with a default implementation so that the backward compatibility is not broken (=classes inheriting from DeserializationContext won't break if they don't provide implementation for all methods).
So I changed the method to virtual with default implementation mostly for consistency with the methods that will be added in the future.

public abstract void Complete(byte[] payload);
public virtual void Complete(byte[] payload)
{
throw new NotImplementedException();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment here as for the abstract -> default-throws comment on DeserializationContext above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

this.deserializer = EmulateSimpleDeserializer;
// gRPC only uses contextual serializer/deserializer internally, so emulating the legacy
// (de)serializer is not necessary.
this.serializer = (msg) => { throw new NotImplementedException(); };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just get rid of the serializer and deserializer fields entirely, since they are no longer used now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to keep the Serializer and Deserializer properties to maintain backward compatibility.
And the other constructor is setting the serializer and deserializer fields.

@jtattermusch
Copy link
Contributor Author

@apolcyn responded to concerns, PTAL.

@jtattermusch
Copy link
Contributor Author

Known failures: #17170

@jtattermusch jtattermusch added release notes: yes Indicates if PR needs to be in release notes and removed release notes: no Indicates if PR should not be in release notes labels Nov 15, 2018
@jtattermusch jtattermusch merged commit dc1bbf9 into grpc:master Nov 15, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Feb 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lang/C# release notes: yes Indicates if PR needs to be in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants