Go to file
Paul Dreik d3f0e2afb3
[no ci] remove references to bintray (#1702)
* download fuzz corpus from www.pauldreik.se

* remove reference to bintray
2021-08-19 08:39:07 -04:00
.circleci This cleans a bit the current code, especially with respect to EOF guards. (#1669) 2021-07-25 10:36:22 -04:00
.github Adding CI for old LLVM in GitHub Actions (#1672) 2021-07-26 08:37:29 -04:00
.vscode Makes it possible to cast a document to a value. (#1690) 2021-08-11 20:02:30 -04:00
benchmark Reduce #include bloat (<iostream>) (#1697) 2021-08-13 11:24:36 -04:00
cmake This cleans a bit the current code, especially with respect to EOF guards. (#1669) 2021-07-25 10:36:22 -04:00
dependencies This deletes most of our data files making the repository much smaller (#1582) 2021-06-04 09:24:03 -04:00
doc [no ci] removing space 2021-08-17 08:35:21 -04:00
examples Reduce #include bloat (<iostream>) (#1697) 2021-08-13 11:24:36 -04:00
extra Removing all stdout, stderr from main library. (#455) 2020-01-20 16:03:15 -05:00
fuzz [no ci] remove references to bintray (#1702) 2021-08-19 08:39:07 -04:00
images Improving the doxygen. (#687) 2020-04-08 17:53:04 -04:00
include Reduce #include bloat (<iostream>) (#1697) 2021-08-13 11:24:36 -04:00
jsonexamples This deletes most of our data files making the repository much smaller (#1582) 2021-06-04 09:24:03 -04:00
scripts remove trailing whitespace (#1284) 2020-11-03 21:48:09 +01:00
singleheader This will update the amalgamate_demo.cpp file to use On Demand. (#1689) 2021-08-07 12:43:40 -04:00
src Makes it possible to cast a document to a value. (#1690) 2021-08-11 20:02:30 -04:00
style Hiding the pointer away... (#252) 2019-08-04 15:41:00 -04:00
tests Reduce #include bloat (<iostream>) (#1697) 2021-08-13 11:24:36 -04:00
tools fix serveral typos (#1558) 2021-05-01 10:19:53 -04:00
windows This adds /permissive- to recent visual studio builds (#1596) 2021-06-01 10:57:37 -04:00
.appveyor.yml This cleans a bit the current code, especially with respect to EOF guards. (#1669) 2021-07-25 10:36:22 -04:00
.cirrus.yml Add test for out-of-order parse asserts 2020-12-13 13:39:47 -08:00
.clang-format We are adopting clang-format. 2019-08-01 15:40:07 -04:00
.dockerignore move amalgamate from bash to python (#1278) 2020-11-03 07:35:16 +01:00
.drone.yml Get fuzzing working again (#1646) 2021-07-05 09:42:57 +02:00
.gitattributes Diff json using text diff 2021-06-23 12:28:03 -06:00
.gitignore Add basic workspace configuration for vscode 2021-06-23 12:28:00 -06:00
.travis.yml This attempts to fix the fuzzers. (#1564) 2021-05-07 22:59:26 -04:00
AUTHORS Update AUTHORS 2020-04-30 19:49:20 -04:00
CMakeLists.txt This deletes most of our data files making the repository much smaller (#1582) 2021-06-04 09:24:03 -04:00
CONTRIBUTING.md fix serveral typos (#1558) 2021-05-01 10:19:53 -04:00
CONTRIBUTORS Update CONTRIBUTORS (#1560) 2021-05-02 12:30:25 -04:00
Doxyfile Version 0.9.1 2021-03-18 11:31:38 -04:00
HACKING.md Removes docker file which is unused and untested, and updates the path to dom/parse. 2021-05-01 10:31:00 -04:00
LICENSE Updating again. 2019-02-08 10:05:50 -05:00
README.md [no ci] Adding new "include <iostream>" lines in the documentation following the recent removal of iostream from our headers. 2021-08-13 11:23:16 -04:00
RELEASES.md release candidate (#1132) 2020-08-19 18:12:23 -04:00

README.md

Ubuntu 18.04 CI Ubuntu 20.04 CI VS16-CI MinGW64-CI Doxygen Documentation

simdjson : Parsing gigabytes of JSON per second

JSON is everywhere on the Internet. Servers spend a *lot* of time parsing it. We need a fresh approach. The simdjson library uses commonly available SIMD instructions and microparallel algorithms to parse JSON 4x faster than RapidJSON and 25x faster than JSON for Modern C++.
  • Fast: Over 4x faster than commonly used production-grade JSON parsers.
  • Record Breaking Features: Minify JSON at 6 GB/s, validate UTF-8 at 13 GB/s, NDJSON at 3.5 GB/s.
  • Easy: First-class, easy to use and carefully documented APIs.
  • Strict: Full JSON and UTF-8 validation, lossless parsing. Performance with no compromises.
  • Automatic: Selects a CPU-tailored parser at runtime. No configuration needed.
  • Reliable: From memory allocation to error handling, simdjson's design avoids surprises.
  • Peer Reviewed: Our research appears in venues like VLDB Journal, Software: Practice and Experience.

This library is part of the Awesome Modern C++ list.

Table of Contents

Quick Start

The simdjson library is easily consumable with a single .h and .cpp file.

  1. Prerequisites: g++ (version 7 or better) or clang++ (version 6 or better), and a 64-bit system with a command-line shell (e.g., Linux, macOS, freeBSD). We also support programming environments like Visual Studio and Xcode, but different steps are needed.

  2. Pull simdjson.h and simdjson.cpp into a directory, along with the sample file twitter.json.

    wget https://raw.githubusercontent.com/simdjson/simdjson/master/singleheader/simdjson.h https://raw.githubusercontent.com/simdjson/simdjson/master/singleheader/simdjson.cpp https://raw.githubusercontent.com/simdjson/simdjson/master/jsonexamples/twitter.json
    
  3. Create quickstart.cpp:

#include <iostream>
#include "simdjson.h"
using namespace simdjson;
int main(void) {
    ondemand::parser parser;
    padded_string json = padded_string::load("twitter.json");
    ondemand::document tweets = parser.iterate(json);
    std::cout << uint64_t(tweets["search_metadata"]["count"]) << " results." << std::endl;
}

  1. c++ -o quickstart quickstart.cpp simdjson.cpp
  2. ./quickstart
    100 results.
    

Documentation

Usage documentation is available:

  • Basics is an overview of how to use simdjson and its APIs.
  • Performance shows some more advanced scenarios and how to tune for them.
  • Implementation Selection describes runtime CPU detection and how you can work with it.
  • API contains the automatically generated API documentation.

Performance results

The simdjson library uses three-quarters less instructions than state-of-the-art parser RapidJSON. To our knowledge, simdjson is the first fully-validating JSON parser to run at gigabytes per second (GB/s) on commodity processors. It can parse millions of JSON documents per second on a single core.

The following figure represents parsing speed in GB/s for parsing various files on an Intel Skylake processor (3.4 GHz) using the GNU GCC 10 compiler (with the -O3 flag). We compare against the best and fastest C++ libraries on benchmarks that load and process the data. The simdjson library offers full unicode (UTF-8) validation and exact number parsing.

The simdjson library offers high speed whether it processes tiny files (e.g., 300 bytes) or larger files (e.g., 3MB). The following plot presents parsing speed for synthetic files over various sizes generated with a script on a 3.4 GHz Skylake processor (GNU GCC 9, -O3).

All our experiments are reproducible.

For NDJSON files, we can exceed 3 GB/s with our multithreaded parsing functions.

Real-world usage

If you are planning to use simdjson in a product, please work from one of our releases.

Bindings and Ports of simdjson

We distinguish between "bindings" (which just wrap the C++ code) and a port to another programming language (which reimplements everything).

About simdjson

The simdjson library takes advantage of modern microarchitectures, parallelizing with SIMD vector instructions, reducing branch misprediction, and reducing data dependency to take advantage of each CPU's multiple execution cores.

Some people enjoy reading our paper: A description of the design and implementation of simdjson is in our research article:

We have an in-depth paper focused on the UTF-8 validation:

We also have an informal blog post providing some background and context.

For the video inclined,
simdjson at QCon San Francisco 2019
(It was the best voted talk, we're kinda proud of it.)

Funding

The work is supported by the Natural Sciences and Engineering Research Council of Canada under grant number RGPIN-2017-03910.

Contributing to simdjson

Head over to CONTRIBUTING.md for information on contributing to simdjson, and HACKING.md for information on source, building, and architecture/design.

License

This code is made available under the Apache License 2.0.

Under Windows, we build some tools using the windows/dirent_portable.h file (which is outside our library code): it under the liberal (business-friendly) MIT license.

For compilers that do not support C++17, we bundle the string-view library which is published under the Boost license. Like the Apache license, the Boost license is a permissive license allowing commercial redistribution.

For efficient number serialization, we bundle Florian Loitsch's implementation of the Grisu2 algorithm for binary to decimal floating-point numbers. The implementation was slightly modified by JSON for Modern C++ library. Both Florian Loitsch's implementation and JSON for Modern C++ are provided under the MIT license.

For runtime dispatching, we use some code from the PyTorch project licensed under 3-clause BSD.