nosj 0.3.2-x86_64-linux → 0.4.1-x86_64-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +55 -0
- data/README.md +19 -1
- data/lib/nosj/3.3/nosj.so +0 -0
- data/lib/nosj/3.4/nosj.so +0 -0
- data/lib/nosj/4.0/nosj.so +0 -0
- data/lib/nosj/version.rb +1 -1
- data/lib/nosj.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1b1ee57c8d059a5906baba48a25a9cd0ddb58c259110e62b6ce6fe3ba4377e0f
|
|
4
|
+
data.tar.gz: 312af7ca03bb1ea8bf65d8f55d68d4e5a49f8ebccc512246cd14b6652ddf6f09
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7f5cec4abab64a013bddbee26c0813750c3d66942dcb94c50c54f499e0d34e5515b34ffe8f2e4cf1ebc6e4c3647604120e3003194f4f87637d8230314e4eecfc
|
|
7
|
+
data.tar.gz: 7916c28d532c41a458d8b0b6aa7e6d37a411574728a0b44e7d526dd397bdd6ce8627060a3255ce4f7685931ee778f67c11fa206af97df9d432e1929d89c168ba
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,58 @@
|
|
|
1
|
+
## [0.4.1] - 2026-09-25
|
|
2
|
+
|
|
3
|
+
- Fixed a crash in `NOSJ.generate`: an object whose `to_json` or
|
|
4
|
+
`to_s` shrank the array being generated (for example with
|
|
5
|
+
`Array#clear`) made the generator read freed memory, usually a
|
|
6
|
+
segfault. The array length is now re-read for every element, like
|
|
7
|
+
the json gem, so elements a callback appends are emitted too.
|
|
8
|
+
- Fixed memory corruption in `NOSJ.splice`: a replacement value whose
|
|
9
|
+
`to_json` modified the source string, deduplicated a frozen String
|
|
10
|
+
subclass (`-str`), or removed entries from the edits hash could make
|
|
11
|
+
splice read freed memory, copying unrelated heap bytes into the
|
|
12
|
+
result or crashing. All values are now generated before the source
|
|
13
|
+
is read.
|
|
14
|
+
- Fixed `NOSJ.lazy` and `NOSJ.each_line` reading freed memory when the
|
|
15
|
+
source is a frozen String subclass (such as
|
|
16
|
+
`ActiveSupport::SafeBuffer`) or a frozen string carrying instance
|
|
17
|
+
variables, and it is deduplicated with `-str` while the lazy
|
|
18
|
+
document is alive or between lines: Ruby swaps such a string's
|
|
19
|
+
buffer, and the old one kept being read (wrong values, or a crash).
|
|
20
|
+
- Fixed a memory leak in `NOSJ.generate` and `NOSJ.write_file`: an
|
|
21
|
+
exception raised by user code the generator calls bypassed its
|
|
22
|
+
cleanup and leaked its output buffer (megabytes per call after large
|
|
23
|
+
documents). Affected: a raising `respond_to?` or
|
|
24
|
+
`respond_to_missing?`, a raising `to_s` on an encoding-conversion
|
|
25
|
+
error, a raising autoload of `JSON::Fragment` (strict and Rails
|
|
26
|
+
modes), and a raising `Errno` constructor for a failed write. The
|
|
27
|
+
exception still propagates unchanged.
|
|
28
|
+
- Fixed: after a `NoMemoryError` in the middle of a parse (or
|
|
29
|
+
`minify`/`reformat`), the next call on that thread aborted the whole
|
|
30
|
+
process. Per-thread parser state is now recovered instead.
|
|
31
|
+
- `NOSJ::Lazy` nodes now take part in generational GC: holding many
|
|
32
|
+
nodes no longer slows down every minor GC (200,000 live nodes: 2.9 ms
|
|
33
|
+
per minor GC before, 0.1 ms now), and they are freed immediately
|
|
34
|
+
when collected.
|
|
35
|
+
- Fixed: lazy documents opened with `allow_trailing_comma: true` or
|
|
36
|
+
`allow_nan: true` could not be walked. `size`, `keys`, `each`, and
|
|
37
|
+
any lookup that missed or stepped over a trailing comma or a `NaN`
|
|
38
|
+
raised `NOSJ::ParserError`, even though `value` worked.
|
|
39
|
+
- `NOSJ.at_pointer`, `NOSJ.at_pointers`, and `NOSJ.at_pointer_file`
|
|
40
|
+
now honor `allow_nan` and `allow_trailing_comma` while resolving the
|
|
41
|
+
pointer, not only when materializing the matched value.
|
|
42
|
+
- Updated the nosj crate to 0.2.2.
|
|
43
|
+
- Updated dependencies, Magnus bumped to 0.9.0.
|
|
44
|
+
|
|
45
|
+
## [0.4.0] - 2026-09-05
|
|
46
|
+
|
|
47
|
+
- Ractors: on Ruby 4.0+, `NOSJ.parse`, `NOSJ.generate`, and every
|
|
48
|
+
other entry point (lazy documents, partial parsing, the file APIs,
|
|
49
|
+
NDJSON, patches, reformatting, statistics) can be called from inside
|
|
50
|
+
a Ractor. Before this release each of them raised
|
|
51
|
+
`Ractor::UnsafeError` outside the main Ractor. Values parsed with
|
|
52
|
+
`freeze: true` are Ractor-shareable, so a document parsed in one
|
|
53
|
+
Ractor can be handed to another without copying.
|
|
54
|
+
- Updated Rust dependencies.
|
|
55
|
+
|
|
1
56
|
## [0.3.2] - 2026-07-19
|
|
2
57
|
|
|
3
58
|
- **IMPORTANT**—Fixed: the precompiled platform gems linked `libruby`
|
data/README.md
CHANGED
|
@@ -16,6 +16,7 @@ faster than Yajl—[see Benchmarks](#benchmarks).
|
|
|
16
16
|
- It does **byte-splicing edits**: `NOSJ.splice` changes a field inside a passing payload 10–51× faster than parse-mutate-generate, and RFC 6902 JSON Patch / RFC 7386 merge patch apply straight to the raw string.
|
|
17
17
|
- It is **great to debug with**: parse errors carry line, column, and a caret snippet pointing at the break, and `NOSJ.stats` X-rays a mystery blob (depth, value counts, key histogram) faster than parsing it.
|
|
18
18
|
- It accelerates a **Rails** application in both encoding and decoding.
|
|
19
|
+
- It is **Ractor-safe**: call it from any Ractor on Ruby 4.0+, and parse with `freeze: true` to get shareable results.
|
|
19
20
|
- It comes **precompiled** (platform gems built with per-platform optimizations,
|
|
20
21
|
nothing to compile on install).
|
|
21
22
|
- Otherwise, same API and option names as gem json.
|
|
@@ -150,7 +151,8 @@ Example: an early field resolves in ~0.35µs where `JSON.parse(json).dig(...)`
|
|
|
150
151
|
costs ~980µs on the same document—three orders of magnitude. A field
|
|
151
152
|
at the far end of a 570 KB document costs ~71µs, still 13× faster
|
|
152
153
|
than parse-then-dig. Misses return nil; matched subtrees materialize
|
|
153
|
-
with the same options as `parse` (`symbolize_names:`, `freeze:`)
|
|
154
|
+
with the same options as `parse` (`symbolize_names:`, `freeze:`), and
|
|
155
|
+
`allow_nan:`/`allow_trailing_comma:` govern the walk to them too.
|
|
154
156
|
|
|
155
157
|
### Files API
|
|
156
158
|
|
|
@@ -300,6 +302,22 @@ NOSJ.parse(%({\n "a": 1,\n "b": }))
|
|
|
300
302
|
# ^
|
|
301
303
|
```
|
|
302
304
|
|
|
305
|
+
### Ractors
|
|
306
|
+
|
|
307
|
+
On Ruby 4.0+, every entry point works inside a Ractor: parse and
|
|
308
|
+
generate, lazy documents, partial parsing, the file APIs, NDJSON,
|
|
309
|
+
patches, reformatting, and statistics.
|
|
310
|
+
|
|
311
|
+
```ruby
|
|
312
|
+
workers = Array.new(4) do
|
|
313
|
+
Ractor.new(payload) { |src| NOSJ.parse(src, freeze: true) }
|
|
314
|
+
end
|
|
315
|
+
workers.map(&:value)
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
`freeze: true` returns deeply frozen, Ractor-shareable values, so a
|
|
319
|
+
document parsed in one Ractor can be handed to another without a copy.
|
|
320
|
+
|
|
303
321
|
## Benchmarks
|
|
304
322
|
|
|
305
323
|
Every installed JSON gem, benchmark-ips: AWS EC2 c7a.2xlarge (AMD EPYC 9R14, Zen 4), Ruby 4.0.6 + YJIT, json 2.21.1, Oj 3.17.4, RapidJSON 0.4.0, FastJsonparser 0.6.0, Yajl 1.4.3, PGO build, 2026-07-16. `×N` = times slower than nosj.
|
data/lib/nosj/3.3/nosj.so
CHANGED
|
Binary file
|
data/lib/nosj/3.4/nosj.so
CHANGED
|
Binary file
|
data/lib/nosj/4.0/nosj.so
CHANGED
|
Binary file
|
data/lib/nosj/version.rb
CHANGED
data/lib/nosj.rb
CHANGED
|
@@ -205,7 +205,8 @@ module NOSJ
|
|
|
205
205
|
|
|
206
206
|
# Partial parsing by JSON Pointer (with the standard +~0+/+~1+
|
|
207
207
|
# escapes). The matched subtree materializes under the same options
|
|
208
|
-
# as {.parse}
|
|
208
|
+
# as {.parse}; +allow_nan+ and +allow_trailing_comma+ also govern the
|
|
209
|
+
# walk to it.
|
|
209
210
|
#
|
|
210
211
|
# @example
|
|
211
212
|
# NOSJ.at_pointer(json, "/users/3/name") #=> "grace" or nil
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: nosj
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.1
|
|
5
5
|
platform: x86_64-linux
|
|
6
6
|
authors:
|
|
7
7
|
- Yaroslav Markin
|
|
@@ -66,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
67
|
version: 3.3.11
|
|
68
68
|
requirements: []
|
|
69
|
-
rubygems_version: 4.0.
|
|
69
|
+
rubygems_version: 4.0.20
|
|
70
70
|
specification_version: 4
|
|
71
71
|
summary: An extremely fast JSON parser and generator for Ruby, written in Rust and
|
|
72
72
|
SIMD-accelerated on every platform.
|