Terse Write Benchmark
commit5c193772d3e102d566859496093577b427830654
authorDave Kwon <dokwon@meta.com>
Tue, 7 Feb 2023 23:06:44 +0000 (7 15:06 -0800)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Tue, 7 Feb 2023 23:06:44 +0000 (7 15:06 -0800)
treee7c3c2a287c99332d05c3f2fc937178e61ebc4ca
parent9ff80fad92182c71d8c3b588a587c72d4436add1
Terse Write Benchmark

Summary:
Create Terse Write Benchmark.
* `N` indicates # of fields.
* `struct_N`: all fields are unqualified
* `terse_struct_N_empty`: all fields are terse and empty
* `terse_struct_N_half_filled`: all fields are terse and half of fields are not empty
* `terse_struct_N_filled`: all fields are terse and not empty
* `terse_struct_N_first_element_nonempty`: all fields are terse. All fields except for the first field is empty.
* `terse_struct_N_middle_element_nonempty`: all fields are terse. All fields except for the middle field is empty.
* `terse_struct_N_last_element_nonempty`: all fields are terse. All fields except for the last field is empty.

Comparison:
* `struct_N` and `terse_struct_N_empty` compare performance empty terse struct.
* `struct_N` and `terse_struct_N_filled` compare performance of non-empty terse fields and overhead of empty check.
* `terse_struct_N` and `terse_struct_N_last_element_nonempty` compare the worst case empty check where duplicate empty check happens due to one non-empty field.

This shows terse write struct optimization actually penalize the sparse struct, and it is significantly worse for the low-level of nested structs.

Analysis:
* When N < 32, empty terse struct is more expensive since rewinding buffer is expensive.

Reviewed By: iahs

Differential Revision: D41089722

fbshipit-source-id: d17c6e6763632c498bb5d26a2b4ba5256d4c7341
third-party/thrift/src/thrift/test/benchmarks/terse_write_benchmark.cpp [new file with mode: 0644]
third-party/thrift/src/thrift/test/benchmarks/terse_write_benchmark.thrift [new file with mode: 0644]