this parallel hashmap implementation is the basis of CCash, its where all the user data is stored, compared to the STD's std::unordered_map<T>
its much faster, this, multi threading support, and more can be found in the writeup.
xxhash is used for both hashing of passwords for storage aswell as the usernames for indexing the phmap, its speed is ridiculous at faster then memcpy
rates of Gb/s.
Hash Name | Width | Bandwidth (GB/s) |
---|---|---|
XXH3 (SSE2) | 64 | 31.5 GB/s |
RAM sequential read | N/A | 28.0 GB/s |
base64 decoding is required for Basic Auth so I used this clean and fast solution which uses SIMD.
simdjson was the fastest JSON parsing I could find, its used for request parsing.
at the time of making this doc Drogon is the 3rd fastest web framework as per this sites metric of measuring web frameworks, it also has multi threading support.
when the program is interupted with CONTROL + C it will save before closing the webserver, it will not however save during a crash.
every n
minutes, a configurable amount at launch, CCash will save.
for the above two cases, it will only save to disk if changes have been made since last save.
saving is done using FBE, this slightly reduces file size compared to JSON and is much faster.
Protocol | Message size | Serialization time | Deserialization time |
---|---|---|---|
Cap'n'Proto | 208 bytes | 558 ns | 359 ns |
FastBinaryEncoding | 234 bytes | 66 ns | 82 ns |
FlatBuffers | 280 bytes | 830 ns | 290 ns |
Protobuf | 120 bytes | 628 ns | 759 ns |
JSON | 301 bytes | 740 ns | 500 ns |
considering phmap and drogon both massively benefit from being multi-threaded it seemed obvious that the entire program should be, this is enabled by default and manually settable at MULTI_THREADED
.