GithubHelp home page GithubHelp logo

kerollmops / oxidized-json-checker Goto Github PK

View Code? Open in Web Editor NEW
13.0 3.0 1.0 65 KB

A pushdown automaton low memory JSON bytes stream checker

Home Page: https://docs.rs/oxidized-json-checker

License: Other

Rust 100.00%
json rust checker streaming low-memory pushdown-automaton

oxidized-json-checker's Introduction

oxidized-json-checker

This is a pure Rust version of the JSON_checker library.

This is a Pushdown Automaton that very quickly determines if a JSON text is syntactically correct. It could be used to filter inputs to a system, or to verify that the outputs of a system are syntactically correct.

You can use it with the std::io::Read Rust trait to checked if a JSON is valid without having to keep it in memory.

Performances

I ran some tests against jq to make sure the library when in the bounds. I used a big JSON lines files (8.3GB) that I converted to JSON using jq -cs '.' ๐Ÿ˜œ

You can find those Wikipedia articles on the benchmark repository of Paul Masurel's Tantivy.

jq type

How many times does jq takes when it comes to checking and determining the type of a JSON document? Probably too much, and also a little bit of memory: 12GB!

$ time cat ../wiki-articles.json | jq type
"array"

real    1m55.064s
user    1m37.335s
sys     0m21.935s

ojc

How many times does it takes to ojc? Just a little bit less! It also consumes 0kb of memory.

$ time cat ../wiki-articles.json | ojc
Array

real  0m56.780s
user  0m47.487s
sys   0m12.628s

ojc with SIMD

How many times does it takes to ojc already? 56s, that can't be true, we are in 2020... What about enabling some SIMD optimizations? Compile the binary with the nightly feature and here we go!

$ cargo build --release --features nightly
$ time cat ../wiki-articles.json | ojc
Array

real    0m15.818s
user    0m10.892s
sys     0m10.721s

oxidized-json-checker's People

Contributors

kerollmops avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

irevoire

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.