GitHub user djwatson opened a pull request: https://github.com/apache/thrift/pull/93
THRIFT-2429 Original diff summary: Add "terse_writes" c++ gen option to thrift compiler. Summary: Add "terse_writes" c++ generator option to thrift compiler, to suppress writing non-optional/non-required fields if they haven't changed from the default value. - This is default-off, whitelist-only. It may be whitelisted per-.thrift, or per struct. - On a Unicorn loadgen benchmark appeared to save roughly 2/3rds of the SearchRequest deserialization cost (fields are only sparsely set). - This will not affect embedded structs, or strings with non-"" default values, since we only want this change to do inexpensive integer-like comparisons. - Also, the user is advised that: - default values for whitelisted structs shouldn't be changed. (or, if they are, upgraded to optional/required) - if one re-read()s into an old struct, one should __clear() it first. however, this is not a new problem for anybody with optional fields. This diff introduces "safe" mode for `terse_writes` in order to prevent us from producing stupid bugs in PHP (and Python) land. If we don't require explicit default value to be set, we have to make PHP / Python logic to correctly understand `null` / `None` and treat them as default field values. davejwatson: It sounds like the proposal in THRIFT-2429 is to make this the default for optional fields as well, with no compiler flag, which is just minor changes to this diff. You can merge this pull request into a Git repository by running: $ git pull https://github.com/djwatson/thrift THRIFT-2429 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/thrift/pull/93.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #93 ---- commit 15dbcec763821b296a246c0b2572b410792a4809 Author: Dave Watson <davejwat...@fb.com> Date: 2014-04-01T22:24:37Z Original diff: Add "terse_writes" c++ gen option to thrift compiler. Summary: Add "terse_writes" c++ generator option to thrift compiler, to suppress writing non-optional/non-required fields if they haven't changed from the default value. - This is default-off, whitelist-only. It may be whitelisted per-.thrift, or per struct. - On a Unicorn loadgen benchmark appeared to save roughly 2/3rds of the SearchRequest deserialization cost (fields are only sparsely set). - This will not affect embedded structs, or strings with non-"" default values, since we only want this change to do inexpensive integer-like comparisons. - Also, the user is advised that: - default values for whitelisted structs shouldn't be changed. (or, if they are, upgraded to optional/required) - if one re-read()s into an old struct, one should __clear() it first. however, this is not a new problem for anybody with optional fields. This diff introduces "safe" mode for `terse_writes` in order to prevent us from producing stupid bugs in PHP (and Python) land. If we don't require explicit default value to be set, we have to make PHP / Python logic to correctly understand `null` / `None` and treat them as default field values. davejwatson: It sounds like the proposal in THRIFT-2429 is to make this the default for optional fields as well, with no compiler flag, which is just minor changes to this diff. ---- --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---