Command deserialization

September 8, 2022 ยท View on GitHub

Performance Benchmarks

Command deserialization

The build receives commands as JSON string and deserializes them into objects. This process is highly optimized within TDW.

JSON is known to be slower than other serialization formats. However, on the backend, JSON allows us to rapidly iterate, fix, and create commands. Switching to a different serialization format would take a tremendous amount of time and result in a faster but much more fragile API; we've decided that this is not a good tradeoff.

1. Command deserialization performance benchmark

The test controller sends increasing quantities of the command {"$type": "do_nothing"} for 1000 iterations. The build responds with an empty frame.

QuantitySize (bytes)FPS
125826
250857
4100867
8200847
16400821
32800781
641600717
1283200662
2566400611
51212800412
102425600316
204851200186

2. Struct deserialization

The test controller deserializes a Vector3 and a Quaternion per frame for 5000 frames. The build responds with an empty frame.

Result: 614 FPS

How to run TDW's deserialization performance benchmarks

  1. Follow instructions in the Benchmark document for cloning the repo, downloading the build, etc.
  2. cd path/to/tdw/Python/benchmarking (replace path/to with the actual path)
  3. python3 command_deserialization.py or python3 struct_deserialization.py
  4. Run the build
  5. Wait for the performance benchmark to complete (this might take up to five minutes).
  6. Compare your results to those listed above

Return to the README