change extractMaskFromPatch to return readMask and writeMask
commit9c0ce32b713500b0e26e851ae91a3ad54be15fe8
authorAmi Oka <aoka@fb.com>
Fri, 9 Sep 2022 20:06:34 +0000 (9 13:06 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Fri, 9 Sep 2022 20:06:34 +0000 (9 13:06 -0700)
tree055f6121d8b26224c481cf948de626b19fdf0c43
parent4393f32c5a2420d8795bd378c4d90252db68161b
change extractMaskFromPatch to return readMask and writeMask

Summary:
Changed extractMaskFromPatch to return readMask and writeMask. ReadMask contains the fields that need to be read, and writeMask contains the fields that will be written when applying the patch. Note that readMask is subset of writeMask. This is used in `applyPatchToSerializedData`, and the benchmark shows that this will greatly improve the runtime if the patch clears the large fields (testcase 4).

```
============================================================================
AppplyPatchToSerializedDataBenchmark.cpp        relative  time/iter   iters/s
============================================================================
patch_few_small_fields_without_partial_deser               17.59ms     56.85
patch_few_small_fields_with_partial_deser                 121.65us     8.22K
patch_large_fields_without_partial_deser                   16.23ms     61.60
patch_large_fields_with_partial_deser                      16.38ms     61.04
patch_all_small_fields_without_partial_deser              133.46ms      7.49
patch_all_small_fields_with_partial_deser                 324.74ms      3.08
patch_clear_large_fields_without_partial_deser              7.35ms    135.97
patch_clear_large_fields_with_partial_deser                84.82us    11.79K
```

Reviewed By: Mizuchi

Differential Revision: D39222760

fbshipit-source-id: 202c6e22dc7595e94701bb027422e3569082d254
third-party/thrift/src/thrift/lib/cpp2/protocol/Patch.cpp
third-party/thrift/src/thrift/lib/cpp2/protocol/Patch.h
third-party/thrift/src/thrift/lib/cpp2/protocol/PatchTest.cpp