felixguendling / cpp-serialization-benchmark Goto Github PK
View Code? Open in Web Editor NEWComparison of C++ Serialization Libraries for Graph Data
License: MIT License
Comparison of C++ Serialization Libraries for Graph Data
License: MIT License
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:
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); })));
}))));
}
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?
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.
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
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
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 .
Interesting... Congrats on your promising statistics!
You may want to consider adding the Bitsery library to your benchmarks.
DJuego
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.