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
Speculative optimization: Use custom string serializer for Type #192
Conversation
It seems that the generic text proto CompactStringMarshal is more expensive that hand-made one.
I'm not necessarily opposed to the change, but could you give more context about the expected impact/benefit to tests, execution, and performance? |
Sure:
|
The reason seems to be excessive allocations caused by standard protobuf. String() indirectly marshals the protos, and the mashaller is fairly expensive. |
Thanks for the info. Let's merge it as long as it doesn't impact the checking logic in any way. |
I examined FormatCheckedType and it seems to be creating unique strings for distinct types. That assumes no obvious collisions, such as naming a proto "dyn". Let me know if you want to extend this further to disambiguate between proto "dyn" and dynamic "dyn". |
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.
I don't think there's any need to differentiate the dyn
types. They should be treated identically here.
Sorry, I wasn't clear. I can in theory create a proto with:
in which case "dyn" is ambiguous between object type "dyn" and type "dyn". Frankly, noone should do it, but we can be more cautious in this function. |
While that is possible, it would be pretty nutty. If you want to add a
precondition check to prevent adding a proto with that name that seems
reasonable
…On Thu, Mar 28, 2019, 2:15 PM Kuat ***@***.***> wrote:
Sorry, I wasn't clear. I can in theory create a proto with:
message dyn { }
in which case "dyn" is ambiguous between object type "dyn" and type "dyn".
Frankly, noone should do it, but we can be more cautious in this function.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#192 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAdf5ICYey8mmPA5kckM_YL3WvkCRW5sks5vbTDmgaJpZM4cQowu>
.
|
Doing something like that will cause "check" to misbehave and reject the expression, so I guess the outcome is right -- don'to do nutty things. |
It seems that the generic text proto CompactStringMarshal is more expensive that hand-made one.
Looking for feedback. I think we probably want to use a Struct as a hashmap key, but that would require building a new family of structs mirroring Types, since using proto Type does not seem to work.