Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Parsing gigabytes of JSON per second

License

NotificationsYou must be signed in to change notification settings

JavaScriptExpert/simdjson

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fuzzing StatusCirrusCIUbuntu 18.04 CIUbuntu 20.04 CIVS16-CIMinGW64-CIDoxygen 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 freshapproach. The simdjson library uses commonly available SIMD instructions and microparallel algorithmsto 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 theAwesome 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) orclang++ (version 6 or better), and a 64-bit system with a command-line shell (e.g., Linux, macOS, freeBSD). We also support programming environnements like Visual Studio and Xcode, but different steps are needed.

  2. Pullsimdjson.h andsimdjson.cpp into a directory, along with the sample filetwitter.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. Createquickstart.cpp:

    #include"simdjson.h"intmain(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 andhow 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 parserRapidJSON andfifty percent less than sajson. To our knowledge, simdjson is the first fully-validating JSON parserto run atgigabytes 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 fileson 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 exactnumber parsing. The RapidJSON library is tested in two modes: fast andexact number parsing. The sajson library offers fast (but not exact)number parsing and partial unicode validation. In this data set, the filesizes range from 65KB (github_events) all the way to 3.3GB (gsoc-2018).Many files are mostly made of numbers: canada, mesh.pretty, mesh, randomand numbers: in such instances, we see lower JSON parsing speeds due to thehigh cost of number parsing. The simdjson library uses exact number parsing whichis 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.

parserGB/s
simdjson2.5
RapidJSON UTF8-validation0.29
RapidJSON UTF8-valid., exact numbers0.28
RapidJSON insitu, UTF8-validation0.41
RapidJSON insitu, UTF8-valid., exact0.39
sajson (insitu, dynamic)0.62
sajson (insitu, static)0.88
dropbox0.13
fastjson0.27
gason0.59
ultrajson0.34
jsmn0.25
cJSON0.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 parsingspeed forsynthetic 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 vectorinstructions, reducing branch misprediction, and reducing data dependency to take advantage of eachCPU's multiple execution cores.

Some peopleenjoy reading our paper: A description of the designand implementation of simdjson is in our research article: Geoff Langdale, DanielLemire,Parsing Gigabytes of JSON per Second, VLDB Journal 28 (6), 2019.

We also have an informalblog 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 grantnumber RGPIN-2017-03910.

Contributing to simdjson

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

License

This code is made available under theApache 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 supportC++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.

About

Parsing gigabytes of JSON per second

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++92.1%
  • C2.6%
  • CMake2.4%
  • Shell1.3%
  • Python0.9%
  • Ruby0.5%
  • Other0.2%

[8]ページ先頭

©2009-2025 Movatter.jp