Merge branch 'master' into jkeiser/json-pointer

This commit is contained in:
Daniel Lemire
2020-03-24 09:51:59 -04:00
committed by GitHub
3 changed files with 46 additions and 7 deletions
+22 -4
View File
@@ -12,6 +12,7 @@ This library is part of the [Awesome Modern C++](https://awesomecpp.com) list.
[![Build Status](https://cloud.drone.io/api/badges/simdjson/simdjson/status.svg)](https://cloud.drone.io/simdjson/simdjson)
[![CircleCI](https://circleci.com/gh/simdjson/simdjson.svg?style=svg)](https://circleci.com/gh/simdjson/simdjson)
[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/simdjson.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&q=proj%3Asimdjson&can=2)
[![Build status](https://ci.appveyor.com/api/projects/status/ae77wp5v3lebmu6n/branch/master?svg=true)](https://ci.appveyor.com/project/lemire/simdjson-jmmti/branch/master)
[![][license img]][license]
@@ -34,7 +35,7 @@ simdjson is easily consumable with a single .h and .cpp file.
std::cout << tweets["search_metadata"]["count"] << " results." << std::endl;
}
```
3. `g++ -o parser parser.cpp` (or clang++)
3. `c++ -o parser parser.cpp simdjson.cpp -std=c++17`
4. `./parser`
```
100 results.
@@ -63,6 +64,7 @@ QCon San Francisco 2019 (best voted talk):
- [Microsoft FishStore](https://github.com/microsoft/FishStore)
- [Yandex ClickHouse](https://github.com/yandex/ClickHouse)
- [Clang Build Analyzer](https://github.com/aras-p/ClangBuildAnalyzer)
- [azul](https://github.com/tudelft3d/azul)
If you are planning to use simdjson in a product, please work from one of our releases.
@@ -143,11 +145,27 @@ The json stream parser is threaded, using exactly two threads.
## Large files
If you are processing large files (e.g., 100 MB), it is likely that the performance of simdjson will be limited by page misses and/or page allocation. [On some systems, memory allocation runs far slower than we can parse (e.g., 1.4GB/s).](https://lemire.me/blog/2020/01/14/how-fast-can-you-allocate-a-large-block-of-memory-in-c/)
If you are processing large files (e.g., 100 MB), it is possible that the performance of simdjson will be limited by page misses and/or page allocation. [On some systems, memory allocation runs far slower than we can parse (e.g., 1.4GB/s).](https://lemire.me/blog/2020/01/14/how-fast-can-you-allocate-a-large-block-of-memory-in-c/)
You will get best performance with large or huge pages. Under Linux, you can enable transparent huge pages with a command like `echo always > /sys/kernel/mm/transparent_hugepage/enabled` (root access may be required). We recommend that you report performance numbers with and without huge pages.
A viable strategy is to amortize the cost of page allocation by reusing the same `parser` object over several files:
```C++
// create one parser
simdjson::document::parser parser;
...
// the parser is going to pay a memory allocation price
auto [doc1, error1] = parser.parse(largestring1);
...
// use again the same parser, it will be faster
auto [doc2, error2] = parser.parse(largestring2);
...
auto [doc3, error3] = parser.load("largefilename");
```
If you cannot reuse the same parser instance, maybe because your application just processes one large document once, you will get best performance with large or huge pages. Under Linux, you can enable transparent huge pages with a command like `echo always > /sys/kernel/mm/transparent_hugepage/enabled` (root access may be required). It may be more difficult to achieve the same result under other systems like macOS or Windows.
In general, when running benchmarks over large files, we recommend that you report performance numbers with and without huge pages if possible. Furthermore, you should amortize the parsing (e.g., by parsing several large files) to distinguish the time spent parsing from the time spent allocating memory.
Another strategy is to reuse pre-allocated buffers. That is, you avoid reallocating memory. You just allocate memory once and reuse the blocks of memory.
## Including simdjson
+9 -3
View File
@@ -6,9 +6,15 @@
- https://github.com/lemire/simdjson/issues/351
- https://github.com/lemire/simdjson/issues/345
Simdjson tries to follow [fuzzing best practises](https://google.github.io/oss-fuzz/advanced-topics/ideal-integration/#summary).
The simdjson library tries to follow [fuzzing best practises](https://google.github.io/oss-fuzz/advanced-topics/ideal-integration/#summary).
The simdjson library is continuously fuzzed on [oss-fuzz](https://github.com/google/oss-fuzz).
## Currently open bugs
You can find the currently opened bugs, if any at [bugs.chromium.org](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&q=proj%3Asimdjson&can=2): make sure not to miss the "Open Issues" selector. Bugs that are fixed by follow-up commits are automatically closed.
Simdjson is continuously fuzzed on [oss-fuzz](https://github.com/google/oss-fuzz).
## Fuzzing as a CI job
@@ -29,7 +35,7 @@ The corpus will grow over time and easy to find bugs will be detected already du
## Corpus
Simdjson does not benefit from a corpus as much as other projects, because the library is very fast and explores the input space very well. With that said, it is still beneficial to have one. The CI job stores the corpus on bintray between runs, and is available here: https://dl.bintray.com/pauldreik/simdjson-fuzz-corpus/corpus/corpus.tar
The simdjson library does not benefit from a corpus as much as other projects, because the library is very fast and explores the input space very well. With that said, it is still beneficial to have one. The CI job stores the corpus on bintray between runs, and is available here: https://dl.bintray.com/pauldreik/simdjson-fuzz-corpus/corpus/corpus.tar
One can also grab the corpus as an artifact from the github actions job. Pick a run, then go to artifacts and download.
+15
View File
@@ -1,6 +1,21 @@
#!/usr/bin/env ruby
require 'json'
y = []
10000.times do
h = {
'x' => rand,
'y' => rand,
'z' => rand,
'name' => ('a'..'z').to_a.shuffle[0..5].join + ' ' + rand(10000).to_s,
'opts' => {'1' => [1, true]},
}
y << h
end
File.open("2.json", 'w') { |f| f.write JSON.pretty_generate('coordinates' => y, 'info' => "some info") }
x = []
524288.times do