Go to file
Paul Dreik 92c34f7f38
do not use deprecated apis in the fuzzers (#705)
* move from deprecated interface in fuzz dump raw tape

* update fuzz_dump to the non deprecated replacement

* replace use of deprecated api

* hopefully fix windows build
2020-04-14 07:45:30 +02:00
.circleci Reference simdjson by name, don't specify include files individually 2020-04-08 14:52:55 -07:00
.github/workflows switch to clang 9 in the github action (#695) 2020-04-12 20:02:45 +02:00
benchmark Don't reinitialize submodules 2020-04-09 08:52:29 -07:00
dependencies Don't reinitialize submodules 2020-04-09 08:52:29 -07:00
doc Compile under C++ 11 2020-04-08 14:00:13 -07:00
examples Add quickstart to cmake 2020-04-09 14:56:54 -07:00
extra Removing all stdout, stderr from main library. (#455) 2020-01-20 16:03:15 -05:00
fuzz do not use deprecated apis in the fuzzers (#705) 2020-04-14 07:45:30 +02:00
images Improving the doxygen. (#687) 2020-04-08 17:53:04 -04:00
include Disabling threads on apple's hardware when optimizer is turned off (#692) 2020-04-10 18:41:05 -04:00
jsonchecker Adding another test 2020-01-02 14:22:43 -05:00
jsonexamples The testing files should not be all over the place. The "small" directory should be only for small files (duh). (#650) 2020-03-30 16:24:03 -04:00
scripts Add quicktests, slowtests to cmake 2020-04-09 14:21:45 -07:00
singleheader Trying again. (#671) 2020-04-02 19:24:43 -04:00
src Only apply compile flags to simdjson 2020-04-09 08:52:29 -07:00
style Hiding the pointer away... (#252) 2019-08-04 15:41:00 -04:00
tests Add quickstart to cmake 2020-04-09 14:56:54 -07:00
tools Don't run parsing competitions on Windows 2020-04-09 08:52:29 -07:00
windows Create simdjson-windows-headers interface library 2020-04-08 14:52:56 -07:00
.appveyor.yml Disable failing VS2017 tests in cmake 2020-04-08 14:58:28 -07:00
.clang-format We are adopting clang-format. 2019-08-01 15:40:07 -04:00
.dockerignore Bring .git into docker (#259) 2019-08-06 09:39:33 -04:00
.drone.yml Don't reinitialize submodules 2020-04-09 08:52:29 -07:00
.gitattributes Add sane defaults for .sh and such (#254) 2019-08-04 18:11:48 -04:00
.gitignore Add benchmark competitions to cmake 2020-04-09 08:52:29 -07:00
.gitmodules Remove googletest entirely as benchmark dependency (#504) 2020-02-21 12:52:38 -05:00
.travis.yml Adding style scripts. (#243) 2019-08-01 16:09:26 -04:00
AUTHORS Create AUTHORS 2018-12-27 20:46:57 -05:00
CMakeLists.txt Add quickstart to cmake 2020-04-09 14:56:54 -07:00
CONTRIBUTING.md Split docs into multiple files 2020-03-25 18:25:14 -07:00
CONTRIBUTORS Upgrading gcc to gcc 8 2020-01-06 18:28:29 -05:00
Dockerfile Fixing amalgamate under ARM 2019-07-30 22:10:48 +00:00
Doxyfile Improving the doxygen. (#687) 2020-04-08 17:53:04 -04:00
HACKING.md Split docs into multiple files 2020-03-25 18:25:14 -07:00
LICENSE Updating again. 2019-02-08 10:05:50 -05:00
Makefile Add quicktests, slowtests to cmake 2020-04-09 14:21:45 -07:00
README.md Only apply compile flags to simdjson 2020-04-09 08:52:29 -07:00
RELEASES.md Add error handling info to RELEASES.md 2020-03-30 13:44:03 -07:00
amalgamation.sh Move document/element/etc. under dom 2020-03-28 13:42:21 -07:00

README.md

Build Status CircleCI Fuzzing Status Build status

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 2.5x faster than anything else out there.
  • Fast: Over 2.5x faster than other production-grade JSON parsers.
  • Easy: First-class, easy to use API.
  • 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.

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.

  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 "simdjson.h"
    int main(void) {
      simdjson::dom::parser parser;
      simdjson::dom::element tweets = parser.load("twitter.json");
      std::cout << tweets["search_metadata"]["count"] << " results." << std::endl;
    }
    
  4. c++ -o quickstart quickstart.cpp simdjson.cpp

  5. ./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 and fifty percent less than sajson. To our knowledge, simdjson is the first fully-validating JSON parser to run at gigabytes per second 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 9 compiler (with the -O3 flag). We compare against the best and fastest C++ libraries. The simdjson library offers full unicode (UTF-8) validation and exact number parsing. The RapidJSON library is tested in two modes: fast and exact number parsing. The sajson library offers fast (but not exact) number parsing and partial unicode validation. In this data set, the file sizes range from 65KB (github_events) all the way to 3.3GB (gsoc-2018). Many files are mostly made of numbers: canada, mesh.pretty, mesh, random and numbers: in such instances, we see lower JSON parsing speeds due to the high cost of number parsing. The simdjson library uses exact number parsing which is particular taxing.

On a Skylake processor, the parsing speeds (in GB/s) of various processors on the twitter.json file are as follows, using again GNU GCC 9.1 (with the -O3 flag). The popular JSON for Modern C++ library is particularly slow: it obviously trades parsing speed for other desirable features.

parser GB/s
simdjson 2.5
RapidJSON UTF8-validation 0.29
RapidJSON UTF8-valid., exact numbers 0.28
RapidJSON insitu, UTF8-validation 0.41
RapidJSON insitu, UTF8-valid., exact 0.39
sajson (insitu, dynamic) 0.62
sajson (insitu, static) 0.88
dropbox 0.13
fastjson 0.27
gason 0.59
ultrajson 0.34
jsmn 0.25
cJSON 0.31
JSON for Modern C++ (nlohmann/json) 0.11

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.

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: Geoff Langdale, Daniel Lemire, Parsing Gigabytes of JSON per Second, VLDB Journal 28 (6), 2019.

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 (http://www.boost.org/LICENSE_1_0.txt). Like the Apache license, the Boost license is a permissive license allowing commercial redistribution.