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

Lazily Create Singular Wrapper Message #6833

Merged
merged 21 commits into from Nov 14, 2019

Conversation

TeBoring
Copy link
Contributor

@TeBoring TeBoring commented Nov 1, 2019

In order to mimic proto2 presence semantic in proto3, some users use lots of well known wrapper to replace primitive fields. This causes the problem of performance, because object creation is expensive.

This change lazily creates wrapper objects, which saves lots of time for unnecessary object creation/deletion.

In order to use the new feature, users needs to use the protoc in this change to update their generated code. However, old generated code is still compatible with the new runtime.

@TeBoring TeBoring changed the title Lazily Create Singular Wrapper Message Lazily Create Singular Wrapper Message [WIP] Nov 1, 2019
@TeBoring TeBoring changed the title Lazily Create Singular Wrapper Message [WIP] Lazily Create Singular Wrapper Message Nov 13, 2019
Copy link
Contributor

@stanley-cheung stanley-cheung left a comment

Choose a reason for hiding this comment

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

Can you also document the motivation of this PR please (a few paragraphs in the PR summary would suffice)? It seems that it has to do with the usage of well known wrapper to replace primitive fields, and to improve performance for object creation by lazily creating these wrapper objects. But it isn't clear from just the PR title.

Please also document that there are protoc code generator changes but things are backward compatible.

php/ext/google/protobuf/encode_decode.c Show resolved Hide resolved
php/ext/google/protobuf/encode_decode.c Show resolved Hide resolved
php/ext/google/protobuf/encode_decode.c Show resolved Hide resolved
php/src/Google/Protobuf/Internal/Message.php Show resolved Hide resolved
php/ext/google/protobuf/upb.c Show resolved Hide resolved
@TeBoring TeBoring merged commit 601f696 into protocolbuffers:master Nov 14, 2019
@TeBoring TeBoring deleted the php-optimization branch November 14, 2019 20:17
nlhien pushed a commit to nlhien/protobuf that referenced this pull request Feb 28, 2020
* Register additional handlers from wrappers

* Return zval instead of parse frame

* Use parse frame

* Update upb

* Lazily create wrapper messages

* Fix a segment fault

Need check type of field before getting submsg def

* Avoid expanding during serialization and direct access

* Fix a bug that getXXXUnwrapped returns null for string

* Implement writeWrapperUnwrapped

* Add more tests

* Fix oneof wrapper parsing

* Fix get oneof field

* Avoid expansion for oneof wrappers

* Fix bug

* Fix a bug that in php7 variable is defined out of scope

* Fix broken tests
 * Update upb to fix Timestamp conformance tests
 * Fix segmentation fault for oneof wrapper fields

* Fix encoding/decoding top level wrapper values

* Add type checking for write wrapper value in php7

* Fix zts build

* Fix the bug that readWrapperValue uses parent message's layout to access wrapper value

* Fix wrapper in map
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants