Sandbox for testing different serialization mechanisms
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
beacon_chain @ 8a3cef6 Init repo; Add beacon_chain submodule; Aug 20, 2018
cpnp Implement timing results table Aug 29, 2018
fbuffers
helpers Add basic MsgPack serialization Aug 27, 2018
mpack
pbuf
pythonpickle
smp
.gitignore
.gitmodules Init repo; Add beacon_chain submodule; Aug 20, 2018
README.md
build.sh Consistency updates; Update README; Add Build; Comments Aug 21, 2018
main.py
requirements.txt
test.sh

README.md

Serialization Sandbox

A simple playground of different serialization types.

The objective of this repository is to provide a framework to choose different serialization mechanisms suitable for Ethereum.

TODOS

  • Information Tests
    • Basic structure serialization of default values
    • Basic structure serialization with maximum values
  • Benchmark (in-progress)
    • Time taken to serialize/deserialize default values
    • Time taken to serialize/deserialize max values
    • Benchmark of serialize/deserialize read/write patterns.
  • Profile of operations
    • CPU profiling
    • Memory profiling
  • Summarising report
    • Research and references
    • Overviews
    • Discussion

Notes

Differences exist between implementations - mainly depiction in each schema language.

  • AttestationRecord - aggregate signatures (bytes in Cap'n Proto and Simple, Uint64 in Protobuf)
  • Int256 - not depicted in protobuf, as bytes in cap'n proto.
  • Int vs Uint - there is discrepancies. The cap'n proto tried to follow the protobuf implementation and adhere to Uint.
  • There are some discrepancies between protobuf - it favours uints over some fields making it less to serialize.

Running the tests

Install dependencies

Install Python deps for the sandbox and Beacon Chain:

$ pip install -r requirements.txt
$ pip install -r beacon_chain/requirements.txt

Ensure git sub-modules are present:

$ git submodule init
$ git submodule update

Install flatc the FlatBuffers compiler. On Arch Linux, you can use the flatbuffers-static AUR package, other platforms should be well supported too.

Building the messages

Using the scripts

Note: running ./test.sh will also check and build files.

$ ./build.sh

Building yourself

Protobuf (requires protobuf : https://developers.google.com/protocol-buffers/ )

$ protoc -I=/path/to/repo/pbuf --python_out=/path/to/repo/pbuf /path/to/repo/pbuf/messages.proto

$ protoc -I=/path/to/repo/pbuf --python_out=/path/to/repo/pbuf /path/to/repo/pbuf/packedmessages.proto

FlatBuffers (reuqires flatbuffers: https://google.github.io/flatbuffers/ )

$ cd fbuffers

$ flatc messages.fbs --python

How to run

The test suite is split into two major commands:

  • message-size: compares the sizes of messages generated by various serializers.
  • timing: compares the running times of serialization/de-serialization operations.

Additionally there are some flags:

  -h, --help            show help message and exit
  -v, --verbose         Verbose (Show all prints)
  -ni, --no-info        Hide Informative Stats
  -r, --raw-output      Raw output as object instead of table
  -n REPEATS, --repeats REPEATS
                        Number of timeit repeats (only for timing).
  -l LOOPS, --loops LOOPS
                        Number of timeit loops (only for timing).

Message Size

$ python main.py message-size

Timing

$ python main.py timing

All

To run all tests:

$ ./test.sh

Advanced

To run each individual test, it requires python dependencies to be installed and runs with Python3.

Note: BeaconChain requirements build with Python 3.6.6 and will not compile on 3.7 as of 21/08/2018

$ pip install -r requirements.txt

$ python cpnp/info.py
$ python pbuf/info.py
$ python smp/info.py
...