pydantic / jiter

Fast iterable JSON parser.
https://crates.io/crates/jiter
MIT License
254 stars 19 forks source link

Batson #136

Open samuelcolvin opened 1 month ago

samuelcolvin commented 1 month ago

Adding "batson" binary alternative to JSON code crate.

From the README:

Binary Alternative To (J)SON. Designed to be very fast to query.

Inspired by Postgres' JSONB type and Snowflake's VARIANT type.

For a relatively small JSON document (3KB), batson is 14 to 126x faster than Jiter, and 106 to 588x faster than Serde.

test medium_get_str_found_batson   ... bench:          51 ns/iter (+/- 1)
test medium_get_str_found_jiter    ... bench:         755 ns/iter (+/- 66)
test medium_get_str_found_serde    ... bench:       5,420 ns/iter (+/- 93)
test medium_get_str_missing_batson ... bench:           9 ns/iter (+/- 0)
test medium_get_str_missing_jiter  ... bench:       1,135 ns/iter (+/- 46)
test medium_get_str_missing_serde  ... bench:       5,292 ns/iter (+/- 324)
codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 82.44804% with 304 lines in your changes missing coverage. Please review.

Project coverage is 87.58%. Comparing base (82d7146) to head (6513df5). Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
crates/batson/src/decoder.rs 61.53% 20 Missing and 45 partials :warning:
crates/batson/src/object.rs 86.60% 33 Missing and 25 partials :warning:
crates/batson/src/array.rs 87.40% 12 Missing and 36 partials :warning:
crates/batson/src/header.rs 78.04% 32 Missing and 13 partials :warning:
crates/batson/src/errors.rs 0.00% 34 Missing :warning:
crates/batson/src/get.rs 84.69% 16 Missing and 14 partials :warning:
crates/batson/src/encoder.rs 91.13% 5 Missing and 9 partials :warning:
crates/batson/src/lib.rs 85.00% 3 Missing and 3 partials :warning:
crates/batson/src/json_writer.rs 94.66% 1 Missing and 3 partials :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #136 +/- ## ========================================== - Coverage 90.94% 87.58% -3.36% ========================================== Files 12 21 +9 Lines 2042 3770 +1728 Branches 2042 3770 +1728 ========================================== + Hits 1857 3302 +1445 - Misses 112 248 +136 - Partials 73 220 +147 ``` | [Files with missing lines](https://app.codecov.io/gh/pydantic/jiter/pull/136?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydantic) | Coverage Δ | | |---|---|---| | [crates/jiter/src/lazy\_index\_map.rs](https://app.codecov.io/gh/pydantic/jiter/pull/136?src=pr&el=tree&filepath=crates%2Fjiter%2Fsrc%2Flazy_index_map.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydantic#diff-Y3JhdGVzL2ppdGVyL3NyYy9sYXp5X2luZGV4X21hcC5ycw==) | `97.03% <100.00%> (+1.07%)` | :arrow_up: | | [crates/jiter/src/python.rs](https://app.codecov.io/gh/pydantic/jiter/pull/136?src=pr&el=tree&filepath=crates%2Fjiter%2Fsrc%2Fpython.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydantic#diff-Y3JhdGVzL2ppdGVyL3NyYy9weXRob24ucnM=) | `97.43% <100.00%> (ø)` | | | [crates/jiter/src/value.rs](https://app.codecov.io/gh/pydantic/jiter/pull/136?src=pr&el=tree&filepath=crates%2Fjiter%2Fsrc%2Fvalue.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydantic#diff-Y3JhdGVzL2ppdGVyL3NyYy92YWx1ZS5ycw==) | `82.35% <100.00%> (+0.64%)` | :arrow_up: | | [crates/batson/src/json\_writer.rs](https://app.codecov.io/gh/pydantic/jiter/pull/136?src=pr&el=tree&filepath=crates%2Fbatson%2Fsrc%2Fjson_writer.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydantic#diff-Y3JhdGVzL2JhdHNvbi9zcmMvanNvbl93cml0ZXIucnM=) | `94.66% <94.66%> (ø)` | | | [crates/batson/src/lib.rs](https://app.codecov.io/gh/pydantic/jiter/pull/136?src=pr&el=tree&filepath=crates%2Fbatson%2Fsrc%2Flib.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydantic#diff-Y3JhdGVzL2JhdHNvbi9zcmMvbGliLnJz) | `85.00% <85.00%> (ø)` | | | [crates/batson/src/encoder.rs](https://app.codecov.io/gh/pydantic/jiter/pull/136?src=pr&el=tree&filepath=crates%2Fbatson%2Fsrc%2Fencoder.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydantic#diff-Y3JhdGVzL2JhdHNvbi9zcmMvZW5jb2Rlci5ycw==) | `91.13% <91.13%> (ø)` | | | [crates/batson/src/get.rs](https://app.codecov.io/gh/pydantic/jiter/pull/136?src=pr&el=tree&filepath=crates%2Fbatson%2Fsrc%2Fget.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydantic#diff-Y3JhdGVzL2JhdHNvbi9zcmMvZ2V0LnJz) | `84.69% <84.69%> (ø)` | | | [crates/batson/src/errors.rs](https://app.codecov.io/gh/pydantic/jiter/pull/136?src=pr&el=tree&filepath=crates%2Fbatson%2Fsrc%2Ferrors.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydantic#diff-Y3JhdGVzL2JhdHNvbi9zcmMvZXJyb3JzLnJz) | `0.00% <0.00%> (ø)` | | | [crates/batson/src/header.rs](https://app.codecov.io/gh/pydantic/jiter/pull/136?src=pr&el=tree&filepath=crates%2Fbatson%2Fsrc%2Fheader.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydantic#diff-Y3JhdGVzL2JhdHNvbi9zcmMvaGVhZGVyLnJz) | `78.04% <78.04%> (ø)` | | | [crates/batson/src/array.rs](https://app.codecov.io/gh/pydantic/jiter/pull/136?src=pr&el=tree&filepath=crates%2Fbatson%2Fsrc%2Farray.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydantic#diff-Y3JhdGVzL2JhdHNvbi9zcmMvYXJyYXkucnM=) | `87.40% <87.40%> (ø)` | | | ... and [2 more](https://app.codecov.io/gh/pydantic/jiter/pull/136?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydantic) | | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/pydantic/jiter/pull/136/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydantic) ------ [Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/pydantic/jiter/pull/136?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydantic). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydantic) > `Δ = absolute (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://app.codecov.io/gh/pydantic/jiter/pull/136?dropdown=coverage&src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydantic). Last update [82d7146...6513df5](https://app.codecov.io/gh/pydantic/jiter/pull/136?dropdown=coverage&src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydantic). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydantic).
codspeed-hq[bot] commented 1 month ago

CodSpeed Performance Report

Merging #136 will improve performances by 11.69%

Comparing batson (6513df5) with main (ae5fc7d)

Summary

⚡ 1 improvements ✅ 72 untouched benchmarks

Benchmarks breakdown

Benchmark main batson Change
sentence_jiter_iter 7.8 µs 6.9 µs +11.69%