Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use F14NodeMap for Protocol Object fields
Summary: `F14NodeMap` is a better choice since we don't know the field size in advance and this will not lead us to reallocate the values in map. In general we see improvement in deserialization and serialization. The extreme test case of `LargeMixed` show improvement in deserialization but regression in serialization but since deserialization is generally much slower than serialization (~x5), this is a fair trade-off. benchmark result: // More general -> ~34% improvement in deserialization of ComplexStruct // -> Slight improvement in serialization in general ``` // before ============================================================================================= fbcode/thrift/lib/cpp2/test/ProtocolBench.cpp relative time/iter iters/s serialized_size ============================================================================================= ObjectBinaryProtocol_write_BigListMixed 659.54us 1.52K NaN ObjectBinaryProtocol_read_BigListMixed 3.11ms 322.00 500009 ObjectBinaryProtocol_write_BigListMixedInt 1.27ms 790.12 NaN ObjectBinaryProtocol_read_BigListMixedInt 6.70ms 149.29 850009 ObjectBinaryProtocol_write_LargeMapMixed 145.46ms 6.87 NaN ObjectBinaryProtocol_read_LargeMapMixed 655.77ms 1.52 54000010 ObjectBinaryProtocol_write_ComplexStruct 160.19ms 6.24 NaN ObjectBinaryProtocol_read_ComplexStruct 876.82ms 1.14 59006614 ObjectCompactProtocol_write_BigListMixed 799.68us 1.25K NaN ObjectCompactProtocol_read_BigListMixed 3.85ms 259.58 300005 ObjectCompactProtocol_write_BigListMixedInt 1.77ms 563.70 NaN ObjectCompactProtocol_read_BigListMixedInt 7.27ms 137.47 720005 ObjectCompactProtocol_write_LargeMapMixed 150.58ms 6.64 NaN ObjectCompactProtocol_read_LargeMapMixed 687.48ms 1.45 32991750 ObjectCompactProtocol_write_ComplexStruct 177.33ms 5.64 NaN ObjectCompactProtocol_read_ComplexStruct 846.40ms 1.18 38637929 ============================================================================================= ``` ``` // after ============================================================================================= fbcode/thrift/lib/cpp2/test/ProtocolBench.cpp relative time/iter iters/s serialized_size ============================================================================================= ObjectBinaryProtocol_write_BigListMixed 616.31us 1.62K NaN ObjectBinaryProtocol_read_BigListMixed 2.82ms 355.18 500009 ObjectBinaryProtocol_write_BigListMixedInt 1.35ms 738.65 NaN ObjectBinaryProtocol_read_BigListMixedInt 7.88ms 126.87 850009 ObjectBinaryProtocol_write_LargeMapMixed 124.44ms 8.04 NaN ObjectBinaryProtocol_read_LargeMapMixed 526.60ms 1.90 54000010 ObjectBinaryProtocol_write_ComplexStruct 128.39ms 7.79 NaN ObjectBinaryProtocol_read_ComplexStruct 580.06ms 1.72 59006614 ObjectCompactProtocol_write_BigListMixed 743.84us 1.34K NaN ObjectCompactProtocol_read_BigListMixed 3.98ms 251.40 300005 ObjectCompactProtocol_write_BigListMixedInt 1.79ms 557.80 NaN ObjectCompactProtocol_read_BigListMixedInt 10.49ms 95.34 720005 ObjectCompactProtocol_write_LargeMapMixed 126.08ms 7.93 NaN ObjectCompactProtocol_read_LargeMapMixed 492.39ms 2.03 32991750 ObjectCompactProtocol_write_ComplexStruct 139.44ms 7.17 NaN ObjectCompactProtocol_read_ComplexStruct 557.91ms 1.79 38637929 ============================================================================================= ``` // LargeMixed -> ~37% improvement in deserialization and ~29% regression in serialization ``` // before ============================================================================================= fbcode/thrift/lib/cpp2/test/ProtocolBench.cpp relative time/iter iters/s serialized_size ============================================================================================= ObjectBinaryProtocol_write_LargeMixed 1.13us 888.40K NaN ObjectBinaryProtocol_read_LargeMixed 6.09us 164.27K 851 ObjectCompactProtocol_write_LargeMixed 1.50us 668.54K NaN ObjectCompactProtocol_read_LargeMixed 5.75us 174.04K 351 ============================================================================================= ``` ``` // after ============================================================================================= fbcode/thrift/lib/cpp2/test/ProtocolBench.cpp relative time/iter iters/s serialized_size ============================================================================================= ObjectBinaryProtocol_write_LargeMixed 1.46us 682.76K NaN ObjectBinaryProtocol_read_LargeMixed 3.84us 260.13K 851 ObjectCompactProtocol_write_LargeMixed 1.81us 550.97K NaN ObjectCompactProtocol_read_LargeMixed 3.96us 252.25K 351 ============================================================================================= ``` Reviewed By: Mizuchi Differential Revision: D62352362 fbshipit-source-id: d00cb613dba749bf9bc5f74bad58b408b1155ecc
- Loading branch information