nosj 0.3.2-aarch64-linux → 0.4.1-aarch64-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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 10e414d3326f37cb0ce77ac5cf270f1ad1570af4d81a9913ab60f3ddadb7f803
4
- data.tar.gz: 68c7283d8fa6f206ffec6256158f61cf051c2c3d420d9e386972a7f1f5936d98
3
+ metadata.gz: c0c6310a850075604639942ee52efb27921987727dd11ca8a5b4533e5a416acf
4
+ data.tar.gz: 9f522e2ba5218ac34c6d0c249bfededb30cd606e07e99837cd17e0faa3f21097
5
5
  SHA512:
6
- metadata.gz: a591cfc2b26aea52dde5eb3ec512f9b22cc7217cf6e47c8d9c0f0ef1a199c4d55064c3632b490cb5c61ea7149f005fcd5284b91fb2e0fc26fbdd8626fddb2a29
7
- data.tar.gz: 5c804ad40c4046c11a6faa07a5f72920a62ea13234436805f19db5306bae516e472a7cd61fb3724d9be2093c94adf625608592d7a0646e95d2d6cd12eaeff7f3
6
+ metadata.gz: 6794e6297ee130061c85d532ba13d820ecd4ee2abe306aa50c835ef0ffebbab7e6f84417a94e533bb4ad311a25fdf7a374262659ff263e290f4bb17b3ddc115c
7
+ data.tar.gz: 1e9f2729a80368ac646f294f46c4fc915741209eb4603721399f8da60459d6bfbac730260fe3d8d7510f5eb07e957fb54f6031398d027c325871cb13495e948d
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
@@ -2,5 +2,5 @@
2
2
 
3
3
  module NOSJ
4
4
  # The gem version.
5
- VERSION = "0.3.2"
5
+ VERSION = "0.4.1"
6
6
  end
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.3.2
4
+ version: 0.4.1
5
5
  platform: aarch64-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.16
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.