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

THRIFT-2429 #93

Closed
wants to merge 1 commit into from
Closed

THRIFT-2429 #93

wants to merge 1 commit into from

Conversation

djwatson
Copy link

@djwatson djwatson commented Apr 2, 2014

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.

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.
@asfbot
Copy link

asfbot commented May 30, 2014

Build triggered. Test FAILed.

@jeking3
Copy link
Contributor

jeking3 commented Jan 24, 2018

This pull request is being closed due to lack of activity.
You can re-open it after rebasing on the current master if you would like it to be reconsidered.

@asfgit asfgit closed this in 8d96b3b Jan 24, 2018
jeking3 added a commit to jeking3/thrift that referenced this pull request Mar 10, 2018
This closes apache#93
This closes apache#326
This closes apache#345
This closes apache#352
This closes apache#353
This closes apache#383
This closes apache#395
This closes apache#413
This closes apache#488
This closes apache#555
This closes apache#624
This closes apache#731
This closes apache#747
This closes apache#756
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants