Code Monkey home page Code Monkey logo

cpp-serialization-benchmark's People

Contributors

eyalz800 avatar felixguendling avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

eyalz800 peizelin

cpp-serialization-benchmark's Issues

A kind request to update the results + some potential issues that could be with measurement

Hi,

So I finally had some time to read the code in the benchmark, and I wanted to get your opinion about some issues that I think are there and maybe you can help me understand the right behavior and correct me:

  1. In flatbuffers fbs.h, it seems that the creation of the graph is also measured with measuring serialize:
  void serialize() {
    auto const edges = utl::to_map(GRAPH.edges_, [&](auto&& e) {
      return std::pair{e.get(), graph::CreateEdge(fbb_, e->from_->id_,
                                                  e->to_->id_, e->weight_)};
    });
    fbb_.Finish(graph::CreateGraph(
        fbb_, fbb_.CreateVector(utl::to_vec(GRAPH.nodes_, [&](auto&& n) {
          return graph::CreateNode(
              fbb_, n->id_, fbb_.CreateString(n->name_),
              fbb_.CreateVector(utl::to_vec(
                  n->out_edges_, [&](auto&& e) { return edges.at(e); })),
              fbb_.CreateVector(utl::to_vec(
                  n->in_edges_, [&](auto&& e) { return edges.at(e); })));
        }))));
  }
  1. This is also true for capnproto -
void serialize() {
    capnp::MallocMessageBuilder message;
    auto graph = message.initRoot<Graph>();
    auto nodes = graph.initNodes(GRAPH.nodes_.size());

    auto node_idx = 0u;
    for (auto const& n : GRAPH.nodes_) {
      auto node = nodes[node_idx++];

      node.setId(n->id_);
      node.setName(n->name_);

      auto edge_idx = 0u;
      auto in_edges = node.initInEdges(n->in_edges_.size());
      for (auto const& e : n->in_edges_) {
        auto edge = in_edges[edge_idx++];
        edge.setFrom(e->from_->id_);
        edge.setTo(e->to_->id_);
        edge.setWeight(e->weight_);
      }

      edge_idx = 0;
      auto out_edges = node.initOutEdges(n->out_edges_.size());
      for (auto const& e : n->out_edges_) {
        auto edge = out_edges[edge_idx++];
        edge.setFrom(e->from_->id_);
        edge.setTo(e->to_->id_);
        edge.setWeight(e->weight_);
      }
    }

    serialized_ = capnp::messageToFlatArray(message);
  }

Most other libraries, including cista itself do not have this counted, meaning only the serialization is measured, I know serialization is supposed to be zero copy for some of the libraries including cista, so wouldn't it make more sense to include construction times for all serializers (both zero copy and non zero-copy)?
Can you help me understand the benchmark approach to that?

Super fast?

I have run the benchmarks and cista_offset_slim_bench serialization looks super fast . Could this serialization be 14 times faster than cap'n proto comparing to your result where it was 1.4 times faster than cap'n proto? Or is there a glitch? I didn't debugged it.

serialize_size of fbs_bench can't be recurrenced

Thanks for your Reply

I'm building the repo with GCC 9.3

โžœ  build git:(master) gcc --version
gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Run benchmark at my PC or Cloud Machine the serialize_size of fbs_bench Only 62.998M while benchmark_result.txt declaring 378.018M , but the serialize_size of cista_raw_bench is nearly same.
my result

BM_SERIALIZE<fbs_bench>                                         3951 ms         3938 ms            1 size=62.998M 
BM_SERIALIZE<cista_raw_bench>                                   1827 ms         1828 ms            1 size=176.378M
BM_SERIALIZE<cista_offset_bench>                                1846 ms         1844 ms            1 size=176.378M

benchmark_result.txt

BM_SERIALIZE<fbs_bench>                                         2349 ms         2349 ms            6 size= 378.018M
BM_SERIALIZE<cista_raw_bench>                                   3555 ms         3555 ms            4 size=176.396M
BM_SERIALIZE<cista_offset_bench>                                3494 ms         3493 ms            4 size=176.396M

full result showing as below

2020-09-04 18:08:30
Running ./cpp-serialization-benchmark
Run on (8 X 2400 MHz CPU s)
Load Average: 0.52, 0.58, 0.59
---------------------------------------------------------------------------------------------------------------------
Benchmark                                                          Time             CPU   Iterations UserCounters...
---------------------------------------------------------------------------------------------------------------------
BM_SERIALIZE<capnp_bench>                                        168 ms          172 ms            3 size=50.5093M
BM_SERIALIZE<cista_offset_slim_bench>                           9.26 ms         9.42 ms           78 size=25.317M
BM_SERIALIZE<cereal_bench>                                       264 ms          266 ms            3 size=37.829M
BM_SERIALIZE<fbs_bench>                                         3951 ms         3938 ms            1 size=62.998M
BM_SERIALIZE<cista_raw_bench>                                   1827 ms         1828 ms            1 size=176.378M
BM_SERIALIZE<cista_offset_bench>                                1846 ms         1844 ms            1 size=176.378M
BM_SAFE_DESERIALIZE<capnp_bench>                               0.002 ms        0.002 ms       373333
BM_SAFE_DESERIALIZE<cista_offset_slim_bench>                   0.259 ms        0.256 ms         2987
BM_SAFE_DESERIALIZE<fbs_bench>                                  78.1 ms         78.1 ms            9
BM_SAFE_DESERIALIZE<cista_offset_bench>                          355 ms          352 ms            2
BM_SAFE_DESERIALIZE<cista_raw_bench>                             539 ms          547 ms            1
BM_SAFE_DESERIALIZE<cereal_bench>                                202 ms          203 ms            3
BM_FAST_DESERIALIZE<cista_raw_bench>                            53.8 ms         57.8 ms           10
BM_TRAVERSE<cista_raw_bench>                                     244 ms          240 ms            3 nodeCount=1.87k
BM_TRAVERSE<cista_offset_slim_bench>                             238 ms          240 ms            3 nodeCount=1.87k
BM_TRAVERSE<cista_offset_bench>                                  236 ms          229 ms            3 nodeCount=1.87k
BM_TRAVERSE<cereal_bench>                                        252 ms          250 ms            3 nodeCount=1.87k
BM_TRAVERSE<fbs_bench>                                           266 ms          255 ms            3 nodeCount=1.87k
BM_TRAVERSE<capnp_bench>                                         424 ms          430 ms            2 nodeCount=1.87k
BM_FAST_DESERIALIZE_AND_TRAVERSE<cista_offset_slim_bench>        204 ms          208 ms            3 nodeCount=1.87k
BM_FAST_DESERIALIZE_AND_TRAVERSE<cista_offset_bench>             208 ms          208 ms            3 nodeCount=1.87k
BM_FAST_DESERIALIZE_AND_TRAVERSE<cista_raw_bench>                264 ms          266 ms            3 nodeCount=1.87k
BM_FAST_DESERIALIZE_AND_TRAVERSE<fbs_bench>                      244 ms          245 ms            3 nodeCount=1.87k
BM_FAST_DESERIALIZE_AND_TRAVERSE<cereal_bench>                   401 ms          406 ms            2 nodeCount=1.87k
BM_FAST_DESERIALIZE_AND_TRAVERSE<capnp_bench>                    355 ms          359 ms            2 nodeCount=1.87k

cannot take address of bit-field with newest cista

when build with cista 0.7, the compile make an error
cannot take address of bit-field
SO I redefine the code

 struct slim_graph {
   using string_t = cista::offset::string;
 
   struct edge {
-    uint32_t from_ : 11;
-    uint32_t to_ : 11;
-    uint32_t weight_ : 10;
+    uint32_t from_;
+    uint32_t to_;
+    uint32_t weight_;
   };

so pls update the benchmark to the newest .

Comparison with Bitsery

Interesting... Congrats on your promising statistics!

You may want to consider adding the Bitsery library to your benchmarks.

DJuego

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.